Continue to learn yacc and flex, and run through a script that is not suitable for the instructions and manuals that I have. I am trying to parse a file, and as I go along, I do additional error checking in the code that I posted in my parser.y file. When I come across something that is lexicographically correct (i.e. Parsing matches correctly) but logically incorrect (unexpected value or inappropriate value), how do I get yyparse to exit? Also, can I return an error code to me, which I can check in my code code?
my_file_format: header body_lines footer ; header: OBRACE INT CBRACE | OBRACE STRING CBRACE { if ( strcmp ( $1, "Contrived_Example" ) != 0 ) { } } ;
I understand that in my example I can just search for “Contrived_Example” using the rule, but my point is in if -block - can I tell yyparse that I want to stop parsing here?
source share