bug-bison
[Top][All Lists]
Advanced

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

Re: Enhancement request: enabling Variant in C parsers


From: Akim Demaille
Subject: Re: Enhancement request: enabling Variant in C parsers
Date: Sun, 19 Aug 2018 17:23:23 +0200

Hey!

> Le 19 août 2018 à 14:24, Victor Khomenko <address@hidden> a écrit :
> 
> Hi Akim,
> 
>> Bison’s variants are for C++, I don’t think porting this to C would be 
>> trivial.
>> They are made to live in a C++ container, not a C array.  Existing variants 
>> show
>> a path though, granted.
> 
> If a c++ compiler is to be used, having a c++ container is ok.

I was referring to the C skeletons, that use C arrays.

>> It seems to me that you are comparing
>> 
>>    yyparse();
>> 
>> with
>> 
>>    yy::parser p;
>>    p.yyparse();
> 
> BTW, can I suggest to provide operator() in yy::parser so that it can be used 
> as a functor? This will shorten the above to yy::parser()(); also it would 
> work well with the standard template library, e.g. one could use 
> std::for_each to apply the parser to a list of file names, etc.

It does make sense, you are right!


>> I would strongly suggest that you look at the examples/ in Bison, the C++
>> calculator
> 
> I did look at it - this example scared me off c++ parsers :-(

Really???  Then I failed.  Can you be more specific?

> Maybe it would be less scary to start with something simpler, like the 
> example you attached.

Ok.

> Generally, the c++ section of the bison manual is rather sketchy, it would be 
> nice to add the detailed description of the generated parsing class, in 
> particular how to reset it to parse another file, how to reset it after an 
> error (or explicitly state that no reset is required).

Contributions are most welcome ;)  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.

I’ll try to look at this section with a fresh eye for the following release, 
and fix these issues.  Help will be deeply appreciated :)


reply via email to

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