Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Parser is the class that maintains the stack for parsing. This class
is used by encoders, which are not required to skip.
The parser knows how to handle the terminal and non-terminal
symbols. But it needs help from outside to handle implicit
and explicit actions. The clients implement this interface to
provide this help.
Handle the action symbol top
when the input
sought to be taken off the stack.
input The input symbol from the caller of advance
top The symbol at the top the stack.
- null if advance() is to continue processing the
stack. If not null the return value will be returned
If there is no sufficient room in the stack, use this expand it.
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
input The symbol to match against the terminal at the
top of the stack.
- The terminal symbol at the top of the stack unless an
implicit action resulted in another symbol, in which case that
symbol is returned.
+ top + " was expected.");
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.
Performs any "trailing" implicit actions at the top the stack.
Pops and returns the top symbol from the stack.
Returns the top symbol from the stack.
on to the stack.
Returns the depth of the stack.