[antlr-interest] newline in Antlr3

Ilia Kantor ilia at obnovlenie.ru
Fri Sep 1 00:56:34 PDT 2006


Ah. Works fine now =).

> You missed Ter's correction--the ~ phrase should be
> ~ ('{' | '}' )*
> to avoid eating the terminal '}' characters.
>
> --Loring
>
> Ilia Kantor <ilia at obnovlenie.ru> wrote:
> Ok, I removed brackedLevel in favour of stack, but it still doesn't work.
>
> ----------- output -----
> Line 1 pos 0 type 7: grammar
> Line 1 pos 7 type 10:
> Line 1 pos 8 type 7: a
> Line 1 pos 9 type 8: ;
> Line 1 pos 10 type 10:
>
> Line 2 pos 0 type 10:
>
> Line 3 pos 0 type 7: output
> Line 3 pos 6 type 10:
> Line 3 pos 7 type 7: ruleO
> Line 3 pos 12 type 10:
> [mTokens, mBLOCK, mBLOCK, mBLOCK]: line 8:0 mismatched char: '?' on line 8;
> expecting char '}'
>
> --------------------- target ----------
> grammar a;
>
> output ruleO { something
>  { bracketed }
> }
>
> rule ruleR { blabla }
>
> ---------------- grammar (3.0b4) -----------
>
> lexer grammar MainLexer;
>
> BLOCK : '{' (BLOCK | ~'{')* '}' ;
>
> ID : ( LETTER | '_' ) (NAMECHAR)* ;
>
> DC: ';';
>
> fragment NAMECHAR
>
>     : LETTER | DIGIT | '.' | '-' | '_' | ':'
>
>     ;
>
> fragment DIGIT
>
>     :    '0'..'9'
>
>     ;
>
> fragment LETTER
>
>     : 'a'..'z'
>     :
>     | 'A'..'Z'
>
>     ;
>
> WS  :
>        (' '|'\r'|'\t'|'\u000C'|'\n' ) {channel=99;}
>     ;
>
> > On Aug 31, 2006, at 3:08 PM, Ilia Kantor wrote:
> > > Hmmm indeed.. I just want ANY rule to read all nested brackets, like
> > > { ..{..}. }
> > >
> > > How you'd recommend to implement it ?
> >
> > HI.
> >
> > "Use the stack, Luke"
> >
> > BLOCK : '{' (BLOCK | ~'{')* '}' ;
> >
> > Ter
>
> ---------------------------------
> Do you Yahoo!?
>  Get on board. You're invited to try the new Yahoo! Mail.


More information about the antlr-interest mailing list