[Top][All Lists]

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

Re: Enhancement request: enabling Variant in C parsers

From: Rici Lake
Subject: Re: Enhancement request: enabling Variant in C parsers
Date: Sun, 19 Aug 2018 11:21:08 -0500

Vaguely on this topic, since you seem to be working on a new release:

On Sun, Aug 19, 2018, 10:23 Akim Demaille <address@hidden> wrote:

> Note that you don’t have anything to do to reset the parser, all the
> problem is actually the scanner.  The parser object holds no state,
> everything is local to yyparse.

That's not the case for a push parser (which unfortunately is not an option
in C++ or Java.) As it happens, that's my preferred API, and at some point
I needed to convince myself that it was unnecessary to reset the parser
state "object".

Since this fact is not documented, it is presumably unspecified whether any
guarantee will be maintained. I think it's a useful guarantee, and since it
is already implemented it might as well be documented, by adding something
like the following paragraph to the end of section 4.2:

> After yypush_parse returns a status other than YYPUSH_MORE, the parser
instance yyps may be reused for a new parse.

I guess a similar guarantee could be provided in the documentation for
yypull_parse (without mention of YYPUSH_MORE), since that is just a thin
wrapper around yypush_parse.


The fact that the parser state is reusable even after an error simplifies
reuse. For example, a calculator application which parses each input line
as an expression can just keep reusing the same pstate even if an input was
invalid. (The scanner will need to be reset but that's not bison's problem.)


reply via email to

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