Re:Eclipse launches new language to cut down Java boilerplat...
by MichaelGG on Friday November 04, 2011 @09:10PM
(#3198468)
Sorry for not understanding, but can you explain what the ambiguity is here?
[ Parent
| on HN ]
Re:Eclipse launches new language to cut down Java boilerplat...
by rayiner on Friday November 04, 2011 @09:32PM
(#3198529)
A 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.