groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <blackd...@gmx.org>
Subject Re: Parentheses required for some piece of dsl code
Date Sat, 26 Nov 2016 11:31:06 GMT
On 26.11.2016 09:32, Nicolas Pillot wrote:
[...]
> // fails with: expecting EOF, found ',' @ line 4, column 16.
> // test4 { n 121 }, 1
>
> // fails with: expecting EOF, found ',' @ line 11, column 16
> // test6 { n 349 }, { t "eufysalnvlw" }
>
> // fails with: expecting EOF, found ',' @ line 18, column 16.
> // test8 { n 581 }, 561, { t "kjxer" }
[...]
> Question is : I cannot figure out what rule or what reason "forces" me
> to add parentheses to test 4/6/8 ... and i would love to know !

This is actually not so easy to explain, since this is a side-effect of 
the way the grammar for the parser is written... and they are 
potentially bugs.

if you have foo {}, then this is seen as a complete method call, the 
parser simply does not expect further arguments after the {} if you wrap 
the whole thing in parens, you actually have a different rule applying, 
which explains why it works there. But that is actually not precise 
enough. we have also a different rule for foo {} and foo 1, {}. So imho 
the parser simply applies the wrong rule first and the problems you see 
are a result of priorities... or missing lookahead

bye Jochen


Mime
View raw message