parser: inits uses Collection instead of Array
[nit.git] / src / parser / parser_prod.nit
index 5be856a..92f9525 100644 (file)
@@ -72,6 +72,9 @@ redef class Prod
                if first_token == null then
                        return "????"
                end
+               if last_token == null then
+                       return "{first_token.locate}--????"
+               end
                var lastpos = last_token.pos + last_token.text.length - 1
                if first_token.line == last_token.line then
                        return "{first_token.locate}--{lastpos}"
@@ -119,8 +122,8 @@ redef class AModule
 
     init init_amodule (
             n_packagedecl: PPackagedecl ,
-            n_imports: Array[Object] , # Should be Array[PImport]
-            n_classdefs: Array[Object]  # Should be Array[PClassdef]
+            n_imports: Collection[Object] , # Should be Collection[PImport]
+            n_classdefs: Collection[Object]  # Should be Collection[PClassdef]
     )
     do
         empty_init
@@ -756,9 +759,9 @@ redef class AClassdef
             n_visibility: PVisibility ,
             n_classkind: PClasskind ,
             n_id: TClassid ,
-            n_formaldefs: Array[Object] , # Should be Array[PFormaldef]
-            n_superclasses: Array[Object] , # Should be Array[PSuperclass]
-            n_propdefs: Array[Object]  # Should be Array[PPropdef]
+            n_formaldefs: Collection[Object] , # Should be Collection[PFormaldef]
+            n_superclasses: Collection[Object] , # Should be Collection[PSuperclass]
+            n_propdefs: Collection[Object]  # Should be Collection[PPropdef]
     )
     do
         empty_init
@@ -966,7 +969,7 @@ redef class ATopClassdef
     private init empty_init do end
 
     init init_atopclassdef (
-            n_propdefs: Array[Object]  # Should be Array[PPropdef]
+            n_propdefs: Collection[Object]  # Should be Collection[PPropdef]
     )
     do
         empty_init
@@ -1018,7 +1021,7 @@ redef class AMainClassdef
     private init empty_init do end
 
     init init_amainclassdef (
-            n_propdefs: Array[Object]  # Should be Array[PPropdef]
+            n_propdefs: Collection[Object]  # Should be Collection[PPropdef]
     )
     do
         empty_init
@@ -1498,6 +1501,13 @@ redef class AAttrPropdef
            n.parent = self
         end
     end
+    redef meth n_kwvar=(n: TKwvar)
+    do
+        _n_kwvar = n
+        if n != null then
+           n.parent = self
+        end
+    end
     redef meth n_id=(n: TAttrid)
     do
         _n_id = n
@@ -1529,6 +1539,7 @@ redef class AAttrPropdef
             n_kwredef: TKwredef ,
             n_visibility: PVisibility ,
             n_kwattr: TKwattr ,
+            n_kwvar: TKwvar ,
             n_id: TAttrid ,
             n_type: PType ,
             n_expr: PExpr 
@@ -1559,6 +1570,10 @@ redef class AAttrPropdef
        if n_kwattr != null then
                n_kwattr.parent = self
        end
+        _n_kwvar = n_kwvar
+       if n_kwvar != null then
+               n_kwvar.parent = self
+       end
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -1636,6 +1651,16 @@ redef class AAttrPropdef
             end
             return
        end
+        if _n_kwvar == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa TKwvar
+                _n_kwvar = new_child
+           else
+               _n_kwvar = null
+            end
+            return
+       end
         if _n_id == old_child then
             if new_child != null then
                 new_child.parent = self
@@ -1688,6 +1713,9 @@ redef class AAttrPropdef
         if _n_kwattr != null then
             v.visit(_n_kwattr)
         end
+        if _n_kwvar != null then
+            v.visit(_n_kwvar)
+        end
         if _n_id != null then
             v.visit(_n_id)
         end
@@ -1719,6 +1747,9 @@ redef class AAttrPropdef
         if _n_kwattr != null then
             v.visit(_n_kwattr)
         end
+        if _n_kwvar != null then
+            v.visit(_n_kwvar)
+        end
         if _n_id != null then
             v.visit(_n_id)
         end
