Index: polemy/parse.d ================================================================== --- polemy/parse.d +++ polemy/parse.d @@ -176,11 +176,11 @@ } if( tryEat("@") ) { auto lay = "@"~eatId("for layer ID"); eat("(", "for layered execution"); - auto e = E(0); + auto e = Body(); eat(")", "after "~lay~"(..."); return new LayeredExpression(pos, lay, e); } if( tryEat("(") ) { ADDED sample/fizzbuzz.pmy Index: sample/fizzbuzz.pmy ================================================================== --- sample/fizzbuzz.pmy +++ sample/fizzbuzz.pmy @@ -0,0 +1,38 @@ +# +# Not at all a good example of the usage of layers, but anyway... +# +# after implementing layered parameters, this may be improved. +# (though still not a good example...) +# + +@ 3 print(x) { @v(print("Fizz")) }; +@ 5 print(x) { @v(print("Buzz")) }; +@15 print(x) { @v(print("FizzBuzz")) }; + +def fb(n, q3, q5, q15) { + if( q15 < 1 ) { + @15(print) + } else { + if( q5 < 1 ) { + @5(print) + } else { + if( q3 < 1 ) { + @3(print) + } else { + @v(print) + } + } + }(n); + let q3 = q3+1; + let q5 = q5+1; + let q15 = q15+1; + + fb( + n+1, + if(q3<3){q3}else{0}, + if(q5<5){q5}else{0}, + if(q15<15){q15}else{0} + ) +}; + +fb(0,0,0,0)