From: Jean Privat Date: Thu, 22 Mar 2012 13:47:31 +0000 (-0400) Subject: parser: simplify constroctors of nodes X-Git-Tag: v0.5~6^2~10 X-Git-Url: http://nitlanguage.org parser: simplify constroctors of nodes in parser_nodes, ANode has an empty constructor inherited by all subclasses Signed-off-by: Jean Privat --- diff --git a/src/parser/parser_nodes.nit b/src/parser/parser_nodes.nit index 574e512..5e905e8 100644 --- a/src/parser/parser_nodes.nit +++ b/src/parser/parser_nodes.nit @@ -29,6 +29,7 @@ abstract class ANode fun location: Location do return _location.as(not null) # The location of the important part of the node (identifier or whatever) fun hot_location: Location do return location + init do end end # Ancestor of all tokens @@ -535,14 +536,12 @@ end class AConcreteInitPropdef super AConcreteMethPropdef super AInitPropdef - init do end readable var _n_kwinit: TKwinit redef fun hot_location do return n_kwinit.location end class AExternInitPropdef super AExternPropdef super AInitPropdef - init do end readable var _n_kwnew: TKwnew end class AMainMethPropdef @@ -1184,4 +1183,9 @@ class Start super Prod readable var _n_base: nullable AModule readable var _n_eof: EOF + init(n_base: nullable AModule, n_eof: EOF) + do + self._n_base = n_base + self._n_eof = n_eof + end end diff --git a/src/parser/parser_prod.nit b/src/parser/parser_prod.nit index 6899b21..d79eac9 100644 --- a/src/parser/parser_prod.nit +++ b/src/parser/parser_prod.nit @@ -8347,14 +8347,6 @@ redef class ADoc end redef class Start - init( - n_base: nullable AModule, - n_eof: EOF) - do - _n_base = n_base - _n_eof = n_eof - end - redef fun replace_child(old_child: ANode, new_child: nullable ANode) do if _n_base == old_child then diff --git a/src/parser/xss/prods.xss b/src/parser/xss/prods.xss index 9f2b330..45a6868 100644 --- a/src/parser/xss/prods.xss +++ b/src/parser/xss/prods.xss @@ -43,6 +43,14 @@ class Start super Prod readable var _n_base: nullable $baseprod readable var _n_eof: EOF + init( + n_base: nullable $baseprod, + n_eof: EOF) + do + _n_base = n_base + _n_eof = n_eof + end + end $ end template @@ -145,14 +153,6 @@ end $ end foreach redef class Start - init( - n_base: nullable $baseprod, - n_eof: EOF) - do - _n_base = n_base - _n_eof = n_eof - end - redef fun replace_child(old_child: PNode, new_child: nullable PNode) do if _n_base == old_child then