I've got a working flex/bison parser that I would like to run from an exe file. However, I can't find the knowledge to achieve that.

Do I need to create a C file, with an exec function to call the files? If so, what files do I call in the exec? Anyone knows how to do something like that?

I really need a hint for this one!


7 Years
Discussion Span
Last Post by fantasma

flex and bison generate C code from their respective sources (.l and .y). You have to compile them and link resulting objects with the rest of your application. At some point the application calls yyparse() (which is the entry point to the parser).

If you have more specific question, please elaborate.


I have those files. something.l and something.y and I need to create an exe in order to, in a JAVA application do something like "cmd executable.exe" < "filetobeparsed" + "parsedfile.xml"

How to make that exe is my question, since I don't have a clue in how to do it


At the command prompt, typing flex something.l gives you lex.yy.c file. Similarly, bison something.y generates yy.tab.c and yy.tab.h files. You may or may not write another C file with main() calling yyparse - inspect something.y for a presence of suitable main(). Assuming it is already there (and assuming gcc as a compiler), type

gcc -o executable yy.tab.c lex.yy.c

. How to integrate it into Java, I have less clue than you.

PS: of course, you need flex and bison executables.

Edited by nezachem: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.