Merge: Some gammar improvements
authorJean Privat <jean@pryen.org>
Wed, 22 Oct 2014 22:45:27 +0000 (18:45 -0400)
committerJean Privat <jean@pryen.org>
Wed, 22 Oct 2014 22:45:27 +0000 (18:45 -0400)
commite1e9193c7e61b0933014b2ecfaadf2fc4368101c
tree82408cc3b6a1c532c53b7204bd023e94174c297a
parent50e47534ee157f1d1fdf9b4045984e8550aeb5b2
parent98808ec99b1a37d6b4e635dc9092235138617c27
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>
src/modelize/modelize_property.nit
src/nitpretty.nit
src/parser/parser_nodes.nit
src/parser/parser_work.nit
src/semantize/flow.nit
src/semantize/typing.nit