> Hi!
>
> I cant figure out why this grammar dont work (I have left out some  
> not relevant stuff).
> This expression works:    [ LOOKUP( A1234567890, 9TN ) ] 93
> This dont:    [ LOOKUP( A1234567890, ATN ) ] 93
> Why?
>
>
>
> prog          returns [NationalDutyExprHelper value] :
>       item (item)* {$value = h;}
>       ;
>
> item          returns [NationalDutyExprHelper value] :
>       '[' expr ']' DUTYEXPR
>       { h.add(".'").add($DUTYEXPR.text + "'").add(">AMOUNT"); $value = h;}
>       ;
>
> expr
>       @init { String s = null; }
>       :
>       multExpr (('+' {s = "+";} | '-'  {s = "-";} | PERCENT  {s = "* 0.01  
> *";}) multExpr { h.add(s);} )*
>       ;
>       
> multExpr
>       @init { String s = null; }
>       :
>       atom ( ('*' {s = "*";} | '/' {s = "/";} ) atom { h.add(s);} )*
>       ;
> lookup
>       :
>       lu='LOOKUP' '(' TABLEID ',' expr ')'
>       { h.addReference(ExtReference.Type.FUNCCALL,  
> $lu.text).addLiteral($TABLEID.text).add($lu.text); }
>       ;
>       
> funcCall
>       :
>       EXTREF '(' expr (',' expr)* ')'
>       { h.addReference(ExtReference.Type.FUNCCALL,  
> $EXTREF.text).add($EXTREF.text); }
>       ;
>       
> parenExpr
>       :       
>       '(' expr ')'
>       ;
>
> oneOfMeas
>       :
>       'ONE_OF(' me=MEAS
>       { h.addReference(ExtReference.Type.MEAS,  
> $me.text).addLiteral($me.text); }
>       (',' me=MEAS { h.addReference(ExtReference.Type.MEAS,  
> $me.text).addLiteral($me.text); } )*
>       ')'
>       { h.add("MEASURE>"); }
>       ;
>
> variable
>       :
>       VARIABLE
>       { h.addReference(ExtReference.Type.VAR,  
> $VARIABLE.text).add($VARIABLE.text); }
> ;
>
> measure
>       :
>       me=MEAS!
>       { h.addReference(ExtReference.Type.MEAS, $me.text).add($me.text); }
> ;
>       
> atom  
>       :
>       meu=UNITQ       
>       { h.addReference(ExtReference.Type.MEAS_UNIT,  
> $meu.text).add($meu.text); }
>       |
>       meu=UNIT        
>       { h.addReference(ExtReference.Type.MEAS_UNIT,  
> $meu.text).add($meu.text); }
>       |
>       n=NUMBER { h.add($n.text); }
>       |
>       lookup
>       |
>       funcCall
>       |
>       variable
>       |
>       oneOfMeas
>       |
>       measure
>       |
>       parenExpr
> ;     
>
>
>       
> VARIABLE:     '$' UCLETTER (ALPHANUM|USCORE)* ;       
> EXTREF:               '@' UCLETTER (ALPHANUM|USCORE)* ;       
> DUTYEXPR:     DIGIT DIGIT;
> ID:   LCLETTER (LCLETTER | DIGIT)+ ;
> MEAS:         '&' ALPHANUM ALPHANUM ALPHANUM ALPHANUM;        
> TABLEID       :       UCLETTER (ALPHANUM)* ;
> WS  :   (' '|'\t')+ {skip();} ;
> fragment DIGIT:               '0'..'9';
> fragment UCLETTER:    'A'..'Z';
> fragment LCLETTER:    'a'..'z';
> fragment USCORE:      '_';
> fragment CHAR:        UCLETTER | LCLETTER | DIGIT;
> fragment ALPHANUM:    DIGIT | UCLETTER;
> UNIT  : ALPHANUM ALPHANUM ALPHANUM
>       ;
> UNITQ : ALPHANUM ALPHANUM ALPHANUM '#' ALPHANUM
>       ;
> PERCENT:      '%' (' ')* 'OF';        
> NUMBER        :       DIGIT+ '.' (DIGIT)* ;
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to