Introduction
The
Traversal Language for
FST Modifications was designed in the context of an
extension for the
FSTComposer (a composition tool for feature-based
software creation).
Modification is an alternative way to represent features. This
representation is in need of a traversal language for FSTs whose
purpose is to travers a given FST and return a certain set of nodes by means
of a plain text string.
top
Syntax
As mentioned above, traversals for our language consist of plain text
strings. There are a few basics you should know about FSTs:
- FSTs consist of Nodes
- Nodes have at a name and
a type
- Notation is name:type
For a quicker understanding the following explanation is done mostly
exemplary:
- On top the example traversal
- Below explanations
- The FST (mostly extracts): blue nodes are the
traversed ones on the bottom
The used code-artifacts are part of the GPL:
Node.java,
Edge.java,
Graph.java
An FST for the whole composition can be found here (
svg |
jpg).
top
Simple
traversals
Test:Feature.Node:Java-File.Node:CompilationUnit
As you can see the tree-walk of this simple traversal is done by
concatenating the path-elements, i.e. the FSTNodes and placing a
special separation-character in between, wich is a '.'
top
Address
Wildcards
..Node:CompilationUnit
You have the possibility to use a wildcard for a certain part of the
address.
..-:PackageDeclaration
The wildcard is a representation for
all
possible addresses from a certain point on, which is focused in the
image above.
top
String
Wildcards
..Graph:ClassDeclaration.*:MethodDecl
As you can see here there is also a wildcard for the Strings in name
and type represented by a '*' (The semantic meaning here is to traversal
all Nodes representing a method in a certain Class).
..Graph:ClassDeclaration.Vector*:MethodDecl
You can combine normal Strings arbitrary with this wildcard.
top
Special
Characters
Test:Feature.Node%s.%ejava:Java-File.Node:CompilationUnit
The point in 'Node.java' has to be treated separately since the '.' has
a special semantic meaning in this language. There are a few other
characters like this one: space ' ',wildcards '*' and '..' to mention
some of them. While using this characters in a name or type-string you
have to put them in the verbal environment for a correct interpretation.
%s<verbalString>%e
top
Operators
If you want to travers more complex patterns you can combine your
independent traversals with operators. The references represented by the traversals containing no operators are treated as sets, i.e. they're duplicate free.
OR
..Graph:ClassDeclaration.*:MethodDecl
|| ..Graph:ClassDeclaration.*:FieldDecl
The or operator is identical to the sets' union operator.
top
MINUS
..Graph:ClassDeclaration.*:* --
..Graph:ClassDeclaration.*:FieldDecl
The minus operator matches the minus operator for sets.
top
AND
..*:MethodDecl &&
(..Graph:ClassDeclaration.*:* || ..Node:ClassDeclaration.*:*)
The minus operator is identical to the intersection operator for sets.
Compound traversals combined by the means of bracers are also possible.
top