> On 17 Feb 2019, at 17:36, Peng Yu <pengyu...@gmail.com> wrote:
> 
> But how to recognize the nested parameter expansion assignment in the
> first place? The lexer should have builtin states to capture paired
> `{` `}`, and use states to remember whether it is in substring
> extraction or pattern replacement in order to make sure to capture any
> errors at the level of the lexer.

Such matched pairs can be recognized in the lexer by using an integer starting 
at 0 adding 1 for each '{' and -1 for each '}' when valid. If one gets non-zero 
at the end of the expression, there is a mismatch. The problem is how to 
recognize the end of the expression. The Bison parser does that by a lookahead 
token if needed. So that might suggest to put it on the parser.



_______________________________________________
help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to