|Perl: the Markov chain saw|
In search of grammars for parsingby coppit (Beadle)
|on Aug 06, 2004 at 00:49 UTC||Need Help??|
coppit has asked for the
wisdom of the Perl Monks concerning the following question:
I'm writing a code generator that needs to parse a YACC-like input file (including partially parsing the C/C++ parts of the head and tail sections), as well as a LEX-like input file.
I figured I would start with existing YACC and LEX grammars, and modify them to add my new features. Unfortunately, I'm having trouble finding suitable Perl tools for parsing YACC, LEX, C, and C++. (I know the latter two are hard--I only need a partial parsing.) Do anyone know where I can find grammars for these languages?
Here's what my research has uncovered:
Parsing a YACC file
I need to fully parse the YACC and LEX input files, but for the C and C++ code I just need to locate any definitions so that I can move them to an implementation file and replace them with "extern" declarations. (I'm generating multiple source files from the YACC/LEX files, instead of the normal one big implementation file.)
Thanks for the help!