[antlr-interest] unexpected token:
Alexey Demakov
demakov at ispras.ru
Thu Oct 21 00:57:50 PDT 2004
> I'd like to simple, but nested list like
> {{0 1 2}{3 4 5}{6 7 8}} into nested java list.
>
> The main work is done something like this in the lexer
> OPENBRACE: ('{')
> {
> // add a new list to the stack to be filled by later
> // Integer, Real, Boolean and Null calls
> List currentList = new ArrayList();
> stack.push( currentList );
> } ;
> CLOSEBRACE: ('}')
> {
> // add the contents of the current list to the previous one
> // in case stack.size() > 1
> if ( stack.size() > 1 ) {
> Object currentList = stack.pop();
> List previousList = (List) stack.peek();
> previousList.add( currentList );
> }
> } ;
>
> and works pretty well. The parser looks like this:
>
> simpleList :
> OPENBRACE ( INTEGER | REAL | BOOLEAN | NULL | SPACE )+ CLOSEBRACE
> {
> //InlineList.parserLog.info("found simpleList " );
> } ;
> nestedList :
> OPENBRACE ( simpleList | SPACE )+ CLOSEBRACE
> {
> InlineList.parserLog.info("found nestedList " );
> } ;
>
> inlineList :
> ( nestedList | simpleList )+
> {
> //InlineList.parserLog.debug("found inlineList " );
> } ;
>
> Everything works as expected, but I get an additional warning
> line 1:2: unexpected token: 0
> parsing the strings, in this case {0 1 2 3 null}.
>
> How could I get rid off this warning ?
>
> Thanks, Carsten
May be the problem is in definition of INTEGER or REAL tokens?
Regards,
Alexey
-----
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list