end
v.seen.add(self)
- if _location == null then
+ if not isset _location then
#debug "LOCATION: unlocated node {v.path.join(", ")}"
_location = self.parent.location
end
# Root of the AST class-hierarchy
abstract class ANode
- var _location: nullable Location = null
-
# Location is set during AST building. Once built, location cannon be null.
# However, manual instantiated nodes may need more care.
- fun location: Location do return _location.as(not null)
+ var location: Location is writable, noinit
# The location of the important part of the node (identifier or whatever)
fun hot_location: Location do return location
abstract class Prod
super ANode
- fun location=(l: Location) do _location = l
-
# All the annotations attached directly to the node
var _n_annotations: nullable AAnnotations = null
fun n_annotations: nullable AAnnotations do return _n_annotations
do
super
assert n isa Prod
- if n._location == null then n._location = _location
+ if not isset n._location and isset _location then n._location = _location
end
end
return node
else if action_type == 3 then # ERROR
# skip injected tokens
- while token._location == null do token = lexer.next
+ while not isset token._location do token = lexer.next
var node2 = new AParserError.init_parser_error("Syntax error: unexpected {token}.", token.location, token)
var node = new Start(null, node2)
return node
redef fun visit(n: ANode)
do
if n isa Token then
+ if not isset n._location then return
var loc = n._location
- if loc == null then return
_last_location = loc
# Add a first token to productions that need one