[antlr-interest] "unexpected token" error
togol machillan
togolmach2 at lycos.com
Wed Mar 9 03:02:49 PST 2005
Hi,
The lexer grammar has the following main rules. I think the problem is only to the ASSIGNMENT rule or the rules it depends on, because the program works fine if I comment it out.
VALUE options {testLiterals = true; }
: CAPITAL_LETTER (CAPITAL_LETTER|DIGIT|','|'-')*
;
FIGURE: ('-')? ((DIGIT)+ '.' (DIGIT)* | '.'(DIGIT)+ );
ASSIGNMENT: VALUE '=' (VALUE|FIGURE)
;
protected
DIGIT: '0'..'9';
protected
CAPITAL_LETTER: 'A'..'Z';
protected
SMALL_LETTER: 'a'..'z';
Some input files and the corresponding error messages generated are as follows.
Input file:
FLOWSHEET
BLOCK B1 IN=1 2 OUT=3
Output error message:
<cin>:1:11: unexpected token:
Input file:
DATABANKS PURE12 / AQUEOUS / SOLIDS / INORGANIC / &
NOASPENPCD
Output error message:
<cin>:1:19: unexpected token: /
I really appreciate your will to help. Thanks.
T. Mach
----- Original Message -----
From: "Monty Zukowski" <monty at codetransform.com>
To: "ANTLR Interest" <antlr-interest at antlr.org>
Subject: Re: [antlr-interest] "unexpected token" error
Date: Tue, 08 Mar 2005 12:35:48 -0500
>
> togol machillan wrote:
> > Hi,
> >
> > The whitespace and the newline rules are as follows.
> >
> > NEWLINE : ('\r''\n')=> '\r''\n' //DOS
> > | '\r' //MAC
> > | '\n' //UNIX
> > { newline(); }
> > ;
> >
> > WS : (' '|'\t'|'\f') { _ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP; } ;
> >
> > Regards,
> >
> > Mach
> > ----- Original Message -----
> > From: "Monty Zukowski" <monty at codetransform.com>
> > To: antlr-interest at antlr.org
> > Subject: Re: [antlr-interest] "unexpected token" error
> > Date: Tue, 08 Mar 2005 10:03:28 -0500
> >
> >
> >> togol machillan wrote:
> >>
> >>> Hi,
> >>>
> >>> Another newbie question. I hope somebody can help me out here.
> >>>
> >>> I have the following lexer rules (omitting some which are clear by name)
> >>>
> >>> VALUE options {testLiterals = true; }
> >>> : CAPITAL_LETTER (CAPITAL_LETTER|DIGIT|','|'-')*
> >>> ;
> >>>
> >>> FIGURE: ('-')? ((DIGIT)+ '.' (DIGIT)* | '.'(DIGIT)+ );
> >>>
> >>> ASSIGNMENT: VALUE '=' (VALUE|FIGURE)
> >>> ;
> >>>
> >>> I want the ASSIGNMENT rule to match a token like MOLE-FRAC=1.0
> >>> or STOIC=IN, for example. But when I include this rule, the
> >>> program throws the unexpected token: error at the point where
> >>> first space character occurs in the input file. Is this due to
> >>> some problem with the greedy nature of the the VALUE rule?
> >>> Thanks in advance.
> >>>
> >>> Regards,
> >>>
> >>> Togol Mach
> >>
> >> What does your whitespace rule look like?
> >>
> >> Monty
> >
> >
>
> It's still not enough information to diagnose. Best thing is the
> minimal grammar & input to reproduce, plus the actual error message.
>
> Monty
--
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at once.
http://datingsearch.lycos.com
More information about the antlr-interest
mailing list