parser: Do not crash if last_loken is unset
[nit.git] / src / parser / parser_prod.nit
index dd9b34e..43abe9e 100644 (file)
@@ -37,6 +37,9 @@ redef class PNode
        # Give a human readable location of the node.
        meth locate: String is abstract
 
+       # Return only the line number of the node
+       meth line_number: Int is abstract
+
        # Debug method: output a message prefixed with the location.
        meth printl(str: String)
        do
@@ -53,6 +56,8 @@ redef class Token
        do
                return "{filename}:{line},{pos}"
        end
+
+       redef meth line_number do return line
 end
 
 redef class Prod
@@ -67,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}"
@@ -76,11 +84,20 @@ redef class Prod
        end
 
        redef meth replace_with(n: PNode)
+        do
+                super
+                assert n isa Prod
+                n.first_token = first_token
+                n.last_token = last_token
+        end
+
+       redef meth line_number
        do
-               super
-               assert n isa Prod
-               n.first_token = first_token
-               n.last_token = last_token
+               if first_token != null then
+                       return first_token.line
+               else
+                       return 0
+               end
        end
 end
 
@@ -109,6 +126,7 @@ redef class AModule
             n_classdefs: Array[Object]  # Should be Array[PClassdef]
     )
     do
+        empty_init
         _n_packagedecl = n_packagedecl
        if n_packagedecl != null then
                n_packagedecl.parent = self
@@ -231,6 +249,7 @@ redef class APackagedecl
             n_id: TId 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -337,6 +356,7 @@ redef class AImport
             n_id: TId 
     )
     do
+        empty_init
         _n_visibility = n_visibility
        if n_visibility != null then
                n_visibility.parent = self
@@ -443,6 +463,7 @@ redef class ANoImport
             n_kwend: TKwend 
     )
     do
+        empty_init
         _n_visibility = n_visibility
        if n_visibility != null then
                n_visibility.parent = self
@@ -524,6 +545,7 @@ redef class APublicVisibility
 
     init init_apublicvisibility
     do
+        empty_init
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -554,6 +576,7 @@ redef class APrivateVisibility
             n_kwprivate: TKwprivate 
     )
     do
+        empty_init
         _n_kwprivate = n_kwprivate
        if n_kwprivate != null then
                n_kwprivate.parent = self
@@ -604,6 +627,7 @@ redef class AProtectedVisibility
             n_kwprotected: TKwprotected 
     )
     do
+        empty_init
         _n_kwprotected = n_kwprotected
        if n_kwprotected != null then
                n_kwprotected.parent = self
@@ -654,6 +678,7 @@ redef class AIntrudeVisibility
             n_kwintrude: TKwintrude 
     )
     do
+        empty_init
         _n_kwintrude = n_kwintrude
        if n_kwintrude != null then
                n_kwintrude.parent = self
@@ -739,6 +764,7 @@ redef class AClassdef
             n_propdefs: Array[Object]  # Should be Array[PPropdef]
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -946,6 +972,7 @@ redef class ATopClassdef
             n_propdefs: Array[Object]  # Should be Array[PPropdef]
     )
     do
+        empty_init
         _n_propdefs = new List[PPropdef]
        for n in n_propdefs do
                assert n isa PPropdef
@@ -997,6 +1024,7 @@ redef class AMainClassdef
             n_propdefs: Array[Object]  # Should be Array[PPropdef]
     )
     do
+        empty_init
         _n_propdefs = new List[PPropdef]
        for n in n_propdefs do
                assert n isa PPropdef
@@ -1055,6 +1083,7 @@ redef class AConcreteClasskind
             n_kwclass: TKwclass 
     )
     do
+        empty_init
         _n_kwclass = n_kwclass
        if n_kwclass != null then
                n_kwclass.parent = self
@@ -1113,6 +1142,7 @@ redef class AAbstractClasskind
             n_kwclass: TKwclass 
     )
     do
+        empty_init
         _n_kwabstract = n_kwabstract
        if n_kwabstract != null then
                n_kwabstract.parent = self
@@ -1183,6 +1213,7 @@ redef class AInterfaceClasskind
             n_kwinterface: TKwinterface 
     )
     do
+        empty_init
         _n_kwinterface = n_kwinterface
        if n_kwinterface != null then
                n_kwinterface.parent = self