@@ -4300,9 +4331,9 @@ redef class ASignature
     private init empty_init do end
 
     init init_asignature (
-            n_params: Array[Object] , # Should be Array[PParam]
+            n_params: Collection[Object] , # Should be Collection[PParam]
             n_type: PType ,
-            n_closure_decls: Array[Object]  # Should be Array[PClosureDecl]
+            n_closure_decls: Collection[Object]  # Should be Collection[PClosureDecl]
     )
     do
         empty_init
@@ -4533,6 +4564,13 @@ redef class AClosureDecl
            n.parent = self
         end
     end
+    redef meth n_expr=(n: PExpr)
+    do
+        _n_expr = n
+        if n != null then
+           n.parent = self
+        end
+    end
 
     private init empty_init do end
 
@@ -4540,7 +4578,8 @@ redef class AClosureDecl
             n_kwwith: TKwwith ,
             n_kwbreak: TKwbreak ,
             n_id: TId ,
-            n_signature: PSignature 
+            n_signature: PSignature ,
+            n_expr: PExpr 
     )
     do
         empty_init
@@ -4560,6 +4599,10 @@ redef class AClosureDecl
        if n_signature != null then
                n_signature.parent = self
        end
+        _n_expr = n_expr
+       if n_expr != null then
+               n_expr.parent = self
+       end
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -4605,6 +4648,16 @@ redef class AClosureDecl
             end
             return
        end
+        if _n_expr == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa PExpr
+                _n_expr = new_child
+           else
+               _n_expr = null
+            end
+            return
+       end
     end
 
     redef meth visit_all(v: Visitor)
@@ -4621,6 +4674,9 @@ redef class AClosureDecl
         if _n_signature != null then
             v.visit(_n_signature)
         end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -4637,6 +4693,9 @@ redef class AClosureDecl
         if _n_signature != null then
             v.visit(_n_signature)
         end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
     end
 end
 redef class AType
@@ -4652,7 +4711,7 @@ redef class AType
 
     init init_atype (
             n_id: TClassid ,
-            n_types: Array[Object]  # Should be Array[PType]
+            n_types: Collection[Object]  # Should be Collection[PType]
     )
     do
         empty_init
@@ -4724,7 +4783,7 @@ redef class ABlockExpr
     private init empty_init do end
 
     init init_ablockexpr (
-            n_expr: Array[Object]  # Should be Array[PExpr]
+            n_expr: Collection[Object]  # Should be Collection[PExpr]
     )
     do
         empty_init
@@ -5763,130 +5822,37 @@ redef class AWhileExpr
     end
 end
 redef class AForExpr
-    redef meth n_vardecl=(n: PExpr)
-    do
-        _n_vardecl = n
-        if n != null then
-           n.parent = self
-        end
-    end
-    redef meth n_kwdo=(n: TKwdo)
+    redef meth n_kwfor=(n: TKwfor)
     do
-        _n_kwdo = n
+        _n_kwfor = n
         if n != null then
            n.parent = self
         end
     end
-    redef meth n_block=(n: PExpr)
+    redef meth n_id=(n: TId)
     do
-        _n_block = n
+        _n_id = n
         if n != null then
            n.parent = self
         end
     end
-
-    private init empty_init do end
-
-    init init_aforexpr (
-            n_vardecl: PExpr ,
-            n_kwdo: TKwdo ,
-            n_block: PExpr 
-    )
-    do
-        empty_init
-        _n_vardecl = n_vardecl
-       if n_vardecl != null then
-               n_vardecl.parent = self
-       end
-        _n_kwdo = n_kwdo
-       if n_kwdo != null then
-               n_kwdo.parent = self
-       end
-        _n_block = n_block
-       if n_block != null then
-               n_block.parent = self
-       end
-    end
-
-    redef meth replace_child(old_child: PNode, new_child: PNode)
-    do
-        assert old_child != null
-        if _n_vardecl == old_child then
-            if new_child != null then
-                new_child.parent = self
-               assert new_child isa PExpr
-                _n_vardecl = new_child
-           else
-               _n_vardecl = null
-            end
-            return
-       end
-        if _n_kwdo == old_child then
-            if new_child != null then
-                new_child.parent = self
-               assert new_child isa TKwdo
-                _n_kwdo = new_child
-           else
-               _n_kwdo = null
-            end
-            return
-       end
-        if _n_block == old_child then
-            if new_child != null then
-                new_child.parent = self
-               assert new_child isa PExpr
-                _n_block = new_child
-           else
-               _n_block = null
-            end
-            return
-       end
-    end
-
-    redef meth visit_all(v: Visitor)
-    do
-        if _n_vardecl != null then
-            v.visit(_n_vardecl)
-        end
-        if _n_kwdo != null then
-            v.visit(_n_kwdo)
-        end
-        if _n_block != null then
-            v.visit(_n_block)
-        end
-    end
-
-    redef meth visit_all_reverse(v: Visitor)
-    do
-        if _n_vardecl != null then
-            v.visit(_n_vardecl)
-        end
-        if _n_kwdo != null then
-            v.visit(_n_kwdo)
-        end
-        if _n_block != null then
-            v.visit(_n_block)
-        end
-    end
-end
-redef class AForVardeclExpr
-    redef meth n_kwfor=(n: TKwfor)
+    redef meth n_expr=(n: PExpr)
     do
