Re: bison and C++ exceptions

2011-08-03 Thread John Horigan
It would be nice if YYABORT, YYERROR, and YYACCEPT were all implemented as exception throws, instead of gotos. Then you could throw them deep in your AST class and still have Bison do the right thing. Then Bison could catch all other exceptions, clean up, and rethrow the non-Bison exception up t

Re: bison and C++ exceptions

2011-06-13 Thread Akim Demaille
Le 24 mai 2011 à 20:32, Sergey Klimkin a écrit : > Hi! Hi! > Trying to find information about C++ exceptions in semantic actions, with no > results. > Is there any Bison %Decl which allows to move parse stack outside yyparse(), > to destroy a stack values after an exception was thrown within se

Re: bison and C++ exceptions

2011-05-26 Thread Hans Aberg
[Please keep the cc to the help-bison list, so others know.] On 26 May 2011, at 13:03, John P. Hartmann wrote: > Well, I did forget, but in this case maybe we do not confuse the children. > > At one point bison picked up a bug in one of the M4 macros. It was > not easy to spot, and it took a wh

Re: bison and C++ exceptions

2011-05-26 Thread Hans Aberg
[Please keep the cc to the help-bison list, so others know.] On 26 May 2011, at 11:16, John P. Hartmann wrote: > The M4 manual by itself is of little use, as all macros are redefined. It says how to redefine them, so advanced users that need to know how it work, should consult it. It is otherw

Re: bison and C++ exceptions

2011-05-26 Thread Hans Aberg
On 26 May 2011, at 07:35, Sergey Klimkin wrote: > I guess it might be helpful, I can not claim yet : ) > there is %initial-action declaration and the %final-action may help, > but rhs symbols will not be discarded. > > %initial-action > { > try { > } > > %final-action > { >} >catch (std:

Re: bison and C++ exceptions

2011-05-25 Thread Sergey Klimkin
I guess it might be helpful, I can not claim yet : ) there is %initial-action declaration and the %final-action may help, but rhs symbols will not be discarded. %initial-action { try { } %final-action { } catch (std::exception &) { yyerror(...); YYABORT; } } into some se

Re: bison and C++ exceptions

2011-05-25 Thread Hans Aberg
On 24 May 2011, at 20:32, Sergey Klimkin wrote: > Trying to find information about C++ exceptions in semantic actions, with no > results. > Is there any Bison %Decl which allows to move parse stack outside yyparse(), > to destroy a stack values after an exception was thrown within semantic > actio

bison and C++ exceptions

2011-05-24 Thread Sergey Klimkin
Hi! Trying to find information about C++ exceptions in semantic actions, with no results. Is there any Bison %Decl which allows to move parse stack outside yyparse(), to destroy a stack values after an exception was thrown within semantic action!? something like: yyparse_stack my_stack; try {

bison and C++

2008-04-11 Thread peter_foelsche
Dear All, it would certainly help if the C++ generated parser would allocate the stack using std::vector so that constructors and destructors are automatically called. And this would also make certain that the parser stack is only limited by the amount of memory. This also would obsolete th

Re: flex+bison and C++, second part (Solved)

2007-04-12 Thread Tamas Nagy
Hi! All problem solved by reading and applying: http://tldp.org/HOWTO/Lex-YACC-HOWTO-5.html Tamas > Hi! > > With no parser.c. Main() is in the .y file, the > following error occured: > > alfa.tab.cpp: In function `int yyparse()': > alfa.tab.cpp:1097: error: `yylex' undeclared (first > use thi

Re: flex+bison and C++, second part

2007-04-12 Thread Tamas Nagy
Hi! With no parser.c. Main() is in the .y file, the following error occured: alfa.tab.cpp: In function `int yyparse()': alfa.tab.cpp:1097: error: `yylex' undeclared (first use this function) alfa.tab.cpp:1097: error: (Each undeclared identifier is reported only once for each function it appear

Re: flex+bison and C++, second part

2007-04-12 Thread Tamas Nagy
Hi! I also have a parser.c file. (sourcehandler) Should i have to rewrite it to c++ or just link it? Because of this, which is in the .y file: vrml_filel_init(f, argv[1]); it cannot compile to c++. Even if #include "prog.tab.h" it cannot see the above function. I have the bottom files too: >

Re: flex+bison and C++, second part

2007-04-10 Thread JPerez45
Got link problem (i suppose) so the general way to compile a lex & yacc program is: 1. Generate the lexer lex my_file.l 2. Generate the parser yacc -d my_file.y 3. Compile the sources cc -c lex.yy.c y.tab.cc 4. Link the object files (this is what i think your problem is) cc -o my_

Re: bison and C++

2006-12-13 Thread Hans Aberg
On 13 Dec 2006, at 11:33, Evan Lavelle wrote: Once upon the time, Bison had an informal support for the C-parser to be compiled as C++, but this was dropped, being too difficult to maintain. Instead, a separate C++ skeleton was developed. So, for C++, it is best to use the C++ skeleton file.

Re: bison and C++

2006-12-13 Thread Evan Lavelle
Hans Aberg wrote: Once upon the time, Bison had an informal support for the C-parser to be compiled as C++, but this was dropped, being too difficult to maintain. Instead, a separate C++ skeleton was developed. So, for C++, it is best to use the C++ skeleton file. I have a lot of C++ code i

Re: bison and C++

2006-12-12 Thread Hans Aberg
On 13 Dec 2006, at 01:11, Satya wrote: Putting the in the .y file would not suffice, as those functions need to be put in a file compiled by the C++ associated C-compiler; Well, when Bison generates an xyz.tab. c file, it can be compiled by a C++ compiler. Thats the idea. Once upon the time

Re: bison and C++

2006-12-12 Thread Satya
Putting the in the .y file would not suffice, as those functions need to be put in a file compiled by the C++ associated C-compiler; Well, when Bison generates an xyz.tab. c file, it can be compiled by a C++ compiler. Thats the idea. one cannot then use C++ containers. If the C-parser is comp

Re: bison and C++

2006-12-12 Thread Hans Aberg
On 13 Dec 2006, at 00:09, Satya wrote: No, you dont need to use the C++ skeleton. Just put an extern "C" declaration at the beggining of your parser file (.y file) e.g., extern "C" { int yyparse ( void ); int yylex ( void ); int yywrap (); void yyerror ( char* ); } Putting the

Re: bison and C++

2006-12-12 Thread Satya
No, you dont need to use the C++ skeleton. Just put an extern "C" declaration at the beggining of your parser file (.y file) e.g., extern "C" { int yyparse ( void ); int yylex ( void ); int yywrap (); void yyerror ( char* ); } satya. -- Work expands to fill the time available for

bison and C++

2006-12-12 Thread Michel Meynard
Hello i want to write a parser with bison using some containers from STL but i don't need an oriented objet parser : yyparse() is sufficient for me ! Have i to use skeleton and all the C++ stuff of bison manual ? -- Cordialement, Michel Meynard. Michel

flex+bison and C++, second part

2006-07-18 Thread pasquale minervini
I'm giving some more tries to generate a C++ parser for a small language, here it's the result: http://www.neuralnoise.com/small_backup_2/ it's hevily ripped off by the example calc++, and I really don't know why I can't get scanner.cc (the file generated from "flex -+ -o scanner.cc scanner.ll")

flex+bison and C++

2006-07-17 Thread pasquale minervini
Hi, I just made a small parser using flex and bison, to integrate it in a bigger project, and it works like a charm; here it is: http://www.neuralnoise.com/small_backup/ . I'm now having problems generating a C++ parser (I'm currently trying to do it using the bison's "-d -S lalr1.cc" and flex'