public class SymbolChecks extends Object
| Modifier and Type | Field and Description |
|---|---|
ErrorManager |
errMgr |
protected Set<String> |
reservedNames |
| Constructor and Description |
|---|
SymbolChecks(Grammar g,
SymbolCollector collector) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkActionRedefinitions(List<GrammarAST> actions) |
protected void |
checkDeclarationRuleConflicts(Rule r,
AttributeDict attributes,
Set<String> ruleNames,
ErrorType errorType) |
void |
checkForAttributeConflicts(Rule r) |
void |
checkForLabelConflict(Rule r,
GrammarAST labelID) |
void |
checkForLabelConflicts(Collection<Rule> rules)
Make sure a label doesn't conflict with another symbol.
|
void |
checkForModeConflicts(Grammar g) |
void |
checkForQualifiedRuleIssues(Grammar g,
List<GrammarAST> qualifiedRuleRefs) |
void |
checkForUnreachableTokens(Grammar g)
Algorithm steps:
1.
|
protected void |
checkLocalConflictingDeclarations(Rule r,
AttributeDict attributes,
AttributeDict referenceAttributes,
ErrorType errorType) |
protected void |
checkReservedNames(Collection<Rule> rules) |
void |
checkRuleArgs(Grammar g,
List<GrammarAST> rulerefs) |
void |
process() |
public ErrorManager errMgr
public SymbolChecks(Grammar g, SymbolCollector collector)
public void process()
public void checkActionRedefinitions(List<GrammarAST> actions)
public void checkForLabelConflicts(Collection<Rule> rules)
public void checkForLabelConflict(Rule r, GrammarAST labelID)
public void checkForAttributeConflicts(Rule r)
protected void checkDeclarationRuleConflicts(@NotNull
Rule r,
@Nullable
AttributeDict attributes,
@NotNull
Set<String> ruleNames,
@NotNull
ErrorType errorType)
protected void checkLocalConflictingDeclarations(@NotNull
Rule r,
@Nullable
AttributeDict attributes,
@Nullable
AttributeDict referenceAttributes,
@NotNull
ErrorType errorType)
protected void checkReservedNames(@NotNull
Collection<Rule> rules)
public void checkForModeConflicts(Grammar g)
public void checkForUnreachableTokens(Grammar g)
getSingleTokenValues(org.antlr.v4.tool.Rule))
2. Compare every string literal with each other (checkForOverlap(org.antlr.v4.tool.Grammar, org.antlr.v4.tool.Rule, org.antlr.v4.tool.Rule, java.util.List<java.lang.String>, java.util.List<java.lang.String>))
and throw TOKEN_UNREACHABLE warning if the same string found.
Complexity: O(m * n^2 / 2), approximately equals to O(n^2)
where m - number of modes, n - average number of lexer rules per mode.
See also testUnreachableTokens unit test for details.public void checkRuleArgs(Grammar g, List<GrammarAST> rulerefs)
public void checkForQualifiedRuleIssues(Grammar g, List<GrammarAST> qualifiedRuleRefs)
Copyright © 1992–2022 Daniel Sun. All rights reserved.