Does lexer fail under Java 8?

79 views
Skip to first unread message

Cliff Berg

unread,
Jun 1, 2015, 10:34:23 PM6/1/15
to sab...@googlegroups.com
I have used Sable for many years without any difficulty. But recently I used it to create a parser and discovered that the lexer returns token values that have a trailing space appended to them. E.g., if I am parsing
"IF A == 2"
the lexer will return
"IF "
(space following "IF") instead of just "IF". I don't know why this would be, and the only thing I am doing differently is that I am using Java 8 now, so I wonder if anyone has had any problems using Java 8 with Sable.

Etienne Gagnon

unread,
Jun 1, 2015, 10:42:08 PM6/1/15
to sab...@googlegroups.com
Hi Cliff,

This usually happens when the toString() method is used in place of the getText() method. The toString() method is meant for debugging; it appends a space so that one can easily convert the AST into a string (e.g. System.out.println(node); ).

Did you use the getText() method?

Etienne
Etienne Gagnon, Ph.D.
http://sablecc.org
Reply all
Reply to author
Forward
0 new messages