Package org.apache.avro.io.parsing

# Class Parser

java.lang.Object
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

Nested Classes
Modifier and Type
Class
Description
`static interface`
`Parser.ActionHandler`
The parser knows how to handle the terminal and non-terminal symbols.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected int`
`pos`
`protected Symbol[]`
`stack`
`protected final Parser.ActionHandler`
`symbolHandler`

## Constructor Summary

Constructors
Constructor
Description
`Parser(Symbol root, Parser.ActionHandler symbolHandler)`

## Method Summary

Modifier and Type
Method
Description
`final 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.
`final void`
`processImplicitActions()`
Performs any implicit actions at the top the stack, expanding any production (other than the root) that may be encountered.
`final void`
`processTrailingImplicitActions()`
Performs any "trailing" implicit actions at the top the stack.
`final 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 Details

### symbolHandler

protected final Parser.ActionHandler symbolHandler

### stack

protected Symbol[] stack

### pos

protected int pos

## Constructor Details

### Parser

public Parser(Symbol root, Parser.ActionHandler symbolHandler)

## Method Details

### 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` - the symbol

### 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()