Language Processing
v2.0

pj2
Class Parser.Rule

Object
  extended by AbstractCollection<E>
      extended by AbstractList<Parser.Node>
          extended by Parser.Node
              extended by Parser.Rule
All Implemented Interfaces:
Iterable<Parser.Node>, Collection<Parser.Node>, List<Parser.Node>
Enclosing class:
Parser

public class Parser.Rule
extends Parser.Node

represents an optionally typed grammar rule. All instances can be found in Parser.rules.


Field Summary
 String name
          unique name, cannot be error.
 Parser.Node[] nodes
          alternatives: each a Sequence or single Node.
 Parser.Type type
          type (if not null).
 
Fields inherited from class Parser.Node
position
 
Fields inherited from class AbstractList
modCount
 
Constructor Summary
protected Parser.Rule(int position, Parser.Type type, String name, Parser.Node... nodes)
          assumed unique, new, adds itself to Parser.rules, manages Parser.defined.
 
Method Summary
 Parser.Node get(int index)
          needs to be overridden when there are descendants.
 int size()
          needs to be overridden when there are descendants.
 void visit(Visitor visitor)
          implements divide and conquer for Visitor.
 
Methods inherited from class AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Field Detail

type

public final Parser.Type type
type (if not null).


name

public final String name
unique name, cannot be error.


nodes

public final Parser.Node[] nodes
alternatives: each a Sequence or single Node. The first one can be null for an empty alternative.

Constructor Detail

Parser.Rule

protected Parser.Rule(int position,
                      Parser.Type type,
                      String name,
                      Parser.Node... nodes)
assumed unique, new, adds itself to Parser.rules, manages Parser.defined.

Method Detail

get

public Parser.Node get(int index)
Description copied from class: Parser.Node
needs to be overridden when there are descendants.

Specified by:
get in interface List<Parser.Node>
Overrides:
get in class Parser.Node
Throws:
IndexOutOfBoundsException - if index is not less then size().

size

public int size()
Description copied from class: Parser.Node
needs to be overridden when there are descendants.

Specified by:
size in interface Collection<Parser.Node>
Specified by:
size in interface List<Parser.Node>
Overrides:
size in class Parser.Node
Returns:
nodes.length.

visit

public void visit(Visitor visitor)
Description copied from class: Parser.Node
implements divide and conquer for Visitor. Body must be visitor.visit(this);.

Specified by:
visit in class Parser.Node


(c) 2008 Axel T. Schreiner