Public Member Functions | |
Lookahead () | |
Lookahead (BitSet p) | |
Lookahead (String c) | |
Object | clone () |
void | combineWith (Lookahead q) |
boolean | containsEpsilon () |
Lookahead | intersection (Lookahead q) |
boolean | nil () |
void | resetEpsilon () |
void | setEpsilon () |
String | toString () |
String | toString (String separator, CharFormatter formatter) |
String | toString (String separator, CharFormatter formatter, Grammar g) |
String | toString (String separator, Vector vocab) |
Static Public Member Functions | |
static Lookahead | of (int el) |
Package Attributes | |
BitSet | fset |
String | cycle |
BitSet | epsilonDepth |
boolean | hasEpsilon = false |
This object holds all information needed to represent the lookahead for any particular lookahead computation for a single lookahead depth. Final lookahead information is a simple bit set, but intermediate stages need computation cycle and FOLLOW information.
Concerning the cycle
variable. If lookahead is computed for a RuleEnd node, then computation is part of a FOLLOW cycle for this rule. If lookahead is computed for a RuleBlock node, the computation is part of a FIRST cycle to this rule.
Concerning the epsilonDepth
variable. This is not the depth relative to the rule reference that epsilon was encountered. That value is
initial_k - epsilonDepth + 1
Also, lookahead depths past rule ref for local follow are:
initial_k - (initial_k - epsilonDepth)
Used for rule references. If we try to compute look(k, ruleref) and there are fewer than k lookahead terminals before the end of the the rule, epsilon will be returned (don't want to pass the end of the rule). We must track when the the lookahead got stuck. For example,
a : b A B E F G; b : C ;
LOOK(5, ref-to(b)) is {<EPSILON>} with depth = 4, which indicates that at 2 (5-4+1) tokens ahead, end of rule was reached. Therefore, the token at 4=5-(5-4) past rule ref b must be included in the set == F. The situation is complicated by the fact that a computation may hit the end of a rule at many different depths. For example,
a : b A B C ; b : E F // epsilon depth of 1 relative to initial k=3 | G // epsilon depth of 2 ;
Here, LOOK(3,ref-to(b)) returns epsilon, but the depths are {1, 2}; i.e., 3-(3-1) and 3-(3-2). Those are the lookahead depths past the rule ref needed for the local follow.
This is null unless an epsilon is created.
antlr.Lookahead.Lookahead | ( | ) |
References antlr.Lookahead.fset.
Referenced by antlr.Lookahead.intersection(), and antlr.Lookahead.of().
antlr.Lookahead.Lookahead | ( | BitSet | p | ) |
create a new lookahead set with the LL(1) set to the parameter
References antlr.Lookahead.fset.
antlr.Lookahead.Lookahead | ( | String | c | ) |
create an empty lookahead set, but with cycle
References antlr.Lookahead.cycle.
Object antlr.Lookahead.clone | ( | ) |
Make a deep copy of everything in this object
References antlr.collections.impl.BitSet.clone(), antlr.Lookahead.clone(), antlr.Lookahead.cycle, antlr.Lookahead.epsilonDepth, and antlr.Lookahead.fset.
Referenced by antlr.Lookahead.clone(), antlr.LLkAnalyzer.FOLLOW(), and antlr.LLkAnalyzer.look().
void antlr.Lookahead.combineWith | ( | Lookahead | q | ) |
References antlr.collections.impl.BitSet.clone(), antlr.Lookahead.containsEpsilon(), antlr.Lookahead.cycle, antlr.Lookahead.epsilonDepth, antlr.Lookahead.fset, antlr.Lookahead.hasEpsilon, and antlr.collections.impl.BitSet.orInPlace().
Referenced by antlr.LLkAnalyzer.FOLLOW(), and antlr.LLkAnalyzer.look().
boolean antlr.Lookahead.containsEpsilon | ( | ) |
References antlr.Lookahead.hasEpsilon.
Referenced by antlr.Lookahead.combineWith(), antlr.PythonCodeGenerator.gen(), antlr.JavaCodeGenerator.gen(), antlr.CSharpCodeGenerator.gen(), antlr.CppCodeGenerator.gen(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.JavaCodeGenerator.genCommonBlock(), antlr.CSharpCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genCommonBlock(), antlr.HTMLCodeGenerator.genLookaheadSetForAlt(), antlr.DocBookCodeGenerator.genLookaheadSetForAlt(), antlr.DiagnosticCodeGenerator.genLookaheadSetForAlt(), antlr.PythonCodeGenerator.genNextToken(), antlr.JavaCodeGenerator.genNextToken(), antlr.CSharpCodeGenerator.genNextToken(), antlr.CppCodeGenerator.genNextToken(), antlr.LLkAnalyzer.look(), and antlr.Lookahead.toString().
What is the intersection of two lookahead depths? Only the Epsilon "bit" and bitset are considered.
References antlr.collections.impl.BitSet.and(), antlr.Lookahead.fset, antlr.Lookahead.hasEpsilon, antlr.Lookahead.Lookahead(), and antlr.Lookahead.setEpsilon().
Referenced by antlr.LLkAnalyzer.deterministic(), and antlr.LLkAnalyzer.deterministicImpliedPath().
boolean antlr.Lookahead.nil | ( | ) |
static Lookahead antlr.Lookahead.of | ( | int | el | ) | [static] |
References antlr.collections.impl.BitSet.add(), antlr.Lookahead.fset, and antlr.Lookahead.Lookahead().
Referenced by antlr.LLkAnalyzer.look().
void antlr.Lookahead.resetEpsilon | ( | ) |
References antlr.Lookahead.hasEpsilon.
Referenced by antlr.LLkAnalyzer.look().
void antlr.Lookahead.setEpsilon | ( | ) |
References antlr.Lookahead.hasEpsilon.
Referenced by antlr.LLkAnalyzer.FOLLOW(), antlr.Lookahead.intersection(), and antlr.LLkAnalyzer.look().
String antlr.Lookahead.toString | ( | String | separator, | |
CharFormatter | formatter | |||
) |
String antlr.Lookahead.toString | ( | ) |
References antlr.Lookahead.containsEpsilon(), antlr.Lookahead.cycle, antlr.Lookahead.epsilonDepth, antlr.Lookahead.fset, and antlr.collections.impl.BitSet.toString().
Referenced by antlr.LLkAnalyzer.deterministic(), antlr.LLkAnalyzer.deterministicImpliedPath(), antlr.LLkAnalyzer.FOLLOW(), antlr.LLkAnalyzer.look(), antlr.RuleBlock.toString(), antlr.Lookahead.toString(), and antlr.AlternativeBlock.toString().
String antlr.Lookahead.toString | ( | String | separator, | |
Vector | vocab | |||
) |
String antlr.Lookahead.toString | ( | String | separator, | |
CharFormatter | formatter, | |||
Grammar | g | |||
) |
String antlr.Lookahead.cycle [package] |
is this computation part of a computation cycle?
Referenced by antlr.Lookahead.clone(), antlr.Lookahead.combineWith(), antlr.LLkAnalyzer.FOLLOW(), antlr.LLkAnalyzer.look(), antlr.Lookahead.Lookahead(), and antlr.Lookahead.toString().
BitSet antlr.Lookahead.epsilonDepth [package] |
What k values were being computed when end of rule hit?
Referenced by antlr.Lookahead.clone(), antlr.Lookahead.combineWith(), antlr.LLkAnalyzer.look(), and antlr.Lookahead.toString().
BitSet antlr.Lookahead.fset [package] |
actual bitset of the lookahead
Referenced by antlr.Lookahead.clone(), antlr.Lookahead.combineWith(), antlr.LLkAnalyzer.FOLLOW(), antlr.PythonCodeGenerator.genCommonBlock(), antlr.JavaCodeGenerator.genCommonBlock(), antlr.CSharpCodeGenerator.genCommonBlock(), antlr.CppCodeGenerator.genCommonBlock(), antlr.PythonCodeGenerator.genRule(), antlr.JavaCodeGenerator.genRule(), antlr.CSharpCodeGenerator.genRule(), antlr.CppCodeGenerator.genRule(), antlr.CodeGenerator.getFIRSTBitSet(), antlr.CodeGenerator.getFOLLOWBitSet(), antlr.PythonCodeGenerator.getLookaheadTestExpression(), antlr.JavaCodeGenerator.getLookaheadTestExpression(), antlr.CSharpCodeGenerator.getLookaheadTestExpression(), antlr.CppCodeGenerator.getLookaheadTestExpression(), antlr.Lookahead.intersection(), antlr.LLkAnalyzer.look(), antlr.Lookahead.Lookahead(), antlr.LLkAnalyzer.lookaheadEquivForApproxAndFullAnalysis(), antlr.PythonCodeGenerator.lookaheadIsEmpty(), antlr.JavaCodeGenerator.lookaheadIsEmpty(), antlr.CSharpCodeGenerator.lookaheadIsEmpty(), antlr.CppCodeGenerator.lookaheadIsEmpty(), antlr.Lookahead.nil(), antlr.Lookahead.of(), antlr.HTMLCodeGenerator.printSet(), antlr.DocBookCodeGenerator.printSet(), antlr.DiagnosticCodeGenerator.printSet(), and antlr.Lookahead.toString().
boolean antlr.Lookahead.hasEpsilon = false [package] |
Does this lookahead depth include Epsilon token type? This is used to avoid having a bit in the set for Epsilon as it conflicts with parsing binary files.
Referenced by antlr.Lookahead.combineWith(), antlr.Lookahead.containsEpsilon(), antlr.Lookahead.intersection(), antlr.Lookahead.nil(), antlr.Lookahead.resetEpsilon(), and antlr.Lookahead.setEpsilon().