From: Nikos B. <nba...@gm...> - 2014-02-27 19:49:14
|
Hi, I have the following flex piece of code: %x PLAYBACK IDIR TABLES SKIPLN HEX <PLAYBACK>{ ^Tuner\ set\ to\ [^\n]+ { BEGIN(HEX); yy_push_state(SKIPLN); } [^\n]+ | \n {} } <IDIR>{ {path} { memcpy(indexDir, yytext, yyleng); if (indexDir[yyleng - 1] != '/') { indexDir[yyleng] = '/'; indexDir[yyleng + 1] = '\0'; } else indexDir[yyleng] = '\0'; } .{6} { fprintf(stderr, "Error: loadConfig ~> Illegal text \"%s\" in group " "\"rainbow\" of \"sdmp.conf\" (line:%d)\n", yytext, lineno); yyterminate(); do_exit(13); } \n { lineno++; yy_push_state(TABLES); } } I am calling it from my C Program: A) BEGIN(IDIR); yylex(); At a different part I call: B) BEGIN(PLAYBACK); yylex(); My problem is that in (A), if it gets the Error in <IDIR> instead of exiting flex du to yyterminate(), it just jumps to <PLAYBACK> and continues scanning the wrong rules. <PLAYBACK> is nowhere in the rulepath of <IDIR>. How can I keep those 2 ruletrees separate and when I use yyterminate() have yylex() exit? TIA, Nikos |