diff options
Diffstat (limited to 'bin/sh.l')
-rw-r--r-- | bin/sh.l | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/bin/sh.l b/bin/sh.l index b27ecebc..8f0f7723 100644 --- a/bin/sh.l +++ b/bin/sh.l @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 C. McEnroe <june@causal.agency> +/* Copyright (C) 2021 June McEnroe <june@causal.agency> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -15,7 +15,7 @@ */ %option prefix="sh" -%option noyywrap +%option noinput nounput noyywrap %{ #include <assert.h> @@ -36,7 +36,7 @@ static int pop(void) { } %} -%s Param Command Arith Backtick +%s Param Command Arith Backtick Subshell %x DQuote HereDocDel HereDoc HereDocLit word [[:alnum:]_.-]+ @@ -51,7 +51,7 @@ reserved [!{}]|else|do|elif|for|done|fi|then|until|while|if|case|esac "\\". { return Escape; } -<INITIAL,DQuote,HereDoc,Param,Command,Arith>{ +<INITIAL,DQuote,HereDoc,Param,Command,Arith,Subshell>{ "$"[*@#?$!0-9-] | "$"[_[:alpha:][_[:alnum:]]* | "${"[#]?{param}"}" { @@ -73,6 +73,10 @@ reserved [!{}]|else|do|elif|for|done|fi|then|until|while|if|case|esac BEGIN(push(Backtick)); return Subst; } + "(" { + BEGIN(push(Subshell)); + return Normal; + } } <Param>"}" | <Command>")" | @@ -81,6 +85,10 @@ reserved [!{}]|else|do|elif|for|done|fi|then|until|while|if|case|esac BEGIN(pop()); return Subst; } +<Subshell>")" { + BEGIN(pop()); + return Normal; +} "\n" { first = true; @@ -168,11 +176,6 @@ reserved [!{}]|else|do|elif|for|done|fi|then|until|while|if|case|esac .|\n { return Normal; } -%{ - (void)yyunput; - (void)input; -%} - %% const struct Lexer LexSh = { yylex, &yyin, &yytext }; |