fri.patterns.interpreter.parsergenerator.semantics
Class TreeBuilderSemantic

java.lang.Object
  |
  +--fri.patterns.interpreter.parsergenerator.semantics.TreeBuilderSemantic
All Implemented Interfaces:
Semantic

public class TreeBuilderSemantic
extends java.lang.Object
implements Semantic

A semantic that builds a syntax tree model from a parser run. Every node of the result tree contains the rule and the parsed token list. The result of the parser run can be retrieved by (TreeBuilderSemantic.Node) parser.getResult().

Author:
(c) 2002, Fritz Ritzberger

Nested Class Summary
static class TreeBuilderSemantic.Node
          Node class that representy a syntax tree node.
 
Constructor Summary
TreeBuilderSemantic()
           
 
Method Summary
 java.lang.Object doSemantic(Rule rule, java.util.List inputTokens, java.util.List ranges)
          Implements Semantic to store every node of the syntax tree with rule and values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeBuilderSemantic

public TreeBuilderSemantic()
Method Detail

doSemantic

public java.lang.Object doSemantic(Rule rule,
                                   java.util.List inputTokens,
                                   java.util.List ranges)
Implements Semantic to store every node of the syntax tree with rule and values.

Specified by:
doSemantic in interface Semantic
Parameters:
rule - Rule that was "reduced" (recognized).
inputTokens - all semantic call returns from underlying rules, collected according to current rule, that means you get a List of Objects as long as the count of symbols on the right side of the rule, every Object is a return of an underlying doSemantic() call.
ranges - all line ranges for parseResults elements. Cast elements to Token.Range to get the start and end position of every Object in parseResult List.
Returns:
some result to be pushed on value stack by the Parser, or null.