-        _n_kwfor = n
+        _n_expr = n
         if n != null then
            n.parent = self
         end
     end
-    redef meth n_id=(n: TId)
+    redef meth n_kwdo=(n: TKwdo)
     do
-        _n_id = n
+        _n_kwdo = n
         if n != null then
            n.parent = self
         end
     end
-    redef meth n_expr=(n: PExpr)
+    redef meth n_block=(n: PExpr)
     do
-        _n_expr = n
+        _n_block = n
         if n != null then
            n.parent = self
         end
@@ -5894,10 +5860,12 @@ redef class AForVardeclExpr
 
     private init empty_init do end
 
-    init init_aforvardeclexpr (
+    init init_aforexpr (
             n_kwfor: TKwfor ,
             n_id: TId ,
-            n_expr: PExpr 
+            n_expr: PExpr ,
+            n_kwdo: TKwdo ,
+            n_block: PExpr 
     )
     do
         empty_init
@@ -5913,6 +5881,14 @@ redef class AForVardeclExpr
        if n_expr != null then
                n_expr.parent = self
        end
+        _n_kwdo = n_kwdo
+       if n_kwdo != null then
+               n_kwdo.parent = self
+       end
+        _n_block = n_block
+       if n_block != null then
+               n_block.parent = self
+       end
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -5948,6 +5924,26 @@ redef class AForVardeclExpr
             end
             return
        end
+        if _n_kwdo == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa TKwdo
+                _n_kwdo = new_child
+           else
+               _n_kwdo = null
+            end
+            return
+       end
+        if _n_block == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa PExpr
+                _n_block = new_child
+           else
+               _n_block = null
+            end
+            return
+       end
     end
 
     redef meth visit_all(v: Visitor)
@@ -5961,6 +5957,12 @@ redef class AForVardeclExpr
         if _n_expr != null then
             v.visit(_n_expr)
         end
+        if _n_kwdo != null then
+            v.visit(_n_kwdo)
+        end
+        if _n_block != null then
+            v.visit(_n_block)
+        end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -5974,6 +5976,12 @@ redef class AForVardeclExpr
         if _n_expr != null then
             v.visit(_n_expr)
         end
+        if _n_kwdo != null then
+            v.visit(_n_kwdo)
+        end
+        if _n_block != null then
+            v.visit(_n_block)
+        end
     end
 end
 redef class AAssertExpr
@@ -7743,7 +7751,7 @@ redef class ANewExpr
             n_kwnew: TKwnew ,
             n_type: PType ,
             n_id: TId ,
-            n_args: Array[Object]  # Should be Array[PExpr]
+            n_args: Collection[Object]  # Should be Collection[PExpr]
     )
     do
         empty_init
@@ -8220,8 +8228,8 @@ redef class ACallExpr
     init init_acallexpr (
             n_expr: PExpr ,
             n_id: TId ,
-            n_args: Array[Object] , # Should be Array[PExpr]
-            n_closure_defs: Array[Object]  # Should be Array[PClosureDef]
+            n_args: Collection[Object] , # Should be Collection[PExpr]
+            n_closure_defs: Collection[Object]  # Should be Collection[PClosureDef]
     )
     do
         empty_init
