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

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Hi Peng,

> Le 8 févr. 2019 à 02:01, Peng Yu <[email protected]> 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.
_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.