Generic Interpreter 0.9
Private API

gi
Class Grammar.ParseTree

java.lang.Object
  |
  +--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:
0.9
Author:
© 1999-2000 Craig A. Rich <carich@acm.org>

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

Field Detail

attribute

public Object attribute

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


phrase

public Grammar.ParseTree[] phrase

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


symbol

public Object symbol

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


tree

private static StringBuffer tree

The last string representation of a ParseTree returned.

Constructor Detail

Grammar.ParseTree

Grammar.ParseTree(Object symbol,
                  Object attribute,
                  Grammar.ParseTree[] phrase)

Constructs a ParseTree with a root and its subtrees.

Parameters:
symbol - the symbol at the root.
phrase - the array of subtrees produced by symbol.
Method Detail

toString

public String toString()

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

toString

private void toString(int depth)

Returns a string representation of this ParseTree.

Returns:
the string representation of this ParseTree.

 

© 1999-2000 Craig A. Rich <carich@acm.org>