groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Pillot <nicolas.pil...@gmail.com>
Subject Parentheses required for some piece of dsl code
Date Sat, 26 Nov 2016 08:32:33 GMT
Hi

I am building a DSL and everythings is working smoothly, except that i
need to add parentheses to some constructs even if they are top-level
statements, otherwise startup fails with
MultipleCompilationErrorsException.

Here is the sample dsl :

test1 592 // ok
test2 { n 723 } // ok
test3 772, { n 60 } // ok
test4 ({ n 121 }, 1) // ok  with paren
test5 651, { n 122 }, 212
test6 ({ n 349 }, { t "eufysalnvlw" }) // ok with paren
test7 806, { n 757 }, { t "guffsvrtm" } // ok
test8 ({ n 581 }, 561, { t "kjxer" }) // ok with paren

// 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" }

The spec class looks like this (btw, class is @TypeChecked and each
arg has @DelegatesTo)

abstract class MasterScriptSpec extends Script {
  void test1(int num1) {}
  void test2(Closure cl1) {}
  void test3(int num1, Closure cl2) {}
  void test4(Closure cl1, int num2) {}
  void test5(int num1, Closure cl2, int num3) {}
  void test6(Closure cl1, Closure cl2) {}
  void test7(int num1, Closure cl2, Closure cl3) {}
  void test8(Closure cl1, int num2, Closure cl3) {}
}

I run the whole thing with : groovy -cp class/path -b MasterScriptSpec
sample.dsl

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 !

Thanks in advance for your insights

Nicolas

Mime
View raw message