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:
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:
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.
[ Parent
| on HN ]