From: Jean Privat Date: Mon, 20 Mar 2017 20:09:00 +0000 (-0400) Subject: Merge: grammar: add union and intersection types X-Git-Url: http://nitlanguage.org Merge: grammar: add union and intersection types This is a stub in the grammar to add intersection and union types. * `var x: A and B` * `var x: A or B and C or D or E` Adding parenthesis `(A and B) or C` cause some nasty conflicts because the Nit grammar is very complex and organic (and sablecc is nowadays more a curse than a blessing). all usage of types accept intersection and union except `new` and `isa` because LR1 conflicts with the boolean `or`. * `x isa A or...`: shift type (`x isa A or B`) vs. reduce expr (`x isa A or true`) This is not too much a problem because: * intersection and union type are abstract (no `new`) * `a isa A or B` should be the same than `a isa A or a isa B` Note that this is only a stub: only the grammar is extended: * there is no new AST node (`A or B` is parsed as `A`, the `B` is just dropped) * there is no change in the metamodel of Nit Pull-Request: #2389 Reviewed-by: Jean-Christophe Beaupré --- a89f0533da07ab11e6518d5bb391b639c4bde748