parsing - how to check an ANTLR token is only used once or less in the parser -
In Anther, if I have a rule for example:
Some rules: Token token;
This will accept: "Token tokenb"
If I want to tip to be optional, then I can say,
SomeRule: Tokna * Tokenb .;
Then I could: "Tokna Tokenb" or "Tokenb" or "Tokna Tokai Token"
But this also means that it is repeated once again can go. Anyway, I can say that this token can be 1 or less but not more than one? Therefore it will accept:
"Token tokenb" or "tokenb" but "token token token"?
Many thanks
... anyway I can say Can this token be 1 or less but not more than one? ...
Here's how:
Some rules: Token? Tokenb;
Or:
Some rules: Token Tokenb. Tokenb;
Comments
Post a Comment