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: Victor Khomenko
Subject: RE: Enhancement request: enabling Variant in C parsers
Date: Sun, 19 Aug 2018 12:24:21 +0000

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. Generally, the c 
vs c++ dichotomy is unhelpful; I'd rather view these as different interfaces. 
E.g. one could choose independently function vs object and variant vs union. 
Then, if the user uses a pure C compiler, some options are not available to 
them.


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


> 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 :-(
Maybe it would be less scary to start with something simpler, like the example 
you attached.
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).

All the best,
Victor.


reply via email to

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