[antlr-interest] AntLR Bug

Ric Klaren klaren at cs.utwente.nl
Tue Feb 5 07:43:07 PST 2002


Hi,

On Tue, Feb 05, 2002 at 08:33:44AM +0800, Michael Labhard wrote:
> This is the simplified example that fails to work with AntLR.  I don't see
> any additional opportunity for left-factoring here.
>
> class L extends Lexer;
> options { k=2; }
>
> NAME_TOKEN
>   : GRAPHIC_TOKEN
>   ;
>
> END_TOKEN
>     :
>     END_CHAR
>     ( options {greedy=true;} :
>      GRAPHIC_TOKEN_CHAR {setType(GRAPHIC_TOKEN);}
>     )+
>     ;

> protected GRAPHIC_CHAR
>   : ( options {greedy=true;} : '#'|'$'|'&'|'*'|'+'|'/'|
>     |':'|'<'|'='|'>'|'?'|'@'|'^'|'~');

Note btw that you have an emtpy alternative here.... '|' at end of line and
start of the next line...

Don't you mean something like:

class L extends Lexer;
options { k=2; }
tokens { END_TOKEN; NAME_TOKEN; }

TOKEN: { setType(END_TOKEN); } "."
	( {setType(NAME_TOKEN);} GRAPHIC_CHARS )?
;

protected
GRAPHIC_CHARS:
 ( '#'|'$'|'&'|'*'|'+'|'/'|':'|'<'|'='|'>'|'?'|'@'|'^'|'~' )+
;

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 Why don't we just invite them to dinner and massacre them all when they're
  drunk? You heard the man. There's seven hundred thousand of them. Ah? ..
           So it'd have to be something simple with pasta, then.
                 From: Interesting Times by Terry Pratchet


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list