4 ms·
Sorry for not understanding, but can you explain what the ambiguity is here?
by MichaelGG 15y ago
Sorry for not understanding, but can you explain what the ambiguity is here?
- rayiner 15y agoA C-like parser will keep parsing an expression as long as it's legal. Take: foo("bar") * a It will parse the call to 'foo', then see the '*' which is an infix operator and parse the whole thing as a multiplication expression. In most C-like languages, '(' is both a prefix operator (for grouping) and an infix operator (for function calls). So: foo("bar") (a + b) Is ambiguous if you don't require semicolons to separate expressions. The parser will parse the call to foo, then see the '(' and parse that as a call to the value returned by 'foo'. To stop that, you use the semicolon to stop parsing one expression, so the next '(' is treated as a prefix operator.
- MichaelGG 15y agoWow, yes of course. For some reason I thought Xtend was whitespace sensitive, so just having a newline was enough.