Generic Interpreter 1.3
Private API

gi
Class Grammar.ParseTree

java.lang.Object
  extended by gi.Grammar.ParseTree
Enclosing class:
Grammar

protected static class Grammar.ParseTree
extends Object

This class implements a ParseTree constructed by interpreting a source stream.

Version:
1.3
Author:
© 1999-2009 Craig A. Rich <carich@csupomona.edu>

Field Summary
 Grammar.ParseTree[] child
          The subtrees of the root of this ParseTree.
 Object root
          The symbol at the root of this ParseTree.
private static StringBuffer t
          The last string representation of a ParseTree returned.
 Object value
          The attribute value at the root of this ParseTree.
 
Constructor Summary
Grammar.ParseTree(Object root, Object value, Grammar.ParseTree[] child)
          Constructs a ParseTree with a root and its subtrees.
 
Method Summary
 String toString()
          Returns the string representation of this ParseTree.
private  void toString(int depth)
          Appends the string representation of this ParseTree to t.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

root

public Object root

The symbol at the root of this ParseTree. root can be a nonterminal, a terminal or Semantics.

Since:
1.1, renames symbol in version 1.0.

value

public Object value

The attribute value at the root of this ParseTree. If root is a terminal, value is initially the source word root matches; otherwise, value is initially null. value may be modified when interpreting by evaluation of embedded Semantics.

Since:
1.1, renames attribute in version 1.0.

child

public Grammar.ParseTree[] child

The subtrees of the root of this ParseTree. If root is a nonterminal, child is the array of subtrees produced by root; otherwise, child is null.

Since:
1.1, renames phrase in version 1.0.

t

private static StringBuffer t

The last string representation of a ParseTree returned.

Constructor Detail

Grammar.ParseTree

Grammar.ParseTree(Object root,
                  Object value,
                  Grammar.ParseTree[] child)

Constructs a ParseTree with a root and its subtrees.

Parameters:
root - the symbol at the root.
value - the attribute value at the root.
child - the array of subtrees produced by root.
Method Detail

toString

private void toString(int depth)

Appends the string representation of this ParseTree to t.

Parameters:
depth - the depth at which this ParseTree occurs.

toString

public String toString()

Returns the string representation of this ParseTree. The symbols in the ParseTree are shown in outline form, with children below their parent indented two columns. Each symbol is followed by its attribute value, if it is not null and differs from the symbol.

Overrides:
toString in class Object
Returns:
the string representation of this ParseTree.

 

© 1999-2009 Craig A. Rich <carich@csupomona.edu>