Class ParseTree
java.lang.Object
ParseTree
Represents a parse tree node for YaLCC.
It can be a leaf or an internal node with children.
Each node has a label (Symbol) and a rule number.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a child node to this node.Returns the list of child nodesgetLabel()Returns the label symbolintReturns the rule numbervoidsetRuleNumber(int ruleNumber) Sets the rule numberWrites the tree as a forest picture.toLaTeX()Writes the tree as a LaTeX document which can be compiled using PDFLaTeX.Writes the tree in LaTeX forest format.toTikZ()Writes the tree as TikZ code.Writes the tree as a TikZ picture.
-
Field Details
-
label
The label symbol for this node -
children
The list of child nodes -
ruleNumber
private int ruleNumberThe rule number used to create this node
-
-
Constructor Details
-
ParseTree
Creates a leaf node with a given symbol. This node has no children, and rule number is set to -1.- Parameters:
lbl- the symbol labeling this node
-
ParseTree
Creates a node with a symbol, a list of children and a rule number.- Parameters:
lbl- the symbol labeling this nodechdn- the list of child nodesruleNum- the rule number used to create this node
-
-
Method Details
-
addChild
Adds a child node to this node.- Parameters:
child- the child node to add
-
getChildren
Returns the list of child nodes- Returns:
- the list of child nodes
-
getRuleNumber
public int getRuleNumber()Returns the rule number- Returns:
- the rule number
-
setRuleNumber
public void setRuleNumber(int ruleNumber) Sets the rule number- Parameters:
ruleNumber- the rule number to set
-
getLabel
Returns the label symbol- Returns:
- the label symbol
-
toLaTexTree
Writes the tree in LaTeX forest format.- Returns:
- the tree in LaTeX forest format
-
toTikZ
Writes the tree as TikZ code.- Returns:
- the tree as TikZ code
-
toTikZPicture
Writes the tree as a TikZ picture. TiKz picture can be used in LaTeX documents.- Returns:
- the tree as a TikZ picture
-
toForestPicture
Writes the tree as a forest picture. Returns the tree in forest enviroment using the latex code of the tree- Returns:
- the tree as a forest picture
-
toLaTeX
Writes the tree as a LaTeX document which can be compiled using PDFLaTeX.
The result can be used with the command:pdflatex some-file.tex
- Returns:
- the tree as a LaTeX document
-