@@ -8371,7 +8379,7 @@ redef class ACallAssignExpr
     init init_acallassignexpr (
             n_expr: PExpr ,
             n_id: TId ,
-            n_args: Array[Object] , # Should be Array[PExpr]
+            n_args: Collection[Object] , # Should be Collection[PExpr]
             n_assign: TAssign ,
             n_value: PExpr 
     )
@@ -8535,7 +8543,7 @@ redef class ACallReassignExpr
     init init_acallreassignexpr (
             n_expr: PExpr ,
             n_id: TId ,
-            n_args: Array[Object] , # Should be Array[PExpr]
+            n_args: Collection[Object] , # Should be Collection[PExpr]
             n_assign_op: PAssignOp ,
             n_value: PExpr 
     )
@@ -8685,7 +8693,7 @@ redef class ASuperExpr
     init init_asuperexpr (
             n_qualified: PQualified ,
             n_kwsuper: TKwsuper ,
-            n_args: Array[Object]  # Should be Array[PExpr]
+            n_args: Collection[Object]  # Should be Collection[PExpr]
     )
     do
         empty_init
@@ -8793,7 +8801,7 @@ redef class AInitExpr
     init init_ainitexpr (
             n_expr: PExpr ,
             n_kwinit: TKwinit ,
-            n_args: Array[Object]  # Should be Array[PExpr]
+            n_args: Collection[Object]  # Should be Collection[PExpr]
     )
     do
         empty_init
@@ -8893,8 +8901,8 @@ redef class ABraExpr
 
     init init_abraexpr (
             n_expr: PExpr ,
-            n_args: Array[Object] , # Should be Array[PExpr]
-            n_closure_defs: Array[Object]  # Should be Array[PClosureDef]
+            n_args: Collection[Object] , # Should be Collection[PExpr]
+            n_closure_defs: Collection[Object]  # Should be Collection[PClosureDef]
     )
     do
         empty_init
@@ -9016,7 +9024,7 @@ redef class ABraAssignExpr
 
     init init_abraassignexpr (
             n_expr: PExpr ,
-            n_args: Array[Object] , # Should be Array[PExpr]
+            n_args: Collection[Object] , # Should be Collection[PExpr]
             n_assign: TAssign ,
             n_value: PExpr 
     )
@@ -9152,7 +9160,7 @@ redef class ABraReassignExpr
 
     init init_abrareassignexpr (
             n_expr: PExpr ,
-            n_args: Array[Object] , # Should be Array[PExpr]
+            n_args: Collection[Object] , # Should be Collection[PExpr]
             n_assign_op: PAssignOp ,
             n_value: PExpr 
     )
@@ -9768,7 +9776,7 @@ redef class AArrayExpr
     private init empty_init do end
 
     init init_aarrayexpr (
-            n_exprs: Array[Object]  # Should be Array[PExpr]
+            n_exprs: Collection[Object]  # Should be Collection[PExpr]
     )
     do
         empty_init
@@ -10403,7 +10411,7 @@ redef class ASuperstringExpr
     private init empty_init do end
 
     init init_asuperstringexpr (
-            n_exprs: Array[Object]  # Should be Array[PExpr]
+            n_exprs: Collection[Object]  # Should be Collection[PExpr]
     )
     do
         empty_init
@@ -10737,7 +10745,7 @@ redef class AClosureDef
 
     init init_aclosuredef (
             n_kwwith: TKwwith ,
-            n_id: Array[Object] , # Should be Array[TId]
+            n_id: Collection[Object] , # Should be Collection[TId]
             n_kwdo: TKwdo ,
             n_expr: PExpr 
     )
@@ -10858,7 +10866,7 @@ redef class AQualified
     private init empty_init do end
 
     init init_aqualified (
-            n_id: Array[Object] , # Should be Array[TId]
+            n_id: Collection[Object] , # Should be Collection[TId]
             n_classid: TClassid 
     )
     do
@@ -10931,7 +10939,7 @@ redef class ADoc
     private init empty_init do end
 
     init init_adoc (
-            n_comment: Array[Object]  # Should be Array[TComment]
+            n_comment: Collection[Object]  # Should be Collection[TComment]
     )
     do
         empty_init