Object-oriented Parser System
v3.6

oops3
Class Build

Object
  extended by Utils
      extended by Visitor
          extended by Recognize
              extended by Build
All Implemented Interfaces:
Symbols

public class Build
extends Recognize

ParserFactory aspect: build a tree. The visitor uses package access.

Version:
3.5.0

Field Summary
protected  boolean addNull
          true (default) to record null for noInput.
protected  Object builder
          can modify the result of each Rule.
protected  List[] collections
          current collections for Permute.
protected  List current
          current collection.
 
Fields inherited from class Recognize
parser, scanner
 
Fields inherited from class Utils
error
 
Fields inherited from interface Symbols
badInput, endOfFile, firstSymbol, noInput
 
Constructor Summary
Build(Parser parser)
           
 
Method Summary
 Object build(Scanner scanner, Object builder, boolean addNull)
          delegate to recognize.
protected  void noInput()
          override processing of noInput: if addNull, add null to current collection.
protected  void permute(Parser.Permute permute, int a)
          override processing of an alternative of Permute: arrange to collect into collection for alternative.
protected  Boolean permutedList(Parser.PermutedList permutedList, int a, int done)
          override processing of an alternative of PermutedList.
 Object visit(Parser.Nonterminal nonterminal)
          override processing of a Nonterminal: visit rule; if result is ArrayList flatten, else add result to current.
 Object visit(Parser.Permute permute)
          override processing of a Permute: collect each alternative separately, add the collections, flattened, in order of definition.
 Object visit(Parser.PermutedList permutedList)
          override processing of a PermutedList.
 Object visit(Parser.Rule rule)
          override processing of a Rule: push current, visit right hand side, pop current; silently filter by invoking builder.
 Object visit(Parser.Token token)
          override processing of a Token: add value to current, then delegate to base class.
 
Methods inherited from class Recognize
advance, recognize, visit, visit, visit, visit, visit
 
Methods inherited from class Visitor
visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class Utils
className, error, error, fromString, getError, message, testScanner, toChars, toString, toString, warning, warning
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

builder

protected Object builder
can modify the result of each Rule.


current

protected List current
current collection.


collections

protected List[] collections
current collections for Permute.


addNull

protected boolean addNull
true (default) to record null for noInput.

Constructor Detail

Build

public Build(Parser parser)
Method Detail

build

public Object build(Scanner scanner,
                    Object builder,
                    boolean addNull)
delegate to recognize.

Returns:
result of visiting start rule, null on error.

visit

public Object visit(Parser.Rule rule)
override processing of a Rule: push current, visit right hand side, pop current; silently filter by invoking builder.rulename(int,List) or builder.rulename(List), if either, with the scanner's position and the current list; if filtering is not possible and rule is marked left-associative, send each element of the current list to its successor using List.add(E) and return the last element.

Overrides:
visit in class Recognize
Returns:
result value from builder or popped list.

visit

public Object visit(Parser.Nonterminal nonterminal)
override processing of a Nonterminal: visit rule; if result is ArrayList flatten, else add result to current.

Overrides:
visit in class Recognize
Returns:
null.

visit

public Object visit(Parser.Token token)
override processing of a Token: add value to current, then delegate to base class.

Overrides:
visit in class Visitor

noInput

protected void noInput()
override processing of noInput: if addNull, add null to current collection.

Overrides:
noInput in class Recognize

visit

public Object visit(Parser.Permute permute)
override processing of a Permute: collect each alternative separately, add the collections, flattened, in order of definition. Delegate to noInput() if an alternative has not been selected.

Overrides:
visit in class Recognize
Returns:
null.

permute

protected void permute(Parser.Permute permute,
                       int a)
override processing of an alternative of Permute: arrange to collect into collection for alternative.

Overrides:
permute in class Recognize

visit

public Object visit(Parser.PermutedList permutedList)
override processing of a PermutedList. Unfortunately, this is identical to permute; however, it needs to call permutedList.

Overrides:
visit in class Recognize
Returns:
null.

permutedList

protected Boolean permutedList(Parser.PermutedList permutedList,
                               int a,
                               int done)
override processing of an alternative of PermutedList. Unfortunately, this is identical to permute; however, it needs to call permutedList. If collected, a delimiter is appended to the alternative it follows.

Overrides:
permutedList in class Recognize
Returns:
null at end of input, true to continue matching.


(c) 2008 Axel T. Schreiner