nitc: add Location::get_line
[nit.git] / src / parser / parser_prod.nit
index 9f2d4f2..0e5b1e3 100644 (file)
@@ -386,7 +386,7 @@ redef class AStdClassdef
                n_kwredef: nullable TKwredef,
                n_visibility: nullable AVisibility,
                n_classkind: nullable AClasskind,
-               n_id: nullable TClassid,
+               n_qid: nullable AQclassid,
                n_obra: nullable TObra,
                n_formaldefs: Collection[Object], # Should be Collection[AFormaldef]
                n_cbra: nullable TCbra,
@@ -403,8 +403,8 @@ redef class AStdClassdef
                n_visibility.parent = self
                _n_classkind = n_classkind.as(not null)
                n_classkind.parent = self
-               _n_id = n_id
-               if n_id != null then n_id.parent = self
+               _n_qid = n_qid
+               if n_qid != null then n_qid.parent = self
                _n_obra = n_obra
                if n_obra != null then n_obra.parent = self
                self.n_formaldefs.unsafe_add_all(n_formaldefs)
@@ -435,8 +435,8 @@ redef class AStdClassdef
                        n_classkind = new_child.as(AClasskind)
                        return
                end
-               if _n_id == old_child then
-                       n_id = new_child.as(nullable TClassid)
+               if _n_qid == old_child then
+                       n_qid = new_child.as(nullable AQclassid)
                        return
                end
                if _n_obra == old_child then
@@ -479,9 +479,9 @@ redef class AStdClassdef
                _n_classkind = node
                node.parent = self
        end
-       redef fun n_id=(node)
+       redef fun n_qid=(node)
        do
-               _n_id = node
+               _n_qid = node
                if node != null then node.parent = self
        end
        redef fun n_obra=(node)
@@ -512,7 +512,7 @@ redef class AStdClassdef
                v.enter_visit(_n_kwredef)
                v.enter_visit(_n_visibility)
                v.enter_visit(_n_classkind)
-               v.enter_visit(_n_id)
+               v.enter_visit(_n_qid)
                v.enter_visit(_n_obra)
                n_formaldefs.visit_all(v)
                v.enter_visit(_n_cbra)
@@ -1007,7 +1007,7 @@ redef class ATypePropdef
                n_kwredef: nullable TKwredef,
                n_visibility: nullable AVisibility,
                n_kwtype: nullable TKwtype,
-               n_id: nullable TClassid,
+               n_qid: nullable AQclassid,
                n_type: nullable AType,
                n_annotations: nullable AAnnotations
        )
@@ -1020,8 +1020,8 @@ redef class ATypePropdef
                n_visibility.parent = self
                _n_kwtype = n_kwtype.as(not null)
                n_kwtype.parent = self
-               _n_id = n_id.as(not null)
-               n_id.parent = self
+               _n_qid = n_qid.as(not null)
+               n_qid.parent = self
                _n_type = n_type.as(not null)
                n_type.parent = self
                _n_annotations = n_annotations
@@ -1046,8 +1046,8 @@ redef class ATypePropdef
                        n_kwtype = new_child.as(TKwtype)
                        return
                end
-               if _n_id == old_child then
-                       n_id = new_child.as(TClassid)
+               if _n_qid == old_child then
+                       n_qid = new_child.as(AQclassid)
                        return
                end
                if _n_type == old_child then
@@ -1080,9 +1080,9 @@ redef class ATypePropdef
                _n_kwtype = node
                node.parent = self
        end
-       redef fun n_id=(node)
+       redef fun n_qid=(node)
        do
-               _n_id = node
+               _n_qid = node
                node.parent = self
        end
        redef fun n_type=(node)
@@ -1103,7 +1103,7 @@ redef class ATypePropdef
                v.enter_visit(_n_kwredef)
                v.enter_visit(_n_visibility)
                v.enter_visit(_n_kwtype)
-               v.enter_visit(_n_id)
+               v.enter_visit(_n_qid)
                v.enter_visit(_n_type)
                v.enter_visit(_n_annotations)
        end
@@ -2272,6 +2272,48 @@ redef class AQid
                v.enter_visit(_n_id)
        end
 end