@@ -1233,6 +1264,7 @@ redef class AUniversalClasskind
             n_kwuniversal: TKwuniversal 
     )
     do
+        empty_init
         _n_kwuniversal = n_kwuniversal
        if n_kwuniversal != null then
                n_kwuniversal.parent = self
@@ -1291,6 +1323,7 @@ redef class AFormaldef
             n_type: PType 
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -1369,6 +1402,7 @@ redef class ASuperclass
             n_type: PType 
     )
     do
+        empty_init
         _n_kwspecial = n_kwspecial
        if n_kwspecial != null then
                n_kwspecial.parent = self
@@ -1467,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
@@ -1498,11 +1539,13 @@ redef class AAttrPropdef
             n_kwredef: TKwredef ,
             n_visibility: PVisibility ,
             n_kwattr: TKwattr ,
+            n_kwvar: TKwvar ,
             n_id: TAttrid ,
             n_type: PType ,
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -1527,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
@@ -1604,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
@@ -1656,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
@@ -1687,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
@@ -1745,6 +1808,7 @@ redef class AMethPropdef
             n_signature: PSignature 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -1915,6 +1979,7 @@ redef class ADeferredMethPropdef
             n_signature: PSignature 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -2105,6 +2170,7 @@ redef class AInternMethPropdef
             n_signature: PSignature 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -2303,6 +2369,7 @@ redef class AExternMethPropdef
             n_extern: TString 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -2521,6 +2588,7 @@ redef class AConcreteMethPropdef
             n_block: PExpr 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -2739,6 +2807,7 @@ redef class AConcreteInitPropdef
             n_block: PExpr 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -2917,6 +2986,7 @@ redef class AMainMethPropdef
             n_block: PExpr 
     )
     do
+        empty_init
         _n_kwredef = n_kwredef
        if n_kwredef != null then
                n_kwredef.parent = self
@@ -3027,6 +3097,7 @@ redef class ATypePropdef
             n_type: PType 
     )
     do
+        empty_init
         _n_doc = n_doc
        if n_doc != null then
                n_doc.parent = self
@@ -3185,6 +3256,7 @@ redef class AReadAble
             n_kwreadable: TKwreadable 
     )
     do
+        empty_init
         _n_kwredef = n_kwredef
        if n_kwredef != null then
                n_kwredef.parent = self
@@ -3263,6 +3335,7 @@ redef class AWriteAble
             n_kwwritable: TKwwritable 
     )
     do
+        empty_init
         _n_kwredef = n_kwredef
        if n_kwredef != null then
                n_kwredef.parent = self
@@ -3333,6 +3406,7 @@ redef class AIdMethid
             n_id: TId 
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -3383,6 +3457,7 @@ redef class APlusMethid
             n_plus: TPlus 
     )
     do
+        empty_init
         _n_plus = n_plus
        if n_plus != null then
                n_plus.parent = self
@@ -3433,6 +3508,7 @@ redef class AMinusMethid
             n_minus: TMinus 
     )
     do
+        empty_init
         _n_minus = n_minus
        if n_minus != null then
                n_minus.parent = self
@@ -3483,6 +3559,7 @@ redef class AStarMethid
             n_star: TStar 
     )
     do
+        empty_init
         _n_star = n_star
        if n_star != null then
                n_star.parent = self
@@ -3533,6 +3610,7 @@ redef class ASlashMethid
             n_slash: TSlash 
     )
     do
+        empty_init
         _n_slash = n_slash
        if n_slash != null then
                n_slash.parent = self
@@ -3583,6 +3661,7 @@ redef class APercentMethid
             n_percent: TPercent 
     )
     do
+        empty_init
         _n_percent = n_percent
        if n_percent != null then
                n_percent.parent = self
@@ -3633,6 +3712,7 @@ redef class AEqMethid
             n_eq: TEq 
     )
     do
+        empty_init
         _n_eq = n_eq
        if n_eq != null then
                n_eq.parent = self
@@ -3683,6 +3763,7 @@ redef class ANeMethid
             n_ne: TNe 
     )
     do
+        empty_init
         _n_ne = n_ne
        if n_ne != null then
                n_ne.parent = self
@@ -3733,6 +3814,7 @@ redef class ALeMethid
             n_le: TLe 
     )
     do
+        empty_init
         _n_le = n_le
        if n_le != null then
                n_le.parent = self
