[Top][All Lists]

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

Re[2]: I need simpler examples (was: RE: Enhancement request: enabling V

From: Askar Safin
Subject: Re[2]: I need simpler examples (was: RE: Enhancement request: enabling Variant in C parsers)
Date: Sat, 08 Dec 2018 19:06:36 +0300

Hi, Akim.

>This is the Bison manual, and we don't try to compete with the "flex & bison" 
I tried to websearch this book and found it in Google Books. Google Books 
showed me preview and suggested to buy full copy. Also I found some free online 
full copy, but I wonder whether it is legal. So, it seems this book is not free 
(I mean free as free beer). And also it seems it is not free as in freedom. So, 
it seems that if user has problems with understanding how Flex and Bison work 
(they are both free software), you suggest them go read non-free book. You said 
you don't try to complete. Well, you should do exactly this: complete with 
non-free documentation. What Stallman would say?

Even if you don't agree with me, well, at least, please, insert a link to the 
manual pointing to that book.

>Besides, locations are also a key feature.  Since out there there are many 
>examples that don't show how to track locations, and since it's a fundamental 
>feature for any user-facing parser, we _have_ to show how it works.
I still think that the manual should give at least one C+Flex+Bison example 
without locations and at least one "C++"+Flex+Bison example without locations. 
Just because the user should have something simple to begin with. Okey, I 
agree, that this examples should be pure. If you add them to /examples/, then, 
please, link them from the manual. Even if you will not add examples, please, 
insert a link to some external web page, where users can view them.

>Again, there are plenty of this on the Internet.
No. When I first decided to write Flex+Bison+"C++" parser, I didn't find 
anything useful in internet. Right now I repeated my websearch and didn't find 
anything useful again. What I want is "C++"+Flex+Bison example, which contains 
nothing on top of "C++"+Flex+Bison. In particular it should not contain any 
"driver classes", nor it should contain any other code, which is not needed for 
example. The only source files should be scanner.ll, parser.yy and possibly 
main.cc and some short headers, but nothing more. The user should not try to 
figure which code is essential, and which is not (and thus can be removed). 
What I found instead? This is first 6 links in Google search "c++ bison flex 
example" from my computer (note, that Google does so-called "bubbling", so at 
your computer you may get different search results):

This is that behemoth scary big example from official documentation

* https://github.com/bingmann/flex-bison-cpp-example
Contains driver.cc with driver class

* https://github.com/ezaquarii/bison-flex-cpp-example
Contains driver, too, and also some command.cpp and interpreter.cpp

* https://panthema.net/2007/flex-bison-cpp-example/
This is just mirror of already mentioned 

* http://www.jonathanbeard.io/tutorials/FlexBisonC++
Contains driver, again

* https://stackoverflow.com/questions/26619079/compiling-flex-and-bison-into-cpp
The only example is link to already mentioned 

You may say that driver is useful. Well, yes, probably. But I still think that 
a user should see example without any driver just to understand how the example 

Also, it is possible the user have already working parser written in C. And he 
wants to know what exactly he should change to turn it into C++ parser (also 
let's assume he wants to use C++ semantic values with non-trivial destructors 
etc, so just processing Bison output with C++ compiler is not enough). So this 
user wants example as simple as possible. Just to know what is difference 
between C parser and C++ parser. Just to know what exactly he should change. 
Instead Bison manual gives huge example with some driver class (what this 

Well, I am not trying to say that I am too stupid to understand driver class. I 
just want to say that first I want to see example without driver class, and 
only after that example with driver class.

Here is how I would write C++ example: 
https://paste.gg/p/anonymous/ad450c26fd6d443b900fbc36f4eb599e . It is possible 
I did something wrong. Well, my example just to show you what size C++ example 
should have. I don't claim the example to be perfect. I tested it, and it works.

* As you can see, this is bare minimum. There is only two files, not counting 
* My example seems to be pure parser
* I warned the user that Flex processes C++ code, but is run in C mode, and 
thus thinks that it processes C code (your example does the same, but you 
didn't warned user about this)
* I give exact command lines to run my example, you don't

Unfortunately, I was not able to find in internet something like this example. 
If I had this example available when I first tried to understand everything, 
this would be very good. If you will include my example into docs, well, this 
would be very good, but then, please, check it for errors.

>We are quite a few here to have some experience with Flex in C++, and it's not 
You mean that Flex is rarely used in C++ mode? Okey, call it in C mode then

>Why Flex only?  There is also POSIX Lex
Is there any lex implementation in use today not counting flex?

>I'm not sure there's really a need for such a templating system, but once it 
>exists, I will be most happy to use it to generate the flex+bison in C to add 
>to examples/c, or to point Bison users to it
Unfortunately, I will not create such in near future

Askar Safin

reply via email to

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