Closed johnny-alvarado closed 5 years ago
RANGE should be a rule (so range
), not a terminal. Uppercase vs lowercase matters.
Regarding if a range can be a minus - that depends: Can you explain clearly the difference between range and substractions, in terms of syntax?
Consider using a different range operator, like ..
or :
I tried with the rule as you suggested and it works. Now, the difference between the range and the substraction is that the range is used only within a list: (1-3,9) is equivalent to (1,2,3,9). Everywhere else it must be a substraction.
Well, you're gonna have a collision the way you do it now, because a-b
can be both. You should put range
outside of atom
, and as a special member of list
.
But I really don't recommend that syntax, what if you want to do subtraction inside lists?
Excellent, thank you for your help!
Currently, I have lists in my grammar. These lists are numbers separated by a comma within parenthesis: (1, 2, 3)
I am trying to include ranges, for example (1-3,8) is equivalent to (1, 2, 3, 8)
Since the minus sign might be confusing, I change it by "&", so my list looks like (1&3,8). For this purpose, I am using the attached grammar and transformers. However, I get an error trying to run the code.
My questions are:
My code follows...