@@ -3783,6 +3865,7 @@ redef class AGeMethid
             n_ge: TGe 
     )
     do
+        empty_init
         _n_ge = n_ge
        if n_ge != null then
                n_ge.parent = self
@@ -3833,6 +3916,7 @@ redef class ALtMethid
             n_lt: TLt 
     )
     do
+        empty_init
         _n_lt = n_lt
        if n_lt != null then
                n_lt.parent = self
@@ -3883,6 +3967,7 @@ redef class AGtMethid
             n_gt: TGt 
     )
     do
+        empty_init
         _n_gt = n_gt
        if n_gt != null then
                n_gt.parent = self
@@ -3941,6 +4026,7 @@ redef class ABraMethid
             n_cbra: TCbra 
     )
     do
+        empty_init
         _n_obra = n_obra
        if n_obra != null then
                n_obra.parent = self
@@ -4011,6 +4097,7 @@ redef class AStarshipMethid
             n_starship: TStarship 
     )
     do
+        empty_init
         _n_starship = n_starship
        if n_starship != null then
                n_starship.parent = self
@@ -4069,6 +4156,7 @@ redef class AAssignMethid
             n_assign: TAssign 
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -4155,6 +4243,7 @@ redef class ABraassignMethid
             n_assign: TAssign 
     )
     do
+        empty_init
         _n_obra = n_obra
        if n_obra != null then
                n_obra.parent = self
@@ -4243,9 +4332,11 @@ redef class ASignature
 
     init init_asignature (
             n_params: Array[Object] , # Should be Array[PParam]
-            n_type: PType 
+            n_type: PType ,
+            n_closure_decls: Array[Object]  # Should be Array[PClosureDecl]
     )
     do
+        empty_init
         _n_params = new List[PParam]
        for n in n_params do
                assert n isa PParam
@@ -4256,6 +4347,12 @@ redef class ASignature
        if n_type != null then
                n_type.parent = self
        end
+        _n_closure_decls = new List[PClosureDecl]
+       for n in n_closure_decls do
+               assert n isa PClosureDecl
+               _n_closure_decls.add(n)
+               n.parent = self
+       end
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -4283,6 +4380,18 @@ redef class ASignature
             end
             return
        end
+        for i in [0.._n_closure_decls.length[ do
+            if _n_closure_decls[i] == old_child then
+                if new_child != null then
+                   assert new_child isa PClosureDecl
+                    _n_closure_decls[i] = new_child
+                    new_child.parent = self
+                else
+                    _n_closure_decls.remove_at(i)
+                end
+                return
+            end
+        end
     end
 
     redef meth visit_all(v: Visitor)
@@ -4293,6 +4402,9 @@ redef class ASignature
         if _n_type != null then
             v.visit(_n_type)
         end
+            for n in _n_closure_decls do
+                v.visit(n)
+           end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -4307,6 +4419,13 @@ redef class ASignature
         if _n_type != null then
             v.visit(_n_type)
         end
+       do
+           var i = _n_closure_decls.length
+            while i >= 0 do
+                v.visit(_n_closure_decls[i])
+               i = i - 1
+           end
+       end
     end
 end
 redef class AParam
@@ -4340,6 +4459,7 @@ redef class AParam
             n_dotdotdot: TDotdotdot 
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -4415,6 +4535,169 @@ redef class AParam
         end
     end
 end
+redef class AClosureDecl
+    redef meth n_kwwith=(n: TKwwith)
+    do
+        _n_kwwith = n
+        if n != null then
+           n.parent = self
+        end
+    end
+    redef meth n_kwbreak=(n: TKwbreak)
+    do
+        _n_kwbreak = n
+        if n != null then
+           n.parent = self
+        end
+    end
+    redef meth n_id=(n: TId)
+    do
+        _n_id = n
+        if n != null then
+           n.parent = self
+        end
+    end
+    redef meth n_signature=(n: PSignature)
+    do
+        _n_signature = n
+        if n != null then
+           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
+
+    init init_aclosuredecl (
+            n_kwwith: TKwwith ,
+            n_kwbreak: TKwbreak ,
+            n_id: TId ,
+            n_signature: PSignature ,
+            n_expr: PExpr 
+    )
+    do
+        empty_init
+        _n_kwwith = n_kwwith
+       if n_kwwith != null then
+               n_kwwith.parent = self
+       end
+        _n_kwbreak = n_kwbreak
+       if n_kwbreak != null then
+               n_kwbreak.parent = self
+       end
+        _n_id = n_id
+       if n_id != null then
+               n_id.parent = self
+       end
+        _n_signature = n_signature
+       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)
+    do
+        assert old_child != null
+        if _n_kwwith == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa TKwwith
+                _n_kwwith = new_child
+           else
+               _n_kwwith = null
+            end
+            return
+       end
+        if _n_kwbreak == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa TKwbreak
+                _n_kwbreak = new_child
+           else
+               _n_kwbreak = null
+            end
+            return
+       end
+        if _n_id == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa TId
+                _n_id = new_child
+           else
+               _n_id = null
+            end
+            return
+       end
+        if _n_signature == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa PSignature
+                _n_signature = new_child
+           else
+               _n_signature = null
+            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)
+    do
+        if _n_kwwith != null then
+            v.visit(_n_kwwith)
+        end
+        if _n_kwbreak != null then
+            v.visit(_n_kwbreak)
+        end
+        if _n_id != null then
+            v.visit(_n_id)
+        end
+        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)
+    do
+        if _n_kwwith != null then
+            v.visit(_n_kwwith)
+        end
+        if _n_kwbreak != null then
+            v.visit(_n_kwbreak)
+        end
+        if _n_id != null then
+            v.visit(_n_id)
+        end
+        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
     redef meth n_id=(n: TClassid)
     do
