New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] State minimizer ignores EOF actions [sf#80] #82

Closed
lsf37 opened this Issue Feb 15, 2015 · 6 comments

Comments

Projects
None yet
1 participant
@lsf37
Member

lsf37 commented Feb 15, 2015

Reported by arhawth on 2006-08-14 21:27 UTC
If two states only differ by the action for the EOF
rule, they are minimized to the same state, and JFlex
emits a warning:

Warning : Lexical states <STATE1> and <STATE2> are
equivalent.

Here is a sample scanner definition that emits the warning:

%%
%{
public static final int WORD = 1;
public static final int WS = 2;
public static final int EOF1 = 3;
public static final int EOF2 = 4;
%}

%unicode

%xstate STATE2

WORD=[a-zA-Z]+
WS=[ \t\n\r]+

%%

<YYINITIAL,STATE2>
{
{WORD}
{
yybegin(STATE2);
return WORD;
}

{WS}
{
yybegin(YYINITIAL);
return WS;
}
}

<YYINITIAL>
{
<<EOF>>
{
return EOF1;
}
}

<STATE2>
{
<<EOF>>
{
return EOF2;
}
}

Here is one where the states are the same except for
the actions in a non-EOF rule. The output does not
emit the warning:

%%
%{
public static final int WORD1 = 1;
public static final int WORD2 = 2;
public static final int WS = 3;
public static final int EOF = 4;
%}

%unicode

%xstate STATE2

WORD=[a-zA-Z]+
WS=[ \t\n\r]+

%%

<YYINITIAL,STATE2>
{
{WS}
{
return WS;
}

<<EOF>>
{
return EOF;
}
}

<YYINITIAL>
{
{WORD}
{
yybegin(STATE2);
return WORD1;
}
}

<STATE2>
{
{WORD}
{
yybegin(YYINITIAL);
return WORD2;
}
}

@lsf37 lsf37 changed the title from State minimizer ignores EOF actions to [Bug] State minimizer ignores EOF actions [sf#80] Feb 15, 2015

@lsf37 lsf37 added this to the jflex bug milestone Feb 15, 2015

@lsf37 lsf37 closed this Feb 15, 2015

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Commented by lsf37 on 2007-11-03 11:07 UTC
Logged In: YES
user_id=93534
Originator: NO

This is an interesting one. The bug is actually not really in the minimisation, but in the code emitter (which makes the wrong assumption that was mentioned: just because they point to the same DFA states, two lex states are not necessarily the same, because they can be distinguished by EOF actions).

Fixed in svn revision 267.

Member

lsf37 commented Feb 15, 2015

Commented by lsf37 on 2007-11-03 11:07 UTC
Logged In: YES
user_id=93534
Originator: NO

This is an interesting one. The bug is actually not really in the minimisation, but in the code emitter (which makes the wrong assumption that was mentioned: just because they point to the same DFA states, two lex states are not necessarily the same, because they can be distinguished by EOF actions).

Fixed in svn revision 267.

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Updated by lsf37 on 2007-11-03 11:07 UTC

  • milestone: --> jflex bug
  • status: open --> open-fixed
Member

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2007-11-03 11:07 UTC

  • milestone: --> jflex bug
  • status: open --> open-fixed
@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Updated by lsf37 on 2008-05-27 11:46 UTC

  • status: open-fixed --> closed
Member

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2008-05-27 11:46 UTC

  • status: open-fixed --> closed
@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Commented by lsf37 on 2007-11-03 11:07 UTC
Logged In: YES
user_id=93534
Originator: NO

This is an interesting one. The bug is actually not really in the minimisation, but in the code emitter (which makes the wrong assumption that was mentioned: just because they point to the same DFA states, two lex states are not necessarily the same, because they can be distinguished by EOF actions).

Fixed in svn revision 267.

Member

lsf37 commented Feb 15, 2015

Commented by lsf37 on 2007-11-03 11:07 UTC
Logged In: YES
user_id=93534
Originator: NO

This is an interesting one. The bug is actually not really in the minimisation, but in the code emitter (which makes the wrong assumption that was mentioned: just because they point to the same DFA states, two lex states are not necessarily the same, because they can be distinguished by EOF actions).

Fixed in svn revision 267.

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Updated by lsf37 on 2007-11-03 11:07 UTC

  • milestone: --> jflex bug
  • status: open --> open-fixed
Member

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2007-11-03 11:07 UTC

  • milestone: --> jflex bug
  • status: open --> open-fixed
@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Updated by lsf37 on 2008-05-27 11:46 UTC

  • status: open-fixed --> closed
Member

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2008-05-27 11:46 UTC

  • status: open-fixed --> closed

@lsf37 lsf37 added the bug label Feb 17, 2015

@lsf37 lsf37 modified the milestone: jflex bug Feb 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment