Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » ASTNode start()/end() invariants
ASTNode start()/end() invariants [message #901998] Wed, 15 August 2012 12:54
Jens von Pilgrim is currently offline Jens von Pilgrim
Messages: 294
Registered: July 2009
Senior Member
Hi,

I'm wondering about certain invariants concerning the ranges of an
ASTNode. I'm not sure whether they are supposed to hold (in all
cases/languages) or not. I would say that they should hold for languages
such as Java, but I'm not sure whether there are some languages out
there for which they cannot hold.

For a given ASTNode n, the following invariants could be defined

1) n.start()<=n.end()
2) n.getChilds().contains(c) -> c.start()>=n.start() && c.end()<=n.end()
3) n.getChilds().contains(c1) && n.getChilds().contains(c2) && c1!=c2
-> c1.end()<c2.start() || c2.end()<c1.start()

Invariant 1) is simple, but does it hold for ASTNodes in all cases?

Invariant 2) states that a child's range is to be contained in its
parent's range. However, this is not true e.g., in case of invalid parse
trees, e.g., due to parse errors.

Invariant 3) states that the ranges of two children must not overlap
(assuming inv. 1) holds). But I'm not sure whether this holds for all nodes.

Inv. 2) and 3) would enable more efficient searches in the AST using a
given position, as one would not have to search all children.

Cheers,
Jens
Previous Topic:DLTK API Javadoc???
Next Topic:DLTK indexing
Goto Forum:
  


Current Time: Sun Sep 21 20:14:13 GMT 2014

Powered by FUDForum. Page generated in 0.01682 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software