dcsimg
Seeking very simple error handling example when generating C code
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Graham_Keellings
Posted On:   Thursday, December 31, 2009 01:48 AM

I want to generate C code. I will not be reading from an input file, one line at a time *as, for instance, a compiler might). Rather, I will be parsing user input as it arrives, one line at a time. I would prefer to detect and handle bad input in the lexer/parser, e.g /* lexer tokens */ foo : "FOO"; bar: "BAR"; baz: "BAZ"; /* grammar*/ grammar: foo "=" BAZ | foo "=" BAR | : {printf(stderr, "bad input ");} OK, if I can't catch it in the lexer/parser, it seems like I need to use displayRecognitionError() but how?? Can anyone point me at a very simple   More>>

I want to generate C code. I will not be reading from an input file, one line at a time *as, for instance, a compiler might). Rather, I will be parsing user input as it arrives, one line at a time.



I would prefer to detect and handle bad input in the lexer/parser, e.g

			

/* lexer tokens */
foo : "FOO";
bar: "BAR";
baz: "BAZ";
/* grammar*/
grammar: foo "=" BAZ |
foo "=" BAR |
: {printf(stderr, "bad input
");}




OK, if I can't catch it in the lexer/parser, it seems like I need to use displayRecognitionError() but how??



Can anyone point me at a very simple example which generates C code and shows some error handling of invalid input?



Thanks!    <<Less
About | Sitemap | Contact