-
Notifications
You must be signed in to change notification settings - Fork 116
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] Including %type and %standalone produces uncompileable code [sf#93] #95
Comments
Commented by lsf37 on 2008-06-21 06:06 UTC The description is correct. I'm inclined to say it's a feature, though. %standalone scanners are supposed to have return type int, in fact they are not supposed to return anything, but be filters only. I should possibly make this a JFlex error message already and not let it occur at the compiler stage. Is it possible that you are looking for %debug instead? Cheers, |
Updated by lsf37 on 2008-06-21 06:06 UTC
|
Commented by mcspanky on 2008-06-21 13:58 UTC Yes, a better error message would be great. Basically I took one of the examples and was learning flex by modifying it various ways. You're right, %debug is probably what I should use. An error message would have saved me a lot of time and head scratching. Perhaps, when someone uses %standalone and another directive that's incompatible with it, the error message could suggest %debug? |
Commented by mcspanky on 2008-06-21 14:02 UTC By the way, the docs for %standalone say this: To avoid having to use an extra token class, the scanning method will be declared as having default type int, not YYtoken (if there isn't any other type explicitly specified). This is in most cases irrelevant, but could be useful to know when making another scanner standalone for some purpose. So, if you want to keep the ability to make another scanner standalone, you could have it return null instead of YYEOF. Either way is fine by me. |
Commented by lsf37 on 2009-01-31 07:16 UTC Cheers, |
Updated by lsf37 on 2009-01-31 07:16 UTC
|
Updated by lsf37 on 2009-01-31 13:12 UTC
|
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()); }
}
The text was updated successfully, but these errors were encountered: