Generic Interpreter 1.2
Private API

gi
Class Grammar.ParseTree

java.lang.Object
  extended bygi.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.2
Author:
© 1999-2004 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
(package private) 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

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.

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.

t

private static StringBuffer t

The last string representation of a ParseTree returned.


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.
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

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.

Returns:
the string representation of this ParseTree.

toString

private void toString(int depth)

Appends the string representation of this ParseTree to t}.

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

 

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