I want to define a "KEYER" in flex, which is a "KEY" in "[]". A "KEY" is starting with a letter and a string of letters, numbers and the following characters: "~_'?$. -". I defind:
keyChar ([a-zA-z0-9~_'?$. \-])
letter ([a-zA-Z])
key ({letter}{keyChar}+)
keyer ("["{key}"]")
and:
<*>{keyer} print("KEYER");
Somehow the input:
[keyer1] [keyer2] [keyer 3]
is read as one KEYER and not three of them. what did I do wrong?
You wrote
A-z
instead ofA-Z
in the pattern forkeyChar
.[A-z]
includes the characters betweenZ
anda
, which include brackets.On the whole, it is better to avoid range expressions when not necessary. I would have written: