I'm using parsimonious to do some parsing and I'm having trouble figuring out how to properly parse alternatives that share the first character in an unordered away:
For example:
Text:
2 > 3
2 >= 3
Grammar:
expr = ~"[0-9]+" space operator space ~"[0-9]+"
operator = ">" / "==" / "<" / ">=" / "<="
space = ~"[\\s]*"
The first line of the text will parse correctly, but the second line won't. It seems like it matches ">" then gets stuck since it sees a "=". It never matches ">=" as a whole. How do I make it do that without having to specify these in careful order? I tried using "&" for lookahead matching but that doesn't seem to work.