X-Git-Url: http://nitlanguage.org diff --git a/src/parser/parser_prod.nit b/src/parser/parser_prod.nit index e356c4c..847a005 100644 --- a/src/parser/parser_prod.nit +++ b/src/parser/parser_prod.nit @@ -4,6 +4,7 @@ package parser_prod import lexer intrude import parser_nodes +private import tables redef class ANode # Parent of the node in the AST @@ -70,15 +71,15 @@ redef class AModule private init empty_init do end init init_amodule ( - n_packagedecl: nullable APackagedecl, + n_moduledecl: nullable AModuledecl, n_imports: Collection[Object], # Should be Collection[AImport] n_classdefs: Collection[Object] # Should be Collection[AClassdef] ) do empty_init - _n_packagedecl = n_packagedecl - if n_packagedecl != null then - n_packagedecl.parent = self + _n_moduledecl = n_moduledecl + if n_moduledecl != null then + n_moduledecl.parent = self end for n in n_imports do assert n isa AImport @@ -94,13 +95,13 @@ redef class AModule redef fun replace_child(old_child: ANode, new_child: nullable ANode) do - if _n_packagedecl == old_child then + if _n_moduledecl == old_child then if new_child != null then new_child.parent = self - assert new_child isa APackagedecl - _n_packagedecl = new_child + assert new_child isa AModuledecl + _n_moduledecl = new_child else - _n_packagedecl = null + _n_moduledecl = null end return end @@ -132,8 +133,8 @@ redef class AModule redef fun visit_all(v: Visitor) do - if _n_packagedecl != null then - v.enter_visit(_n_packagedecl.as(not null)) + if _n_moduledecl != null then + v.enter_visit(_n_moduledecl.as(not null)) end for n in _n_imports do v.enter_visit(n) @@ -143,12 +144,12 @@ redef class AModule end end end -redef class APackagedecl +redef class AModuledecl private init empty_init do end - init init_apackagedecl ( + init init_amoduledecl ( n_doc: nullable ADoc, - n_kwpackage: nullable TKwpackage, + n_kwmodule: nullable TKwmodule, n_id: nullable TId ) do @@ -157,8 +158,8 @@ redef class APackagedecl if n_doc != null then n_doc.parent = self end - _n_kwpackage = n_kwpackage.as(not null) - n_kwpackage.parent = self + _n_kwmodule = n_kwmodule.as(not null) + n_kwmodule.parent = self _n_id = n_id.as(not null) n_id.parent = self end @@ -175,11 +176,11 @@ redef class APackagedecl end return end - if _n_kwpackage == old_child then + if _n_kwmodule == old_child then if new_child != null then new_child.parent = self - assert new_child isa TKwpackage - _n_kwpackage = new_child + assert new_child isa TKwmodule + _n_kwmodule = new_child else abort end @@ -202,7 +203,7 @@ redef class APackagedecl if _n_doc != null then v.enter_visit(_n_doc.as(not null)) end - v.enter_visit(_n_kwpackage) + v.enter_visit(_n_kwmodule) v.enter_visit(_n_id) end end @@ -778,25 +779,25 @@ redef class AInterfaceClasskind v.enter_visit(_n_kwinterface) end end -redef class AUniversalClasskind +redef class AEnumClasskind private init empty_init do end - init init_auniversalclasskind ( - n_kwuniversal: nullable TKwuniversal + init init_aenumclasskind ( + n_kwenum: nullable TKwenum ) do empty_init - _n_kwuniversal = n_kwuniversal.as(not null) - n_kwuniversal.parent = self + _n_kwenum = n_kwenum.as(not null) + n_kwenum.parent = self end redef fun replace_child(old_child: ANode, new_child: nullable ANode) do - if _n_kwuniversal == old_child then + if _n_kwenum == old_child then if new_child != null then new_child.parent = self - assert new_child isa TKwuniversal - _n_kwuniversal = new_child + assert new_child isa TKwenum + _n_kwenum = new_child else abort end @@ -806,7 +807,7 @@ redef class AUniversalClasskind redef fun visit_all(v: Visitor) do - v.enter_visit(_n_kwuniversal) + v.enter_visit(_n_kwenum) end end redef class AFormaldef @@ -863,12 +864,19 @@ redef class ASuperclass init init_asuperclass ( n_kwspecial: nullable TKwspecial, + n_kwsuper: nullable TKwsuper, n_type: nullable AType ) do empty_init - _n_kwspecial = n_kwspecial.as(not null) - n_kwspecial.parent = self + _n_kwspecial = n_kwspecial + if n_kwspecial != null then + n_kwspecial.parent = self + end + _n_kwsuper = n_kwsuper + if n_kwsuper != null then + n_kwsuper.parent = self + end _n_type = n_type.as(not null) n_type.parent = self end @@ -881,7 +889,17 @@ redef class ASuperclass assert new_child isa TKwspecial _n_kwspecial = new_child else - abort + _n_kwspecial = null + end + return + end + if _n_kwsuper == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa TKwsuper + _n_kwsuper = new_child + else + _n_kwsuper = null end return end @@ -899,7 +917,12 @@ redef class ASuperclass redef fun visit_all(v: Visitor) do - v.enter_visit(_n_kwspecial) + if _n_kwspecial != null then + v.enter_visit(_n_kwspecial.as(not null)) + end + if _n_kwsuper != null then + v.enter_visit(_n_kwsuper.as(not null)) + end v.enter_visit(_n_type) end end @@ -914,6 +937,7 @@ redef class AAttrPropdef n_visibility: nullable AVisibility, n_kwvar: nullable TKwvar, n_id: nullable TAttrid, + n_id2: nullable TId, n_type: nullable AType, n_expr: nullable AExpr ) @@ -939,8 +963,14 @@ redef class AAttrPropdef n_visibility.parent = self _n_kwvar = n_kwvar.as(not null) n_kwvar.parent = self - _n_id = n_id.as(not null) - n_id.parent = self + _n_id = n_id + if n_id != null then + n_id.parent = self + end + _n_id2 = n_id2 + if n_id2 != null then + n_id2.parent = self + end _n_type = n_type if n_type != null then n_type.parent = self @@ -1019,7 +1049,17 @@ redef class AAttrPropdef assert new_child isa TAttrid _n_id = new_child else - abort + _n_id = null + end + return + end + if _n_id2 == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa TId + _n_id2 = new_child + else + _n_id2 = null end return end @@ -1061,7 +1101,12 @@ redef class AAttrPropdef end v.enter_visit(_n_visibility) v.enter_visit(_n_kwvar) - v.enter_visit(_n_id) + if _n_id != null then + v.enter_visit(_n_id.as(not null)) + end + if _n_id2 != null then + v.enter_visit(_n_id2.as(not null)) + end if _n_type != null then v.enter_visit(_n_type.as(not null)) end @@ -1984,6 +2029,7 @@ redef class AWriteAble init init_awriteable ( n_kwredef: nullable TKwredef, + n_visibility: nullable AVisibility, n_kwwritable: nullable TKwwritable ) do @@ -1992,6 +2038,10 @@ redef class AWriteAble if n_kwredef != null then n_kwredef.parent = self end + _n_visibility = n_visibility + if n_visibility != null then + n_visibility.parent = self + end _n_kwwritable = n_kwwritable.as(not null) n_kwwritable.parent = self end @@ -2008,6 +2058,16 @@ redef class AWriteAble end return end + if _n_visibility == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa AVisibility + _n_visibility = new_child + else + _n_visibility = null + end + return + end if _n_kwwritable == old_child then if new_child != null then new_child.parent = self @@ -2025,6 +2085,9 @@ redef class AWriteAble if _n_kwredef != null then v.enter_visit(_n_kwredef.as(not null)) end + if _n_visibility != null then + v.enter_visit(_n_visibility.as(not null)) + end v.enter_visit(_n_kwwritable) end end @@ -2400,6 +2463,68 @@ redef class AGtMethid v.enter_visit(_n_gt) end end +redef class ALlMethid + private init empty_init do end + + init init_allmethid ( + n_ll: nullable TLl + ) + do + empty_init + _n_ll = n_ll.as(not null) + n_ll.parent = self + end + + redef fun replace_child(old_child: ANode, new_child: nullable ANode) + do + if _n_ll == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa TLl + _n_ll = new_child + else + abort + end + return + end + end + + redef fun visit_all(v: Visitor) + do + v.enter_visit(_n_ll) + end +end +redef class AGgMethid + private init empty_init do end + + init init_aggmethid ( + n_gg: nullable TGg + ) + do + empty_init + _n_gg = n_gg.as(not null) + n_gg.parent = self + end + + redef fun replace_child(old_child: ANode, new_child: nullable ANode) + do + if _n_gg == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa TGg + _n_gg = new_child + else + abort + end + return + end + end + + redef fun visit_all(v: Visitor) + do + v.enter_visit(_n_gg) + end +end redef class ABraMethid private init empty_init do end @@ -4105,6 +4230,51 @@ redef class AAndExpr v.enter_visit(_n_expr2) end end +redef class AOrElseExpr + private init empty_init do end + + init init_aorelseexpr ( + n_expr: nullable AExpr, + n_expr2: nullable AExpr + ) + do + empty_init + _n_expr = n_expr.as(not null) + n_expr.parent = self + _n_expr2 = n_expr2.as(not null) + n_expr2.parent = self + end + + redef fun replace_child(old_child: ANode, new_child: nullable ANode) + do + if _n_expr == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa AExpr + _n_expr = new_child + else + abort + end + return + end + if _n_expr2 == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa AExpr + _n_expr2 = new_child + else + abort + end + return + end + end + + redef fun visit_all(v: Visitor) + do + v.enter_visit(_n_expr) + v.enter_visit(_n_expr2) + end +end redef class ANotExpr private init empty_init do end @@ -4375,6 +4545,51 @@ redef class ALeExpr v.enter_visit(_n_expr2) end end +redef class ALlExpr + private init empty_init do end + + init init_allexpr ( + n_expr: nullable AExpr, + n_expr2: nullable AExpr + ) + do + empty_init + _n_expr = n_expr.as(not null) + n_expr.parent = self + _n_expr2 = n_expr2.as(not null) + n_expr2.parent = self + end + + redef fun replace_child(old_child: ANode, new_child: nullable ANode) + do + if _n_expr == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa AExpr + _n_expr = new_child + else + abort + end + return + end + if _n_expr2 == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa AExpr + _n_expr2 = new_child + else + abort + end + return + end + end + + redef fun visit_all(v: Visitor) + do + v.enter_visit(_n_expr) + v.enter_visit(_n_expr2) + end +end redef class AGtExpr private init empty_init do end @@ -4465,6 +4680,51 @@ redef class AGeExpr v.enter_visit(_n_expr2) end end +redef class AGgExpr + private init empty_init do end + + init init_aggexpr ( + n_expr: nullable AExpr, + n_expr2: nullable AExpr + ) + do + empty_init + _n_expr = n_expr.as(not null) + n_expr.parent = self + _n_expr2 = n_expr2.as(not null) + n_expr2.parent = self + end + + redef fun replace_child(old_child: ANode, new_child: nullable ANode) + do + if _n_expr == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa AExpr + _n_expr = new_child + else + abort + end + return + end + if _n_expr2 == old_child then + if new_child != null then + new_child.parent = self + assert new_child isa AExpr + _n_expr2 = new_child + else + abort + end + return + end + end + + redef fun visit_all(v: Visitor) + do + v.enter_visit(_n_expr) + v.enter_visit(_n_expr2) + end +end redef class AIsaExpr private init empty_init do end