public abstract class Parser extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Parser.Events
This class "lists" reportable events that might happen during parsing.
|
static class |
Parser.Exception |
class |
Parser.Simulator
Simulator is a stripped (of action code) version of a parser that will try to parse ahead
token stream after a syntax error.
|
class |
Parser.TokenStream
This class wraps a Scanner and provides a token "accumulator" for a parsing simulation.
|
Modifier and Type | Field and Description |
---|---|
protected Symbol[] |
_symbols
The stack of shifted symbols.
|
protected short |
accept_action_id
Cached ID of the ACCEPT action.
|
protected Parser.Events |
report
Parsing events notification "gateway"
|
protected short[] |
states
The parser's stack.
|
protected ParsingTables |
tables
The automaton tables.
|
protected int |
top
Index of the stack's top element, i.e.
|
Modifier | Constructor and Description |
---|---|
protected |
Parser(ParsingTables tables) |
Modifier and Type | Method and Description |
---|---|
protected abstract Symbol |
invokeReduceAction(int rule_num,
int offset)
Invoke actual reduce action routine.
|
Object |
parse(Scanner source)
Parses a source and returns a semantic value of the accepted nonterminal
|
Object |
parse(Scanner source,
short alt_goal_marker_id)
Parses a source and returns a semantic value of the accepted nonterminal.
|
protected void |
recoverFromError(Symbol token,
Parser.TokenStream in)
Implements parsing error recovery.
|
protected final ParsingTables tables
protected final short accept_action_id
protected short[] states
protected int top
protected Symbol[] _symbols
protected Parser.Events report
protected Parser(ParsingTables tables)
public Object parse(Scanner source) throws IOException, Parser.Exception
source
- of tokens - a ScannerIOException
Parser.Exception
public Object parse(Scanner source, short alt_goal_marker_id) throws IOException, Parser.Exception
source
- of tokens - a Scanneralt_goal_marker_id
- ID of a token like symbol that will be used as a markerIOException
Parser.Exception
protected abstract Symbol invokeReduceAction(int rule_num, int offset)
rule_num
- ID of a reduce action routine to invokeoffset
- to the symbol before first action routine argumentprotected void recoverFromError(Symbol token, Parser.TokenStream in) throws IOException, Parser.Exception
token
- a lookahead terminal symbol that messed parsingin
- token streamIOException
- propagated from a scanner if it has issues with the sourceParser.Exception
- if Parser cannot recoverCopyright © 2021 Soot OSS. All rights reserved.