-   Programming (
-   -   Do flex and bison support C++? (

ankit4u1 05-21-2006 08:38 AM

Do flex and bison support C++?
I want to write my action for rules and grammar in lex and yacc in c++. But I am not sure, whether flex and bison supports this. In case it does not support, what do i need to do, if i want to write my actions in c++ and C code. Do i need to change the source code in lex and yacc or just the the way and procedure of compilation like suppose i need to use flex++ instead of flex, do i need to just write flex++ during compilation instead of flex or do i need to change the coding in source files also(lex and yacc) ?

I read from man pages that there's flex++ also available for c++. But din't understand much as there was not much information given about that. So, I have posted this thread here.

I am using fedora core 2. So what should i do?

Hope to get a reply from you soon. Thank you.

Ankit Parikh:Pengy:

jim mcnamara 05-22-2006 06:18 AM


ankit4u1 05-23-2006 01:52 PM

thanks for the info..i'll try according to the info given on the webpage...

ankit4u1 05-24-2006 01:43 PM

I welcome more suggestions, because i read that for lex only C code can be used in action while in yacc, C++ can be used. And i am using flex not lex.

Also I want to use only C++ , as I am using STL (standard template library). So hope to get help regarding this.

Thank you.

jim mcnamara 05-24-2006 01:57 PM

flex++ accepts C++ code.

Try info flex++

ankit4u1 05-24-2006 02:26 PM

ok. so i just need to write flex++ while compilation right?
I'll try that. Thanks for the info.

friendship7 05-16-2008 12:17 PM

Hi all,

A little bit late reply, but I just discovered flex and bison a couple of months ago, and I am now in the way of my 2nd assembler with flex and bison. For me these tools are great.

Have a look here for flex and bison c++ support:


bozziebear 08-08-2011 05:56 PM

flex++ and bison++ support writing actions in c++ and also support encapsulating the parser and scanner within a class definition.

I believe Ubuntu offers flex++ and bison++ packages. For other distributions and also for flex++/bison++ code examples, download here:

All times are GMT -5. The time now is 01:42 PM.