nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nitunit: can work with markdown files in parameters
[nit.git]
/
src
/
astvalidation.nit
diff --git
a/src/astvalidation.nit
b/src/astvalidation.nit
index
a3c4bbc
..
b34d42f
100644
(file)
--- a/
src/astvalidation.nit
+++ b/
src/astvalidation.nit
@@
-15,7
+15,6
@@
# Check the consitency of AST
module astvalidation
# Check the consitency of AST
module astvalidation
-private import typing
intrude import parser
import astbuilder
intrude import parser
import astbuilder
@@
-23,9
+22,7
@@
class ASTValidationVisitor
super Visitor
redef fun visit(node)
do
super Visitor
redef fun visit(node)
do
- path.unshift(node)
node.accept_ast_validation(self)
node.accept_ast_validation(self)
- path.shift
end
private var path = new List[ANode]
private var seen = new HashSet[ANode]
end
private var path = new List[ANode]
private var seen = new HashSet[ANode]
@@
-35,33
+32,37
@@
redef class ANode
private fun accept_ast_validation(v: ASTValidationVisitor)
do
var parent = self.parent
private fun accept_ast_validation(v: ASTValidationVisitor)
do
var parent = self.parent
+ var path = v.path
- if v.path.length > 1 then
- var path_parent = v.path[1]
+ if path.length > 0 then
+ var path_parent = v.path.first
if parent == null then
self.parent = path_parent
#debug "PARENT: expected parent: {path_parent}"
if parent == null then
self.parent = path_parent
#debug "PARENT: expected parent: {path_parent}"
+ v.seen.add(self)
else if parent != path_parent then
self.parent = path_parent
else if parent != path_parent then
self.parent = path_parent
- debug "PARENT: expected parent: {path_parent}, got {parent}"
+ if v.seen.has(self) then
+ debug "DUPLICATE (NOTATREE): already seen node with parent {parent} now with {path_parent}."
+ else
+ v.seen.add(self)
+ debug "PARENT: expected parent: {path_parent}, got {parent}"
+ end
end
end
end
end
- if v.seen.has(self) then
- debug "DUPLICATE: already seen node. NOTATREE"
- end
- v.seen.add(self)
-
if not isset _location then
#debug "LOCATION: unlocated node {v.path.join(", ")}"
_location = self.parent.location
end
if not isset _location then
#debug "LOCATION: unlocated node {v.path.join(", ")}"
_location = self.parent.location
end
+ path.unshift(self)
visit_all(v)
visit_all(v)
+ path.shift
end
end
end
end
-redef class AAnnotations
+redef class AAnnotation
redef fun accept_ast_validation(v)
do
# Do not enter in annotations
redef fun accept_ast_validation(v)
do
# Do not enter in annotations