Reputation: 31
I am in the process of learning how to program a compiler through antlr. I looked around a bit to get some knowledge about it, so I ended up on this.
What I want to ask is that, what are each symbols doing? The '?', '+' and '*' in the expression, what are they doing?
FLOAT
: [0-9]+ '.' {_input.LA(1) != '.'}?
| [0-9]* '.' [0-9]+
;
INT
: [0-9]+
;
Do any of you know where to start learning these expressions?
Upvotes: 0
Views: 655
Reputation: 1570
These symbols are a part of regular expressions, see this tutorial about regular expression in python (it's very similar in all languages).
the *
means match the previous thing zero or more times, for example, a*
will match
, a
, aa
, ...
the +
means match the previous thing one or more times, for example, a+
will match a
, aa
, ...
the ?
means match the previous thing zero or one times, for example, a?
will match
or a
.
Upvotes: 2