[antlr-interest] newbie: help grammar trips on dual use period

Sriram Durbha cintyram at yahoo.com
Thu Nov 14 09:39:14 PST 2002


 protected  DIGIT :	'0'..'9' ;
 protected EXPONENT :   ( ('e'|'d')('+'|'-')?(DIGIT)+ )   ;
 protected INT            :	(DIGIT) +    ;  /// match the integral part
 123
 protected FLOATING  :   ( '.'  (DIGIT)+ ) ;
 
 NUM   : INT ( FLOATING  ) ? (EXPONENT ) ?     ;      
 
 ID  options { testLiterals=true; }     : ('a'..'z' |
'A'..'Z'|'_')('a'..'z' | 'A'..'Z'|'_'|DIGIT)*   ;

protected DOT : '.' ;
// (interface):(base_object).(sub_object)*.(variable) = (value)
rule : ID COLON ID ( ( DOT ID) + ) ? DOT ID ASSIGN NUM ;

this might give you an idea. but looking at example grammars is very
helpful, so u might want to see those also;
HTH
cheers
ram

--- DogbertKarma <gossman at free-source.com> wrote:
> All,
> I'm thinking this should be easy to do, unluckily I'm new enough at
> antlr that I'm missing something and I'm hoping that with a little
> push from you'all that I can solve this. 
> 
> I've got a grammar (not allowed to change it) of the form:
> 
> (interface):(base_object).(sub_object)*.(variable) = (value)
> 
> so a file of these would look like:
> 
> // example comment
> ethernet:dog.tail = true
> serial:cat.collar.tag = 123.6
> ethernet:dog.snout = 12
> // another example comment
> 
> I keep hanging up on the fact that the (.) period is dual use. It is
> both a delimiter and part of the value when the value is a floating
> point number.
> 
> Thanks,
> Matt
> 
> 
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/ 
> 
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

 

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



More information about the antlr-interest mailing list