@@ -4431,6 +4714,7 @@ redef class AType
             n_types: Array[Object]  # Should be Array[PType]
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -4502,6 +4786,7 @@ redef class ABlockExpr
             n_expr: Array[Object]  # Should be Array[PExpr]
     )
     do
+        empty_init
         _n_expr = new List[PExpr]
        for n in n_expr do
                assert n isa PExpr
@@ -4592,6 +4877,7 @@ redef class AVardeclExpr
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_kwvar = n_kwvar
        if n_kwvar != null then
                n_kwvar.parent = self
@@ -4730,6 +5016,7 @@ redef class AReturnExpr
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_kwreturn = n_kwreturn
        if n_kwreturn != null then
                n_kwreturn.parent = self
@@ -4793,17 +5080,30 @@ redef class ABreakExpr
            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
 
     init init_abreakexpr (
-            n_kwbreak: TKwbreak 
+            n_kwbreak: TKwbreak ,
+            n_expr: PExpr 
     )
     do
+        empty_init
         _n_kwbreak = n_kwbreak
        if n_kwbreak != null then
                n_kwbreak.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)
@@ -4819,6 +5119,16 @@ redef class ABreakExpr
             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)
@@ -4826,6 +5136,9 @@ redef class ABreakExpr
         if _n_kwbreak != null then
             v.visit(_n_kwbreak)
         end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -4833,6 +5146,9 @@ redef class ABreakExpr
         if _n_kwbreak != null then
             v.visit(_n_kwbreak)
         end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
     end
 end
 redef class AAbortExpr
@@ -4850,6 +5166,7 @@ redef class AAbortExpr
             n_kwabort: TKwabort 
     )
     do
+        empty_init
         _n_kwabort = n_kwabort
        if n_kwabort != null then
                n_kwabort.parent = self
@@ -4893,17 +5210,30 @@ redef class AContinueExpr
            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
 
     init init_acontinueexpr (
-            n_kwcontinue: TKwcontinue 
+            n_kwcontinue: TKwcontinue ,
+            n_expr: PExpr 
     )
     do
+        empty_init
         _n_kwcontinue = n_kwcontinue
        if n_kwcontinue != null then
                n_kwcontinue.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)
@@ -4919,6 +5249,16 @@ redef class AContinueExpr
             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)
@@ -4926,6 +5266,9 @@ redef class AContinueExpr
         if _n_kwcontinue != null then
             v.visit(_n_kwcontinue)
         end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -4933,6 +5276,9 @@ redef class AContinueExpr
         if _n_kwcontinue != null then
             v.visit(_n_kwcontinue)
         end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
     end
 end
 redef class ADoExpr
@@ -4958,6 +5304,7 @@ redef class ADoExpr
             n_block: PExpr 
     )
     do
+        empty_init
         _n_kwdo = n_kwdo
        if n_kwdo != null then
                n_kwdo.parent = self
