public class Ast extends Object
Constructor and Description |
---|
Ast(Ast tree)
constructor
|
Ast(String nt,
String label)
constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Set<Ast> |
getDominatingSubtrees(Predicate<AstNode> p)
find dominant subtrees, i.e., subtrees where the distance of the subtree root
node to the ast root node is minimal.
|
Set<AstNode> |
getLeafs()
get leaf nodes
|
List<AstNode> |
getNodes()
get all nodes
|
AstNode |
getRoot()
get root node
|
Ast |
getSubtree(Ast subtree)
get subtree
|
Set<Ast> |
getSubtrees(Predicate<AstNode> p)
get subtree with the root node identified by p
|
int |
hashCode() |
boolean |
hasSubtree(Ast subtree)
check the presence of subree in the current tree
|
AstNode |
newNode(AstNode parent,
String nt,
String label)
create new ast node
|
boolean |
removeSubtree(Ast subtree)
remove subtree from ast
|
boolean |
replaceSubtree(Ast oldTree,
Ast newTree)
replace oldTree by newTree
|
String |
toDot()
generate dot representation from ast
|
public Ast(String nt, String label)
create a new abstract syntax tree
nt
- name of root non-terminal nodelabel
- value of root non-terminal nodepublic Ast(Ast tree)
copy constructor
tree
- tree to be duplicatedpublic AstNode getRoot()
public AstNode newNode(AstNode parent, String nt, String label)
parent
- parent nodent
- name of node to be cratedlabel
- value of node to be createdpublic String toDot()
public boolean replaceSubtree(Ast oldTree, Ast newTree)
oldTree
- tree to be replacednewTree
- tree replacementpublic boolean removeSubtree(Ast subtree)
subtree
- to be removedpublic Set<Ast> getDominatingSubtrees(Predicate<AstNode> p)
p
- predicate to search for the dominating subtree root nodepublic Set<Ast> getSubtrees(Predicate<AstNode> p)
p
- predicate for identifying the root nodepublic boolean hasSubtree(Ast subtree)
subtree
- tree whose presence is checkedpublic Ast getSubtree(Ast subtree)
subtree
- tree whose presence is checkedCopyright © 2017. All rights reserved.