[antlr-interest] Problem with Self 4.1 grammar

Jim Idle jimi at temporal-wave.com
Mon Mar 24 01:23:41 PDT 2008


Carter Cheng wrote:

Your real needs to add the empty alt:

Real
    : Decimal
       (
           ('.' Decimal)=> '.' Decimal (('e'|'E') ('+'|'-') Decimal)?
           | // Just an integer { $type = Integer; }
       )
    ;

Dot  : '.' ;


> Hello again,
>
> I am currently building a self 4.1 grammar which so far seems to work reasonably well for certain specific files but I came across a problem in the grammar which I am not sure how to resolve. The problem is that Self like Smalltalk uses '.' as a statement separator and there appears to be some conflict in the case:
>
> [ x == 1. ]    
>
> Where it seems unable to determine that 1 is an int obviously adding white space 
>
> [ x == 1 . ] 
>
> works. I assume this is some sort of lexing problem but the only rule I have which may conflict is:
>
> Real
> 	: Decimal ( ('.' Decimal) => '.' Decimal ) ( ('e'|'E') ('+'|'-') Decimal )?
> 	;
>
> with Integer and Decimal defined as:
>
> Integer
> 	: Decimal
> 	| Base GeneralDigit+
> 	;
>
> Decimal
>         : Digit+
>         ;
>
> Thanks in advance,
>
> Carter.
>
> Is there some way to peek into the token stream to see what the lexer is doing? It seems like the lexing problems given some of the operator ambiguities in Self are causing most of my problems. 
>
>
>       ____________________________________________________________________________________
> Looking for last minute shopping deals?  
> Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>   



More information about the antlr-interest mailing list