+redef class AQclassid
+       init init_aqclassid (
+               n_qualified: nullable AQualified,
+               n_id: nullable TClassid
+       )
+       do
+               _n_qualified = n_qualified
+               if n_qualified != null then n_qualified.parent = self
+               _n_id = n_id.as(not null)
+               n_id.parent = self
+       end
+
+       redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+       do
+               if _n_qualified == old_child then
+                       n_qualified = new_child.as(nullable AQualified)
+                       return
+               end
+               if _n_id == old_child then
+                       n_id = new_child.as(TClassid)
+                       return
+               end
+       end
+
+       redef fun n_qualified=(node)
+       do
+               _n_qualified = node
+               if node != null then node.parent = self
+       end
+       redef fun n_id=(node)
+       do
+               _n_id = node
+               node.parent = self
+       end
+
+
+       redef fun visit_all(v: Visitor)
+       do
+               v.enter_visit(_n_qualified)
+               v.enter_visit(_n_id)
+       end
+end
 redef class ASignature
        init init_asignature (
                n_opar: nullable TOpar,
@@ -2402,7 +2444,7 @@ end
 redef class AType
        init init_atype (
                n_kwnullable: nullable TKwnullable,
-               n_id: nullable TClassid,
+               n_qid: nullable AQclassid,
                n_obra: nullable TObra,
                n_types: Collection[Object], # Should be Collection[AType]
                n_cbra: nullable TCbra,
@@ -2411,8 +2453,8 @@ redef class AType
        do
                _n_kwnullable = n_kwnullable
                if n_kwnullable != null then n_kwnullable.parent = self
-               _n_id = n_id.as(not null)
-               n_id.parent = self
+               _n_qid = n_qid.as(not null)
+               n_qid.parent = self
                _n_obra = n_obra
                if n_obra != null then n_obra.parent = self
                self.n_types.unsafe_add_all(n_types)
@@ -2428,8 +2470,8 @@ redef class AType
                        n_kwnullable = new_child.as(nullable TKwnullable)
                        return
                end
-               if _n_id == old_child then
-                       n_id = new_child.as(TClassid)
+               if _n_qid == old_child then
+                       n_qid = new_child.as(AQclassid)
                        return
                end
                if _n_obra == old_child then
@@ -2452,9 +2494,9 @@ redef class AType
                _n_kwnullable = node
                if node != null then node.parent = self
        end
-       redef fun n_id=(node)
+       redef fun n_qid=(node)
        do
-               _n_id = node
+               _n_qid = node
                node.parent = self
        end
        redef fun n_obra=(node)
@@ -2477,7 +2519,7 @@ redef class AType
        redef fun visit_all(v: Visitor)
        do
                v.enter_visit(_n_kwnullable)
-               v.enter_visit(_n_id)
+               v.enter_visit(_n_qid)
                v.enter_visit(_n_obra)
                n_types.visit_all(v)
                v.enter_visit(_n_cbra)
@@ -2695,6 +2737,48 @@ redef class AReturnExpr
                v.enter_visit(_n_expr)
        end
 end
+redef class AYieldExpr
+       init init_ayieldexpr (
+               n_kwyield: nullable TKwyield,
+               n_expr: nullable AExpr
+       )
+       do
+               _n_kwyield = n_kwyield.as(not null)
+               n_kwyield.parent = self
+               _n_expr = n_expr.as(not null)
+               n_expr.parent = self
+       end
+
+       redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+       do
+               if _n_kwyield == old_child then
+                       n_kwyield = new_child.as(TKwyield)
+                       return
+               end
+               if _n_expr == old_child then
+                       n_expr = new_child.as(AExpr)
+                       return
+               end
+       end
+
+       redef fun n_kwyield=(node)
+       do
+               _n_kwyield = node
+               node.parent = self
+       end
+       redef fun n_expr=(node)
+       do
+               _n_expr = node
+               node.parent = self
+       end
+
+
+       redef fun visit_all(v: Visitor)
+       do
+               v.enter_visit(_n_kwyield)
+               v.enter_visit(_n_expr)
+       end
+end
 redef class ABreakExpr
        init init_abreakexpr (
                n_kwbreak: nullable TKwbreak,
@@ -2812,6 +2896,8 @@ redef class ADoExpr
        init init_adoexpr (
                n_kwdo: nullable TKwdo,
                n_block: nullable AExpr,
+               n_kwcatch: nullable TKwcatch,
+               n_catch: nullable AExpr,
                n_label: nullable ALabel
        )
        do
@@ -2819,6 +2905,10 @@ redef class ADoExpr
                n_kwdo.parent = self
                _n_block = n_block
                if n_block != null then n_block.parent = self
+               _n_kwcatch = n_kwcatch
+               if n_kwcatch != null then n_kwcatch.parent = self
+               _n_catch = n_catch
+               if n_catch != null then n_catch.parent = self
                _n_label = n_label
                if n_label != null then n_label.parent = self
        end
@@ -2833,6 +2923,14 @@ redef class ADoExpr
                        n_block = new_child.as(nullable AExpr)
                        return
                end
+               if _n_kwcatch == old_child then
+                       n_kwcatch = new_child.as(nullable TKwcatch)
+                       return
+               end
+               if _n_catch == old_child then
+                       n_catch = new_child.as(nullable AExpr)
+                       return
+               end
                if _n_label == old_child then
                        n_label = new_child.as(nullable ALabel)
                        return
@@ -2849,6 +2947,16 @@ redef class ADoExpr
                _n_block = node
                if node != null then node.parent = self
        end
+       redef fun n_kwcatch=(node)
+       do
+               _n_kwcatch = node
+               if node != null then node.parent = self
+       end
+       redef fun n_catch=(node)
+       do
+               _n_catch = node
+               if node != null then node.parent = self
+       end
        redef fun n_label=(node)
        do
                _n_label = node
@@ -2860,6 +2968,8 @@ redef class ADoExpr
        do
                v.enter_visit(_n_kwdo)
                v.enter_visit(_n_block)
+               v.enter_visit(_n_kwcatch)
+               v.enter_visit(_n_catch)
                v.enter_visit(_n_label)
        end
 end
@@ -3190,9 +3300,7 @@ end
 redef class AForExpr
        init init_aforexpr (
                n_kwfor: nullable TKwfor,
-               n_ids: Collection[Object], # Should be Collection[TId]
-               n_kwin: nullable TKwin,
-               n_expr: nullable AExpr,
+               n_groups: Collection[Object], # Should be Collection[AForGroup]
                n_kwdo: nullable TKwdo,
                n_block: nullable AExpr,
                n_label: nullable ALabel
@@ -3200,11 +3308,7 @@ redef class AForExpr
        do
                _n_kwfor = n_kwfor.as(not null)
                n_kwfor.parent = self
-               self.n_ids.unsafe_add_all(n_ids)
-               _n_kwin = n_kwin.as(not null)
-               n_kwin.parent = self
-               _n_expr = n_expr.as(not null)
-               n_expr.parent = self
+               self.n_groups.unsafe_add_all(n_groups)
                _n_kwdo = n_kwdo.as(not null)
                n_kwdo.parent = self
                _n_block = n_block
@@ -3219,15 +3323,7 @@ redef class AForExpr
                        n_kwfor = new_child.as(TKwfor)
                        return
                end
-               if n_ids.replace_child(old_child, new_child) then return
-               if _n_kwin == old_child then
-                       n_kwin = new_child.as(TKwin)
-                       return
-               end
-               if _n_expr == old_child then
-                       n_expr = new_child.as(AExpr)
-                       return
-               end
+               if n_groups.replace_child(old_child, new_child) then return
                if _n_kwdo == old_child then
                        n_kwdo = new_child.as(TKwdo)
                        return
@@ -3247,16 +3343,6 @@ redef class AForExpr
                _n_kwfor = node
                node.parent = self
        end
-       redef fun n_kwin=(node)
-       do
-               _n_kwin = node
-               node.parent = self
-       end
-       redef fun n_expr=(node)
-       do
-               _n_expr = node
-               node.parent = self
-       end
        redef fun n_kwdo=(node)
        do
                _n_kwdo = node
@@ -3277,9 +3363,7 @@ redef class AForExpr
        redef fun visit_all(v: Visitor)
        do
                v.enter_visit(_n_kwfor)
-               n_ids.visit_all(v)
-               v.enter_visit(_n_kwin)
-               v.enter_visit(_n_expr)
+               n_groups.visit_all(v)
                v.enter_visit(_n_kwdo)
                v.enter_visit(_n_block)
                v.enter_visit(_n_label)
@@ -7696,6 +7780,52 @@ redef class AGgAssignOp
                v.enter_visit(_n_op)
        end
 end
+redef class AForGroup
+       init init_aforgroup (
+               n_ids: Collection[Object], # Should be Collection[TId]
+               n_kwin: nullable TKwin,
+               n_expr: nullable AExpr
+       )
+       do
+               self.n_ids.unsafe_add_all(n_ids)
+               _n_kwin = n_kwin.as(not null)
+               n_kwin.parent = self
+               _n_expr = n_expr.as(not null)
+               n_expr.parent = self
+       end
+
+       redef fun replace_child(old_child: ANode, new_child: nullable ANode)
+       do
+               if n_ids.replace_child(old_child, new_child) then return
+               if _n_kwin == old_child then
+                       n_kwin = new_child.as(TKwin)
+                       return
+               end
+               if _n_expr == old_child then
+                       n_expr = new_child.as(AExpr)
+                       return
+               end
+       end
+
+       redef fun n_kwin=(node)
+       do
+               _n_kwin = node
+               node.parent = self
+       end
+       redef fun n_expr=(node)
+       do
+               _n_expr = node
+               node.parent = self
+       end
+
+
+       redef fun visit_all(v: Visitor)
+       do
+               n_ids.visit_all(v)
+               v.enter_visit(_n_kwin)
+               v.enter_visit(_n_expr)
+       end
+end
 redef class AModuleName
        init init_amodulename (
                n_quad: nullable TQuad,