nitc :: ScopeVisitor :: get_escapemark
If a label is given, the escapemark of this label is returned.
If there is no label, the nearest escapemark that is for loop
is returned.
If there is no valid escapemark, then an error is displayed ans null is returned.
Return null if no such a label is found.
# Look for an escape mark optionally associated with a label.
# If a label is given, the escapemark of this label is returned.
# If there is no label, the nearest escapemark that is `for loop` is returned.
# If there is no valid escapemark, then an error is displayed ans null is returned.
# Return null if no such a label is found.
fun get_escapemark(node: ANode, nlabel: nullable ALabel): nullable EscapeMark
do
if nlabel != null then
var nid = nlabel.n_id
if nid == null then
var res = search_label("")
if res == null then
self.error(nlabel, "Syntax Error: invalid anonymous label.")
node.is_broken = true
return null
end
return res
end
var name = nid.text
var res = search_label(name)
if res == null then
self.error(nlabel, "Syntax Error: invalid label `{name}`.")
node.is_broken = true
return null
end
return res
else
for scope in scopes do
var res = scope.escapemark
if res != null then
return res
end
end
self.error(node, "Syntax Error: `break` statement outside block.")
return null
end
end
src/semantize/scope.nit:185,2--221,4