jFlex error: class throws java.io.IOException
Asked Answered
W

2

7

I have written a very simple file with specification shown below to to tokenize words:

%%
%class Lexer
%unicode

WORD = [^\r\n\t ]

%%
{WORD}  {System.out.println("Word is:"+yytext());}

.       {System.out.println("Bad character: "+ yytext());}

The following are the commands I run:

jflex hindi.jlex
javac Lexer.java

I get the following error:

Lexer.java:442: cannot find symbol
symbol  : class Yytoken
location: class Lexer
  public Yytoken yylex() throws java.io.IOException {
     ^
1 error

Any help appreciated.

On a additional note I checked the Lexer.java file and there was no main function in it. Is that the reason for this error.

Window answered 2/4, 2013 at 20:8 Comment(1)
I removed the antlr tag, since I fail to see how it is related to ANTLR.Ramayana
W
5

If you want to check the lexer standalone(without a parser) then add the following to the user code section:

%standalone
Window answered 2/4, 2013 at 21:36 Comment(0)
W
1

Those working with byaccj and getting this error should add a %byaccj line instead of %standalone below the %class Lexer line

Wretch answered 1/4, 2015 at 13:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.