C# Class Antlr4.Runtime.ParserInterpreter

A parser simulator that mimics what ANTLR's generated parser code does.
A parser simulator that mimics what ANTLR's generated parser code does. A ParserATNSimulator is used to make predictions via adaptivePredict but this class moves a pointer through the ATN to simulate parsing. ParserATNSimulator just makes us efficient rather than having to backtrack, for example. This properly creates parse trees even for left recursive rules. We rely on the left recursive rule invocation and special predicate transitions to make left recursive rules work. See TestParserInterpreter for examples.
Inheritance: Parser
Show file Open project: antlr/antlr4 Class Usage Examples

Protected Properties

Property Type Description
pushRecursionContextStates Antlr4.Runtime.Sharpen.BitSet

Public Methods

Method Description
EnterRecursionRule ( ParserRuleContext localctx, int state, int ruleIndex, int precedence ) : void
Parse ( int startRuleIndex ) : ParserRuleContext

Begin parsing at startRuleIndex

ParserInterpreter ( string grammarFileName, IVocabulary vocabulary, IEnumerable ruleNames, ATN atn, ITokenStream input ) : System

Protected Methods

Method Description
VisitRuleStopState ( ATNState p ) : void
VisitState ( ATNState p ) : void

Method Details

EnterRecursionRule() public method

public EnterRecursionRule ( ParserRuleContext localctx, int state, int ruleIndex, int precedence ) : void
localctx ParserRuleContext
state int
ruleIndex int
precedence int
return void

Parse() public method

Begin parsing at startRuleIndex
public Parse ( int startRuleIndex ) : ParserRuleContext
startRuleIndex int
return ParserRuleContext

ParserInterpreter() public method

public ParserInterpreter ( string grammarFileName, IVocabulary vocabulary, IEnumerable ruleNames, ATN atn, ITokenStream input ) : System
grammarFileName string
vocabulary IVocabulary
ruleNames IEnumerable
atn Antlr4.Runtime.Atn.ATN
input ITokenStream
return System

VisitRuleStopState() protected method

protected VisitRuleStopState ( ATNState p ) : void
p Antlr4.Runtime.Atn.ATNState
return void

VisitState() protected method

protected VisitState ( ATNState p ) : void
p Antlr4.Runtime.Atn.ATNState
return void

Property Details

pushRecursionContextStates protected property

protected BitSet,Antlr4.Runtime.Sharpen pushRecursionContextStates
return Antlr4.Runtime.Sharpen.BitSet