nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Factorize common strings in generated C.
[nit.git]
/
src
/
parser
/
xss
/
nodes.xss
diff --git
a/src/parser/xss/nodes.xss
b/src/parser/xss/nodes.xss
index
3d59406
..
46cfafd
100644
(file)
--- a/
src/parser/xss/nodes.xss
+++ b/
src/parser/xss/nodes.xss
@@
-65,6
+65,9
@@
redef class PNode
# Give a human readable location of the node.
meth locate: String is abstract
# 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
# Debug method: output a message prefixed with the location.
meth printl(str: String)
do
@@
-81,6
+84,8
@@
redef class Token
do
return "{filename}:{line},{pos}"
end
do
return "{filename}:{line},{pos}"
end
+
+ redef meth line_number do return line
end
redef class Prod
end
redef class Prod
@@
-104,11
+109,20
@@
redef class Prod
end
redef meth replace_with(n: PNode)
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
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
end
end