Merge: Some gammar improvements
A bunch of unrelated grammar work: bugfixes, a feature and stuff for future work.
The only implemented feature is the use of extended method identifiers in annotation (setters and operators)
~~~nit
class A
var foo: String is writable(real_foo=)
fun foo=(f: String) do
print "Hello!"
real_foo = f
end
end
~~~
Some additional syntax for future works are now accepted but are ignored (or will crash at compile-time).
* user defined factories in class (eg. define `new` in interface)
~~~
interface Buffer
new do return new FlatBuffer
end
var x = new Buffer
~~~
* code-block in attributes. when the default/lazy value is more complex than a single expression
~~~
class A
var foo: Int do
print "Hello!"
return 5
end
end
~~~
* generalized tuples. eg. for multiple returns, but more word is needed #839
~~~
fun foo(a,b: Int)
do
return (a/b, a%b)
end
~~~
In fact, generalized tuples accepts anything that annotations accepts... (eventually they will be rejected just after parsing)
~~~
var x = (1, Array[Int], for x in a do print x, toto=, -)
# in order: a literal expression, a type, a statement, a method identifier (setter),
# an other method identifier (the minus operator)
~~~
Pull-Request: #832
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>