public class SymbolChecks
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
(package private) java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
actionScopeToActionNames |
(package private) SymbolCollector |
collector |
ErrorManager |
errMgr |
(package private) Grammar |
g |
(package private) java.util.Map<java.lang.String,Rule> |
nameToRuleMap |
protected java.util.Set<java.lang.String> |
reservedNames |
(package private) java.util.Set<java.lang.String> |
tokenIDs |
| Constructor and Description |
|---|
SymbolChecks(Grammar g,
SymbolCollector collector) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkActionRedefinitions(java.util.List<GrammarAST> actions) |
protected void |
checkDeclarationRuleConflicts(Rule r,
AttributeDict attributes,
java.util.Set<java.lang.String> ruleNames,
ErrorType errorType) |
void |
checkForAttributeConflicts(Rule r) |
void |
checkForLabelConflict(Rule r,
GrammarAST labelID) |
void |
checkForLabelConflicts(java.util.Collection<Rule> rules)
Make sure a label doesn't conflict with another symbol.
|
void |
checkForModeConflicts(Grammar g) |
private void |
checkForOverlap(Grammar g,
Rule rule1,
Rule rule2,
java.util.List<java.lang.String> firstTokenStringValues,
java.util.List<java.lang.String> secondTokenStringValues)
For same rule compare values from next index:
TOKEN_WITH_SAME_VALUES: 'asdf' | 'asdf';
For different rules compare from start value:
TOKEN1: 'asdf';
TOKEN2: 'asdf';
|
void |
checkForQualifiedRuleIssues(Grammar g,
java.util.List<GrammarAST> qualifiedRuleRefs) |
private void |
checkForTypeMismatch(Rule r,
LabelElementPair prevLabelPair,
LabelElementPair labelPair) |
void |
checkForUnreachableTokens(Grammar g)
Algorithm steps:
1.
|
private void |
checkLabelPairs(Rule r,
java.util.Map<java.lang.String,LabelElementPair> labelNameSpace,
java.util.List<LabelElementPair> pairs) |
protected void |
checkLocalConflictingDeclarations(Rule r,
AttributeDict attributes,
AttributeDict referenceAttributes,
ErrorType errorType) |
protected void |
checkReservedNames(java.util.Collection<Rule> rules) |
void |
checkRuleArgs(Grammar g,
java.util.List<GrammarAST> rulerefs) |
private java.lang.String |
findAltLabelName(org.antlr.runtime.tree.CommonTree label) |
private java.util.List<java.lang.String> |
getSingleTokenValues(Rule rule)
list of simple string literals for rule
|
void |
process() |
Grammar g
SymbolCollector collector
java.util.Map<java.lang.String,Rule> nameToRuleMap
java.util.Set<java.lang.String> tokenIDs
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> actionScopeToActionNames
public ErrorManager errMgr
protected final java.util.Set<java.lang.String> reservedNames
public SymbolChecks(Grammar g, SymbolCollector collector)
public void process()
public void checkActionRedefinitions(java.util.List<GrammarAST> actions)
public void checkForLabelConflicts(java.util.Collection<Rule> rules)
private void checkLabelPairs(Rule r, java.util.Map<java.lang.String,LabelElementPair> labelNameSpace, java.util.List<LabelElementPair> pairs)
private java.lang.String findAltLabelName(org.antlr.runtime.tree.CommonTree label)
private void checkForTypeMismatch(Rule r, LabelElementPair prevLabelPair, LabelElementPair labelPair)
public void checkForLabelConflict(Rule r, GrammarAST labelID)
public void checkForAttributeConflicts(Rule r)
protected void checkDeclarationRuleConflicts(Rule r, AttributeDict attributes, java.util.Set<java.lang.String> ruleNames, ErrorType errorType)
protected void checkLocalConflictingDeclarations(Rule r, AttributeDict attributes, AttributeDict referenceAttributes, ErrorType errorType)
protected void checkReservedNames(java.util.Collection<Rule> rules)
public void checkForModeConflicts(Grammar g)
public void checkForUnreachableTokens(Grammar g)
getSingleTokenValues)
2. Compare every string literal with each other (checkForOverlap)
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.private java.util.List<java.lang.String> getSingleTokenValues(Rule rule)
private void checkForOverlap(Grammar g, Rule rule1, Rule rule2, java.util.List<java.lang.String> firstTokenStringValues, java.util.List<java.lang.String> secondTokenStringValues)
public void checkRuleArgs(Grammar g, java.util.List<GrammarAST> rulerefs)
public void checkForQualifiedRuleIssues(Grammar g, java.util.List<GrammarAST> qualifiedRuleRefs)