[Flex-devel] [PATCH] Continued Actions and <<EOF>>
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Michael W. <mfw...@MI...> - 2008-02-17 10:35:39
|
Hello, Consider the following, in which the special continued action symbol '|' refers to the action of an <<EOF>>: pattern | <<EOF>> { /* some action */ } Unfortunately, this produces a buggy scanner, because an <<EOF>> action's case block doesn't begin with a "YY_RULE_SETUP", so that any regular rule that drops into that case block will not be properly initialized. I have provided a patch that simply modifies build_eof_action() in parse.y to check whether a YY_RULE_SETUP should be emitted for the previous rule (before the <<EOF>> case statement). The patch can be accessed in 2 ways: (1) The attachment (3) https://sourceforge.net/tracker/download.php?group_id=97492&atid=618179&file_id=266698&aid=1895336 There is also an inlined version below, but the mailer renders it useless unless you fill in the removed whitespace-only lines by hand. Please give your comments. Sincerely, Michael Witten Index: parse.y =================================================================== RCS file: /cvsroot/flex/flex/parse.y,v retrieving revision 2.50 diff -u -8 -p -r2.50 parse.y --- parse.y 15 Feb 2008 12:37:35 -0000 2.50 +++ parse.y 17 Feb 2008 10:06:16 -0000 @@ -963,16 +963,20 @@ void build_eof_action() if ( sceof[scon_stk[i]] ) format_pinpoint_message( "multiple <<EOF>> rules for start condition %s", scname[scon_stk[i]] ); else { sceof[scon_stk[i]] = true; + + if (previous_continued_action /* && previous action was regular */) + add_action("YY_RULE_SETUP\n"); + snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n", scname[scon_stk[i]] ); add_action( action_text ); } } line_directive_out( (FILE *) 0, 1 ); |