parser: node locations are not nullable
[nit.git] / src / parser / xss / nodes.xss
index 6d43485..d6df697 100644 (file)
@@ -18,7 +18,11 @@ $ // limitations under the License.
 $ template make_abs_nodes()
 # Root of the AST hierarchy
 abstract class PNode
-       readable var _location: nullable Location
+       var _location: nullable Location
+
+       # Location is set during AST building. Once built, location cannon be null
+       # However, manual instanciated nodes may need mode care
+       fun location: Location do return _location.as(not null)
 end
 
 # Ancestor of all tokens
@@ -29,7 +33,7 @@ end
 # Ancestor of all productions
 abstract class Prod
 special PNode
-       fun location=(loc: nullable Location) do _location = loc
+       fun location=(loc: Location) do _location = loc
 end
 $ end template
 
@@ -71,18 +75,10 @@ redef class Token
 end
 
 redef class Prod
-       # The first token of the production node
-       readable writable var _first_token: nullable Token
-
-       # The last token of the production node
-       readable writable var _last_token: nullable Token
-
        redef fun replace_with(n: PNode)
         do
                 super
                 assert n isa Prod
-                n.first_token = first_token
-                n.last_token = last_token
                 n.location = location
         end
 end