|
I have the same question as szabgab posted years ago. No one responded to his post ... Hope I have better luck here.
I'm using RecDescent to parse a C-like language(a small subset of C: not pointer, only integer type, no struct, no #include, etc.). With some experience with lex/yacc/yacc++, I got the grammar correctly working in relatively short time. But I cannot figure out how to implement syntax error reporting and recovery. Especially tricky is to report syntax error in optional items (e.g. c_statement(s?)). I managed to get it working using <commit> and <error?>, and <resync> in a very small test case, but I find my approach not scalable to larger grammar. Most examples found on-line are using <error> in the top-most rule. Not sufficient for a C-like language. Want to know:
* Any example of error handling in a larger/deeper grammar out there?
* Maybe RecDescent is not intended for implementing C-like compiler?
* If I'm not using the right tool, any recommentation of another CPAN package for my purpose?
Thanks!!!
Wilson
|