Open iwillspeak opened 5 years ago
The Ruby grammar appears to solve this problem with a pair grammar non-terminals:
T
, which can be either ;
, or \n
DO
, which is either the literal "do"
or T
.which means you can write loops like while foo do (100) end
and
while foo
(100)
end
Given the following:
The parse tree will be a function call to foo, rather than a grouping expression in the body of the while loop. To solve this we need some kind of expression separator.
while
we could mandate()
around the conditionwhile
we could have an openingdo
or similar;
in CIn general I'm not a fan of the whitespace solution. I'd rather the language wasn't whitespace sensitive. If we move to a traditional
if
/elif
/else
block this will become more pressing as the same ambiguity exists there.