@@ -5052,6 +5399,7 @@ redef class AIfExpr
             n_else: PExpr 
     )
     do
+        empty_init
         _n_kwif = n_kwif
        if n_kwif != null then
                n_kwif.parent = self
@@ -5202,6 +5550,7 @@ redef class AIfexprExpr
             n_else: PExpr 
     )
     do
+        empty_init
         _n_kwif = n_kwif
        if n_kwif != null then
                n_kwif.parent = self
@@ -5376,6 +5725,7 @@ redef class AWhileExpr
             n_block: PExpr 
     )
     do
+        empty_init
         _n_kwwhile = n_kwwhile
        if n_kwwhile != null then
                n_kwwhile.parent = self
@@ -5472,129 +5822,37 @@ redef class AWhileExpr
     end
 end
 redef class AForExpr
-    redef meth n_vardecl=(n: PExpr)
+    redef meth n_kwfor=(n: TKwfor)
     do
-        _n_vardecl = n
+        _n_kwfor = n
         if n != null then
            n.parent = self
         end
     end
-    redef meth n_kwdo=(n: TKwdo)
-    do
-        _n_kwdo = 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
-        _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
@@ -5602,12 +5860,15 @@ 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
         _n_kwfor = n_kwfor
        if n_kwfor != null then
                n_kwfor.parent = self
@@ -5620,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)
@@ -5655,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)
@@ -5668,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)
@@ -5681,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
@@ -5714,6 +6015,7 @@ redef class AAssertExpr
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_kwassert = n_kwassert
        if n_kwassert != null then
                n_kwassert.parent = self
@@ -5812,6 +6114,7 @@ redef class AOnceExpr
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_kwonce = n_kwonce
        if n_kwonce != null then
                n_kwonce.parent = self
@@ -5882,6 +6185,7 @@ redef class ASendExpr
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -5940,6 +6244,7 @@ redef class ABinopExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6018,6 +6323,7 @@ redef class AOrExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6096,6 +6402,7 @@ redef class AAndExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6174,6 +6481,7 @@ redef class ANotExpr
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_kwnot = n_kwnot
        if n_kwnot != null then
                n_kwnot.parent = self
@@ -6252,6 +6560,7 @@ redef class AEqExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6330,6 +6639,7 @@ redef class AEeExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6408,6 +6718,7 @@ redef class ANeExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6486,6 +6797,7 @@ redef class ALtExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6564,6 +6876,7 @@ redef class ALeExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6642,6 +6955,7 @@ redef class AGtExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6720,6 +7034,7 @@ redef class AGeExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6798,6 +7113,7 @@ redef class AIsaExpr
             n_type: PType 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6876,6 +7192,7 @@ redef class APlusExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -6954,6 +7271,7 @@ redef class AMinusExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7032,6 +7350,7 @@ redef class AStarshipExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7110,6 +7429,7 @@ redef class AStarExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7188,6 +7508,7 @@ redef class ASlashExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7266,6 +7587,7 @@ redef class APercentExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7344,6 +7666,7 @@ redef class AUminusExpr
             n_expr: PExpr 
     )
     do
+        empty_init
         _n_minus = n_minus
        if n_minus != null then
                n_minus.parent = self
@@ -7431,6 +7754,7 @@ redef class ANewExpr
             n_args: Array[Object]  # Should be Array[PExpr]
     )
     do
+        empty_init
         _n_kwnew = n_kwnew
        if n_kwnew != null then
                n_kwnew.parent = self
