I'm trying to write a native Node.js parser using Flex/Bison. There are three parts to the addon: the lexer, the parser, and the node/v8 interface. The lexer and the parser were working well in the beginning (I used g++ to compile the lexer/parser and included the necessary lexer functions like this: http://tldp.org/HOWTO/Lex-YACC-HOWTO-5.html). When I added the node/v8 section into the mix, I ended up getting a missing symbol error for a function defined in the lexer code.
Here's an overview of the file structure:
File A: Lexer file, automatically generated by flex from the lexer rules I wrote.
File B: The parser file, includes the extern "C" { [lexer functions] } and
a function called parse(std::string). parse() calls some yy_functions,
which are defined in the lexer, and returns a c++ data structure
representing the parsed data.
File C: This is the node/v8 part. There is a header file with the prototype for
B's parse() function. When JS calls a certain function, the data is
converted to a c++ string and passed to the parse() function in File B.
When I run a simple test to parse a JS string, I get an error saying
node: symbol lookup error: /home/monty/projects/flex_bison/GetObj_Request_Parser/build/default/GetObjParser.node: undefined symbol: yy_scan_string
Note: I'm using node-waf to build the addon and I've renamed the files generated by flex and bison from [FILE].c to [FILE].cc so that the build script picks them up.
If you would like to see some code, you can find it all here: https://github.com/IDX-io/GetObj_Request_Parser (look in the src/buildstuffs dir).
File A = src/buildstuffs/lex.yy.c[c]
File B = src/buildstuffs/geto.tab.c[c]
File C = src/buildstuffs/GetObjParser.cc
Test = test.js
Thanks!
[EDIT] Instead of using two different compilers and messing around with the node-waf build script (my solution), one could probably use flex++ and bison++ to generate C++.
Makefile
missing from your git tree? – sarnold[flex]
tag goes to the much newer project, by all rights it ought to be[adobeflex]
:) but thanks for retagging, the overlap bugged me to no end. – sarnold