org.apache.avro.io.parsing
Class Parser

java.lang.Object
  extended by org.apache.avro.io.parsing.Parser
Direct Known Subclasses:
SkipParser

public class Parser
extends Object

Parser is the class that maintains the stack for parsing. This class is used by encoders, which are not required to skip.


Nested Class Summary
static interface Parser.ActionHandler
          The parser knows how to handle the terminal and non-terminal symbols.
 
Field Summary
protected  int pos
           
protected  Symbol[] stack
           
protected  Parser.ActionHandler symbolHandler
           
 
Constructor Summary
Parser(Symbol root, Parser.ActionHandler symbolHandler)
           
 
Method Summary
 Symbol advance(Symbol input)
          Recursively replaces the symbol at the top of the stack with its production, until the top is a terminal.
 int depth()
          Returns the depth of the stack.
 Symbol popSymbol()
          Pops and returns the top symbol from the stack.
 void processImplicitActions()
          Performs any implicit actions at the top the stack, expanding any production (other than the root) that may be encountered.
 void processTrailingImplicitActions()
          Performs any "trailing" implicit actions at the top the stack.
 void pushProduction(Symbol sym)
          Pushes the production for the given symbol sym.
 void pushSymbol(Symbol sym)
          Pushes sym on to the stack.
 void reset()
           
 Symbol topSymbol()
          Returns the top symbol from the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

symbolHandler

protected final Parser.ActionHandler symbolHandler

stack

protected Symbol[] stack

pos

protected int pos
Constructor Detail

Parser

public Parser(Symbol root,
              Parser.ActionHandler symbolHandler)
       throws IOException
Throws:
IOException
Method Detail

advance

public final Symbol advance(Symbol input)
                     throws IOException
Recursively replaces the symbol at the top of the stack with its production, until the top is a terminal. Then checks if the top symbol matches the terminal symbol suppled terminal.

Parameters:
input - The symbol to match against the terminal at the top of the stack.
Returns:
The terminal symbol at the top of the stack unless an implicit action resulted in another symbol, in which case that symbol is returned.
Throws:
IOException

processImplicitActions

public final void processImplicitActions()
                                  throws IOException
Performs any implicit actions at the top the stack, expanding any production (other than the root) that may be encountered. This method will fail if there are any repeaters on the stack.

Throws:
IOException

processTrailingImplicitActions

public final void processTrailingImplicitActions()
                                          throws IOException
Performs any "trailing" implicit actions at the top the stack.

Throws:
IOException

pushProduction

public final void pushProduction(Symbol sym)
Pushes the production for the given symbol sym. If sym is a repeater and input is either Symbol.ARRAY_END or Symbol.MAP_END pushes nothing.

Parameters:
sym -

popSymbol

public Symbol popSymbol()
Pops and returns the top symbol from the stack.


topSymbol

public Symbol topSymbol()
Returns the top symbol from the stack.


pushSymbol

public void pushSymbol(Symbol sym)
Pushes sym on to the stack.


depth

public int depth()
Returns the depth of the stack.


reset

public void reset()


Copyright © 2010 The Apache Software Foundation