# Give a human readable location of the node.
meth locate: String is abstract
+ # Return only the line number of the node
+ meth line_number: Int is abstract
+
# Debug method: output a message prefixed with the location.
meth printl(str: String)
do
do
return "{filename}:{line},{pos}"
end
+
+ redef meth line_number do return line
end
redef class Prod
if first_token == null then
return "????"
end
+ if last_token == null then
+ return "{first_token.locate}--????"
+ end
var lastpos = last_token.pos + last_token.text.length - 1
if first_token.line == last_token.line then
return "{first_token.locate}--{lastpos}"
end
redef meth replace_with(n: PNode)
+ do
+ super
+ assert n isa Prod
+ n.first_token = first_token
+ n.last_token = last_token
+ end
+
+ redef meth line_number
do
- super
- assert n isa Prod
- n.first_token = first_token
- n.last_token = last_token
+ if first_token != null then
+ return first_token.line
+ else
+ return 0
+ end
end
end