C# Class Loyc.LLParserGenerator.LLParserGenerator.PredictionAnalysisVisitor

Performs prediction analysis using the visitor pattern to visit the predicates in a rule. The process starts with Analyze(Rule).
This class primarily does prediction analysis. It generates prediction trees, placed in the Alts.PredictionTree field, which GenerateCodeVisitor then uses to generate code. It relies on the //#region "Prediction analysis" in LLParserGenerator for the lowest-level analysis tasks.
Inheritance: Loyc.LLParserGenerator.RecursivePredVisitor
Mostra file Open project: qwertie/ecsharp

Private Properties

Property Type Description
AddElseCases void
AutoAddBranchForAndPred void
ComputeAssertionTree PredictionTreeOrAlt
ComputeAssertionTree2 PredictionTreeOrAlt
ComputeNestedPredictionTree PredictionTreeOrAlt
ComputeSetForNextBranch IPGTerminalSet
CountAlt void
NarrowDownToOneCase IPGTerminalSet
NarrowDownToSet KthSet
NarrowDownToSet void
RemoveFalsifiedCases void
SimplifyPredictionTree PredictionTreeOrAlt

Public Methods

Method Description
Analyze ( Rule rule ) : void
PredictionAnalysisVisitor ( LLParserGenerator llpg ) : System
Visit ( Alts alts ) : void
Visit ( AndPred pred ) : void
Visit ( Gate pred ) : void

Protected Methods

Method Description
ComputePredictionTree ( KthSet kthSets ) : PredictionTree

Private Methods

Method Description
AddElseCases ( Alts alts, PredictionTree tree ) : void

Extends each level of the prediction tree so that it has total coverage. For example, a typicaly prediction tree might have branches for 'a'..'z' and '0..'9'; this method will add coverage for all other possible inputs. It does this either by adding an error branch, or by extending the set handled by the default branch of each level.

AutoAddBranchForAndPred ( InternalList &children, AndPred andPred, List alts, Set matched, MSet falsified ) : void
ComputeAssertionTree ( List alts ) : PredictionTreeOrAlt
ComputeAssertionTree2 ( List alts, Set matched ) : PredictionTreeOrAlt
ComputeNestedPredictionTree ( List prevSets ) : PredictionTreeOrAlt
ComputeSetForNextBranch ( KthSet kthSets, List thisBranch, IPGTerminalSet covered ) : IPGTerminalSet
CountAlt ( int alt, int>.Dictionary timesUsed ) : void
NarrowDownToOneCase ( IPGTerminalSet normalSet, List cases ) : IPGTerminalSet
NarrowDownToSet ( KthSet kthSet, IPGTerminalSet set ) : KthSet
NarrowDownToSet ( List thisBranch, IPGTerminalSet set ) : void
RemoveFalsifiedCases ( List alts, MSet falsified ) : void
SimplifyPredictionTree ( PredictionTree tree ) : PredictionTreeOrAlt

Recursively merges adjacent duplicate cases in prediction trees. The tree is modified in-place, but in case a tree collapses to a single alternative, the return value indicates which single alternative.

Method Details

Analyze() public method

public Analyze ( Rule rule ) : void
rule Rule
return void

ComputePredictionTree() protected method

protected ComputePredictionTree ( KthSet kthSets ) : PredictionTree
kthSets KthSet
return PredictionTree

PredictionAnalysisVisitor() public method

public PredictionAnalysisVisitor ( LLParserGenerator llpg ) : System
llpg LLParserGenerator
return System

Visit() public method

public Visit ( Alts alts ) : void
alts Alts
return void

Visit() public method

public Visit ( AndPred pred ) : void
pred AndPred
return void

Visit() public method

public Visit ( Gate pred ) : void
pred Gate
return void