[antlr-interest] related question: multiple grammars..

Gavin Lambert antlr at mirality.co.nz
Thu Mar 29 13:35:42 PDT 2007

At 02:42 30/03/2007, Eitan Suez wrote:
>here is an illustration of my problem and why i think
>whitespace significance plays a role:
>length returns [Length value]
>  : INT Unit
>  {
>    $value = new Length(Integer.parseInt($INT.text), $Unit.text);
>  }
>  ;
>i think by definition the tokens INT and Unit must be
>whitespace-separated.  so the rule does not match
>"4px".  it matches "4 px" which is not what i want.
>i believe that if whitespace was significant (not skipped
>or hidden) then the rule would work/match.

No, it shouldn't make a difference.  As long as your INT rule 
isn't too greedy it should be able to match an int immediately 
followed by something else (with the something else producing its 
own token).  Maybe you should post your INT and Unit rules.

(And incidentally, make sure you reply to the group, not just 
privately.  You'll get more responses that way.)

More information about the antlr-interest mailing list