org.ourgrid.common.spec.syntactical
Class SyntacticalDerivationTree

java.lang.Object
  extended by org.ourgrid.common.spec.syntactical.SyntacticalDerivationTree

public class SyntacticalDerivationTree
extends java.lang.Object

This is the entity that will control the derivation of a word from a language described by a grammar. Here a word is the source that has to be compiled, then; a derivation is the process of, beginning from the initial symbol of a grammar, obtain the read source.


Constructor Summary
SyntacticalDerivationTree(Symbol endOfSourceSymbol, Symbol initialSymbol)
          Initializes the stack that will control the derivation.
 
Method Summary
 Symbol pop()
          Pops (removes) the symbol at the top of the derivation stack.
 void pushRule(Rule rule)
          Pushes (insert) a given rule at the top of the derivation stack.
 Symbol top()
          Returns the symbol at the top of the derivation stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyntacticalDerivationTree

public SyntacticalDerivationTree(Symbol endOfSourceSymbol,
                                 Symbol initialSymbol)
Initializes the stack that will control the derivation.

Parameters:
endOfSourceSymbol - The symbol that defines that the source has ended.
initialSymbol - The initial symbol of the grammar language.
Method Detail

top

public Symbol top()
Returns the symbol at the top of the derivation stack.

Returns:
The symbol at the top of the derivation stack.

pop

public Symbol pop()
Pops (removes) the symbol at the top of the derivation stack.

Returns:
The symbol that was removed from the top of the derivation stack.

pushRule

public void pushRule(Rule rule)
Pushes (insert) a given rule at the top of the derivation stack. A rule is a set of symbols (terminal or not). To push a rule at the derivation stack, is necessary to insert from the end to the beggining of the rule's symbols.

Parameters:
rule - The rule that have to be inserted at the derivation stack top.