How to raise an error

2009-10-09 Thread BradDaBug
My parser basically works by calling various functions that build a big parse tree. Something like this: identifier: LOCALIDENTIFIER { $$ = CreateIdentifierNode(yytext); } The problem is that I need to be able to detect errors within those functions (for example, is the identifier name too lo

Re: How to raise an error

2009-10-09 Thread Mike Aubury
Why not something like : identifier: LOCALIDENTIFIER { $$ = CreateIdentifierNode(yytext); if ($$== NULL) { YYERROR; } } Then just get your CreateIdentifierNode to return NULL if its invalid.. (You can play with setting an e

Re: How to raise an error

2009-10-09 Thread Luca
CreateIdentifierNode function can return a pointer to a struct (typically a pointer to a node). You can set the error in a field inside the node; you have also to increase an error counter (increase the same variable inside yyerror). Then you can parse the remaining input, for example: exp: