Each comment is recorded along with its starting line and column position. The CommentList class represents a series of comments, each stored as a Comment object. CommentStream is used to traverse a CommentList when a parse tree is being written out. It will dump out a series of comments up to a given line and column position, and is used to intersperse terminals and comments in the output. As the tree is printed, comments and whitespace are interspersed, meaning that the exact original program is reconstructed.
Annotation is especially useful when doing instrumentation.
Trees are equal if they have identical tree structure, all terminal nodes are identical, and the source code positions of each node are the same. The tree is walked in preorder order, that is, the node itself is visited first, and then its children are visited left to right. The constructor for FileWalker is given an array of Strings representing directories and files. Directories are walked in depth-first order. The tree is walked in preorder order, that is, the node itself is visited, followed by its children left to right.