[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debug Lexer [Was: ParserException: [1,1] expecting: EOF]




Hi,

I tried using the debugger you sent. But at the
", text : [" + token.getText() + "]");

portion, I get a java null pointer error.

The string I am passing is

String _expression_="//users[login/text()='" + login + "' and password/text()='" + password + "']/id/text() ";
Can it support this type of string?




----- Original Message ----
From: Etienne M. Gagnon <egagnon@xxxxxxxxx>
To: Discussion mailing list for the SableCC project <sablecc-discussion@xxxxxxxxxxxxxxxxx>
Sent: Sunday, August 3, 2008 4:38:04 PM
Subject: Debug Lexer [Was: ParserException: [1,1] expecting: EOF]

Hi Lola,

You should first make sure that your lexer behaves as you expect it to do. Often, errors in the lexer specification lead to syntax errors. Try a custom debug lexer such as:
class PrintLexer extends Lexer
{
PrintLexer(PushbackReader reader)
{
super(reader);
}

protected void filter()
{
System.out.println(token.getClass() +
", state : " + state.id() +
", text : [" + token.getText() + "]");
}
}

Have fun!

Etienne

Lola Oluyomi a écrit :
Thanks. It works for me as well from command prompt. i.e the parser and other files are generated.

However, when I try to parse an _expression_  (from netbeans or command prompt), I get the error:
[...]

-- 
Etienne M. Gagnon, Ph.D.
SableCC: http://sablecc.org
SableVM: http://sablevm.org