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: Peng Yu
Subject: Re: Is it always possible to make a non-reentrant parser reentrant?
Date: Fri, 8 Feb 2019 05:39:23 -0600

On Thu, Feb 7, 2019 at 11:49 PM Akim Demaille <address@hidden> wrote:

> 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.


Probably it should be another scanner. I only has a vague idea and I don’t
know what will the implementation details.

I’d like to know what is the best way to structure the parsing code. Given
a lot of code of bash started 30 years ago, I’d expect at least some part
of the code is not the  best according to today’s standard. I’d like to
know anything that can improve it.

> --
Regards,
Peng


reply via email to

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