@@ -7557,6 +7881,7 @@ redef class AAttrExpr
             n_id: TAttrid 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7651,6 +7976,7 @@ redef class AAttrAssignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7785,6 +8111,7 @@ redef class AAttrReassignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7901,9 +8228,11 @@ redef class ACallExpr
     init init_acallexpr (
             n_expr: PExpr ,
             n_id: TId ,
-            n_args: Array[Object]  # Should be Array[PExpr]
+            n_args: Array[Object] , # Should be Array[PExpr]
+            n_closure_defs: Array[Object]  # Should be Array[PClosureDef]
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -7918,6 +8247,12 @@ redef class ACallExpr
                _n_args.add(n)
                n.parent = self
        end
+        _n_closure_defs = new List[PClosureDef]
+       for n in n_closure_defs do
+               assert n isa PClosureDef
+               _n_closure_defs.add(n)
+               n.parent = self
+       end
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -7955,6 +8290,18 @@ redef class ACallExpr
                 return
             end
         end
+        for i in [0.._n_closure_defs.length[ do
+            if _n_closure_defs[i] == old_child then
+                if new_child != null then
+                   assert new_child isa PClosureDef
+                    _n_closure_defs[i] = new_child
+                    new_child.parent = self
+                else
+                    _n_closure_defs.remove_at(i)
+                end
+                return
+            end
+        end
     end
 
     redef meth visit_all(v: Visitor)
@@ -7968,6 +8315,9 @@ redef class ACallExpr
             for n in _n_args do
                 v.visit(n)
            end
+            for n in _n_closure_defs do
+                v.visit(n)
+           end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -7985,6 +8335,13 @@ redef class ACallExpr
                i = i - 1
            end
        end
+       do
+           var i = _n_closure_defs.length
+            while i >= 0 do
+                v.visit(_n_closure_defs[i])
+               i = i - 1
+           end
+       end
     end
 end
 redef class ACallAssignExpr
@@ -8027,6 +8384,7 @@ redef class ACallAssignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -8190,6 +8548,7 @@ redef class ACallReassignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -8337,6 +8696,7 @@ redef class ASuperExpr
             n_args: Array[Object]  # Should be Array[PExpr]
     )
     do
+        empty_init
         _n_qualified = n_qualified
        if n_qualified != null then
                n_qualified.parent = self
@@ -8444,6 +8804,7 @@ redef class AInitExpr
             n_args: Array[Object]  # Should be Array[PExpr]
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -8540,9 +8901,11 @@ redef class ABraExpr
 
     init init_abraexpr (
             n_expr: PExpr ,
-            n_args: Array[Object]  # Should be Array[PExpr]
+            n_args: Array[Object] , # Should be Array[PExpr]
+            n_closure_defs: Array[Object]  # Should be Array[PClosureDef]
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -8553,6 +8916,12 @@ redef class ABraExpr
                _n_args.add(n)
                n.parent = self
        end
+        _n_closure_defs = new List[PClosureDef]
+       for n in n_closure_defs do
+               assert n isa PClosureDef
+               _n_closure_defs.add(n)
+               n.parent = self
+       end
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -8580,6 +8949,18 @@ redef class ABraExpr
                 return
             end
         end
+        for i in [0.._n_closure_defs.length[ do
+            if _n_closure_defs[i] == old_child then
+                if new_child != null then
+                   assert new_child isa PClosureDef
+                    _n_closure_defs[i] = new_child
+                    new_child.parent = self
+                else
+                    _n_closure_defs.remove_at(i)
+                end
+                return
+            end
+        end
     end
 
     redef meth visit_all(v: Visitor)
@@ -8590,6 +8971,9 @@ redef class ABraExpr
             for n in _n_args do
                 v.visit(n)
            end
+            for n in _n_closure_defs do
+                v.visit(n)
+           end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -8604,6 +8988,13 @@ redef class ABraExpr
                i = i - 1
            end
        end
+       do
+           var i = _n_closure_defs.length
+            while i >= 0 do
+                v.visit(_n_closure_defs[i])
+               i = i - 1
+           end
+       end
     end
 end
 redef class ABraAssignExpr
@@ -8638,6 +9029,7 @@ redef class ABraAssignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -8773,6 +9165,7 @@ redef class ABraReassignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -8891,6 +9284,7 @@ redef class AVarExpr
             n_id: TId 
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -8957,6 +9351,7 @@ redef class AVarAssignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -9063,6 +9458,7 @@ redef class AVarReassignExpr
             n_value: PExpr 
     )
     do
+        empty_init
         _n_id = n_id
        if n_id != null then
                n_id.parent = self
@@ -9161,6 +9557,7 @@ redef class ARangeExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -9239,6 +9636,7 @@ redef class ACrangeExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -9317,6 +9715,7 @@ redef class AOrangeExpr
             n_expr2: PExpr 
     )
     do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
@@ -9380,6 +9779,7 @@ redef class AArrayExpr
             n_exprs: Array[Object]  # Should be Array[PExpr]
     )
     do
+        empty_init
         _n_exprs = new List[PExpr]
        for n in n_exprs do
                assert n isa PExpr
@@ -9438,6 +9838,7 @@ redef class ASelfExpr
             n_kwself: TKwself 
     )
     do
+        empty_init
         _n_kwself = n_kwself
        if n_kwself != null then
                n_kwself.parent = self
@@ -9479,6 +9880,7 @@ redef class AImplicitSelfExpr
 
     init init_aimplicitselfexpr
     do
+        empty_init
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -9509,6 +9911,7 @@ redef class ATrueExpr
             n_kwtrue: TKwtrue 
     )
     do
