help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it always possible to make a non-reentrant parser reentrant?


From: Akim Demaille
Subject: Re: Is it always possible to make a non-reentrant parser reentrant?
Date: Fri, 8 Feb 2019 06:49:18 +0100

Hi Peng,

> Le 8 févr. 2019 à 02:01, Peng Yu <address@hidden> a écrit :
> 
> [...]
> For example, to deal with heredoc in bash, the grammar rule will change the
> variable `need_here_doc` via `push_heredoc()`.
> 
> ```
>    |   LESS_LESS WORD
>            {
>              source.dest = 0;
>              redir.filename = $2;
>              $$ = make_redirection (source, r_reading_until, redir, 0);
>              push_heredoc ($$);
>            }
> [...]
> `need_here_doc` is used in `read_token()`, which is called by
> `yylex()`. This makes the behavior of `yylex()` non-automomous.
> 
> It seems to me that the parsing code could be made simpler by making
> the parser reentrant. So there can be a parser parses anything not
> heredoc and another parser just parse heredoc. And there should
> different lexers for non-heredoc and heredoc. Is it so?

I'm a bit confused here: did you really mean "another parser", or did
you mean "another scanner"?  If you do mean "another parser", I'm not
sure how you would coordinate the several layers.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]