Reported by mcspanky on 2008-06-21 04:15 UTC
If you include both a %type and a %standalone, the resulting scanner has the specified return type, yet at EOF returns the int YYEOF. javac rightly complains about that and refuses to compile the file.
Here's the file I used; it could be stripped down more:
package foo;
%%
%public
%class Scanner
%standalone
%function nextToken
%type Foo
%line
%column
/* main character classes */
LineTerminator = \r|\n|\r\n
WhiteSpace = [ \t\f]
/* identifiers /
Identifier = [:jletter:][:jletterdigit:]
%%
<YYINITIAL> {
/* keywords */
"double" { System.out.println(yytext()); }
"int" { System.out.println(yytext()); }
/* end of line */
{LineTerminator} { System.out.println("LINE TERMINATOR"); }
/* whitespace /
{WhiteSpace} { / ignore */ }
/* identifiers */
{Identifier} { System.out.println("identifier: "+ yytext()); }
}
Reported by mcspanky on 2008-06-21 04:15 UTC
If you include both a %type and a %standalone, the resulting scanner has the specified return type, yet at EOF returns the int YYEOF. javac rightly complains about that and refuses to compile the file.
Here's the file I used; it could be stripped down more:
package foo;
%%
%public
%class Scanner
%standalone
%function nextToken
%type Foo
%line
%column
/* main character classes */
LineTerminator = \r|\n|\r\n
WhiteSpace = [ \t\f]
/* identifiers /
Identifier = [:jletter:][:jletterdigit:]
%%
<YYINITIAL> {
/* keywords */
"double" { System.out.println(yytext()); }
"int" { System.out.println(yytext()); }
/* end of line */
{LineTerminator} { System.out.println("LINE TERMINATOR"); }
/* whitespace /
{WhiteSpace} { / ignore */ }
/* identifiers */
{Identifier} { System.out.println("identifier: "+ yytext()); }
}