+        empty_init
         _n_kwtrue = n_kwtrue
        if n_kwtrue != null then
                n_kwtrue.parent = self
@@ -9559,6 +9962,7 @@ redef class AFalseExpr
             n_kwfalse: TKwfalse 
     )
     do
+        empty_init
         _n_kwfalse = n_kwfalse
        if n_kwfalse != null then
                n_kwfalse.parent = self
@@ -9609,6 +10013,7 @@ redef class ANullExpr
             n_kwnull: TKwnull 
     )
     do
+        empty_init
         _n_kwnull = n_kwnull
        if n_kwnull != null then
                n_kwnull.parent = self
@@ -9659,6 +10064,7 @@ redef class AIntExpr
             n_number: TNumber 
     )
     do
+        empty_init
         _n_number = n_number
        if n_number != null then
                n_number.parent = self
@@ -9709,6 +10115,7 @@ redef class AFloatExpr
             n_float: TFloat 
     )
     do
+        empty_init
         _n_float = n_float
        if n_float != null then
                n_float.parent = self
@@ -9759,6 +10166,7 @@ redef class ACharExpr
             n_char: TChar 
     )
     do
+        empty_init
         _n_char = n_char
        if n_char != null then
                n_char.parent = self
@@ -9809,6 +10217,7 @@ redef class AStringExpr
             n_string: TString 
     )
     do
+        empty_init
         _n_string = n_string
        if n_string != null then
                n_string.parent = self
@@ -9859,6 +10268,7 @@ redef class AStartStringExpr
             n_string: TStartString 
     )
     do
+        empty_init
         _n_string = n_string
        if n_string != null then
                n_string.parent = self
@@ -9909,6 +10319,7 @@ redef class AMidStringExpr
             n_string: TMidString 
     )
     do
+        empty_init
         _n_string = n_string
        if n_string != null then
                n_string.parent = self
@@ -9959,6 +10370,7 @@ redef class AEndStringExpr
             n_string: TEndString 
     )
     do
+        empty_init
         _n_string = n_string
        if n_string != null then
                n_string.parent = self
@@ -10002,6 +10414,7 @@ redef class ASuperstringExpr
             n_exprs: Array[Object]  # Should be Array[PExpr]
     )
     do
+        empty_init
         _n_exprs = new List[PExpr]
        for n in n_exprs do
                assert n isa PExpr
@@ -10060,10 +10473,86 @@ redef class AParExpr
             n_expr: PExpr 
     )
     do
+        empty_init
+        _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)
+    do
+        assert old_child != null
+        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)
+    do
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
+    end
+
+    redef meth visit_all_reverse(v: Visitor)
+    do
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
+    end
+end
+redef class AAsCastExpr
+    redef meth n_expr=(n: PExpr)
+    do
+        _n_expr = n
+        if n != null then
+           n.parent = self
+        end
+    end
+    redef meth n_kwas=(n: TKwas)
+    do
+        _n_kwas = n
+        if n != null then
+           n.parent = self
+        end
+    end
+    redef meth n_type=(n: PType)
+    do
+        _n_type = n
+        if n != null then
+           n.parent = self
+        end
+    end
+
+    private init empty_init do end
+
+    init init_aascastexpr (
+            n_expr: PExpr ,
+            n_kwas: TKwas ,
+            n_type: PType 
+    )
+    do
+        empty_init
         _n_expr = n_expr
        if n_expr != null then
                n_expr.parent = self
        end
+        _n_kwas = n_kwas
+       if n_kwas != null then
+               n_kwas.parent = self
+       end
+        _n_type = n_type
+       if n_type != null then
+               n_type.parent = self
+       end
     end
 
     redef meth replace_child(old_child: PNode, new_child: PNode)
@@ -10079,6 +10568,26 @@ redef class AParExpr
             end
             return
        end
