Class SymbolChecks

  • public class SymbolChecks
    extends Object
    Check for symbol problems; no side-effects. Inefficient to walk rules and such multiple times, but I like isolating all error checking outside of code that actually defines symbols etc... Side-effect: strip away redef'd rules.
    • Method Detail

      • process

        public void process()
      • checkActionRedefinitions

        public void checkActionRedefinitions​(List<GrammarAST> actions)
      • checkForLabelConflicts

        public void checkForLabelConflicts​(Collection<Rule> rules)
        Make sure a label doesn't conflict with another symbol. Labels must not conflict with: rules, tokens, scope names, return values, parameters, and rule-scope dynamic attributes defined in surrounding rule. Also they must have same type for repeated defs.
      • checkForLabelConflict

        public void checkForLabelConflict​(Rule r,
                                          GrammarAST labelID)
      • checkForAttributeConflicts

        public void checkForAttributeConflicts​(Rule r)
      • checkReservedNames

        protected void checkReservedNames​(Collection<Rule> rules)
      • checkForModeConflicts

        public void checkForModeConflicts​(Grammar g)
      • checkForUnreachableTokens

        public void checkForUnreachableTokens​(Grammar g)
        Algorithm steps: 1. Collect all simple string literals (i.e. 'asdf', 'as' 'df', but not [a-z]+, 'a'..'z') for all lexer rules in each mode except of autogenerated tokens (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.
      • checkForQualifiedRuleIssues

        public void checkForQualifiedRuleIssues​(Grammar g,
                                                List<GrammarAST> qualifiedRuleRefs)