Le 27 nov. 2013 à 23:25, Arthur Schwarz <[email protected]> a écrit :
> Hi Akim; Hi! > The issue here is that in setting the language too C++ in bison, the bison > interface x.tab.h file buries %union in class parser but does not define > YYSTYPE. This poses a problem when interfacing with flex. No, not really. Please, have a look at the documentation that features a complete example in C++. > As to your comment about using 'bison -d'. This is the interface generated > with junk.y. junk.tab.hh has been stripped of everything not necessary to > describe the problem. And note that in class parser if YYSTYPE is not > defined, it doesn't get defined and/or a typedef is not created. But if > YYSTYPE is defined, then a typedef is created with semantic_type. If you want your Flex scanner to see the definition of the type, you need -d. Now, Flex does not know anything about YYSTYPE, just type parser::semantic_type parser instead. this is C++, there is no longer any reason to pollute the global namespace with a name such as YYSTYPE. If you want to use that name, just typedef it from parser::semantic_type. > My integration difficulties with flex and bison are many. flex %bison-bridge > does something, I don't quite know what but it doesn't integrate well. Then don't use it. > At the same time when I tried %option C++ (to generate a C++ file) it also > didn't integrate well, and if I remember correctly, there were compiler > errors. using Flex in C++ is really tricky, I concur. > I have a C++ project. One element of the project (only one) leads me to try > to use flex and bison. I use flex because (by gosh and by golly) it's tedious > to develop a scanner, particularly a scanner which includes floating point > numbers. As a first step, I would recommend a C-scanner, and C++-parser.