+        if _n_kwas == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa TKwas
+                _n_kwas = new_child
+           else
+               _n_kwas = null
+            end
+            return
+       end
+        if _n_type == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa PType
+                _n_type = new_child
+           else
+               _n_type = null
+            end
+            return
+       end
     end
 
     redef meth visit_all(v: Visitor)
@@ -10086,6 +10595,12 @@ redef class AParExpr
         if _n_expr != null then
             v.visit(_n_expr)
         end
+        if _n_kwas != null then
+            v.visit(_n_kwas)
+        end
+        if _n_type != null then
+            v.visit(_n_type)
+        end
     end
 
     redef meth visit_all_reverse(v: Visitor)
@@ -10093,6 +10608,12 @@ redef class AParExpr
         if _n_expr != null then
             v.visit(_n_expr)
         end
+        if _n_kwas != null then
+            v.visit(_n_kwas)
+        end
+        if _n_type != null then
+            v.visit(_n_type)
+        end
     end
 end
 redef class APlusAssignOp
@@ -10110,6 +10631,7 @@ redef class APlusAssignOp
             n_pluseq: TPluseq 
     )
     do
+        empty_init
         _n_pluseq = n_pluseq
        if n_pluseq != null then
                n_pluseq.parent = self
@@ -10160,6 +10682,7 @@ redef class AMinusAssignOp
             n_minuseq: TMinuseq 
     )
     do
+        empty_init
         _n_minuseq = n_minuseq
        if n_minuseq != null then
                n_minuseq.parent = self
@@ -10195,6 +10718,142 @@ redef class AMinusAssignOp
         end
     end
 end
+redef class AClosureDef
+    redef meth n_kwwith=(n: TKwwith)
+    do
+        _n_kwwith = n
+        if n != null then
+           n.parent = self
+        end
+    end
+    redef meth n_kwdo=(n: TKwdo)
+    do
+        _n_kwdo = n
+        if n != null then
+           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
+
+    init init_aclosuredef (
+            n_kwwith: TKwwith ,
+            n_id: Array[Object] , # Should be Array[TId]
+            n_kwdo: TKwdo ,
+            n_expr: PExpr 
+    )
+    do
+        empty_init
+        _n_kwwith = n_kwwith
+       if n_kwwith != null then
+               n_kwwith.parent = self
+       end
+        _n_id = new List[TId]
+       for n in n_id do
+               assert n isa TId
+               _n_id.add(n)
+               n.parent = self
+       end
+        _n_kwdo = n_kwdo
+       if n_kwdo != null then
+               n_kwdo.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)
+    do
+        assert old_child != null
+        if _n_kwwith == old_child then
+            if new_child != null then
+                new_child.parent = self
+               assert new_child isa TKwwith
+                _n_kwwith = new_child
+           else
+               _n_kwwith = null
+            end
+            return
+       end
+        for i in [0.._n_id.length[ do
+            if _n_id[i] == old_child then
+                if new_child != null then
+                   assert new_child isa TId
+                    _n_id[i] = new_child
+                    new_child.parent = self
+                else
+                    _n_id.remove_at(i)
+                end
+                return
+            end
+        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_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)
+    do
+        if _n_kwwith != null then
+            v.visit(_n_kwwith)
+        end
+            for n in _n_id do
+                v.visit(n)
+           end
+        if _n_kwdo != null then
+            v.visit(_n_kwdo)
+        end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
+    end
+
+    redef meth visit_all_reverse(v: Visitor)
+    do
+        if _n_kwwith != null then
+            v.visit(_n_kwwith)
+        end
+       do
+           var i = _n_id.length
+            while i >= 0 do
+                v.visit(_n_id[i])
+               i = i - 1
+           end
+       end
+        if _n_kwdo != null then
+            v.visit(_n_kwdo)
+        end
+        if _n_expr != null then
+            v.visit(_n_expr)
+        end
+    end
+end
 redef class AQualified
     redef meth n_classid=(n: TClassid)
     do
@@ -10211,6 +10870,7 @@ redef class AQualified
             n_classid: TClassid 
     )
     do
+        empty_init
         _n_id = new List[TId]
        for n in n_id do
                assert n isa TId
@@ -10282,6 +10942,7 @@ redef class ADoc
             n_comment: Array[Object]  # Should be Array[TComment]
     )
     do
+        empty_init
         _n_comment = new List[TComment]
        for n in n_comment do
                assert n isa TComment