Class LexerGrammar

    • Field Detail

      • implicitLexerOwner

        public Grammar implicitLexerOwner
        The grammar from which this lexer grammar was derived (if implicit)
      • modes

        public MultiMap<String,​Rule> modes
        DEFAULT_MODE rules are added first due to grammar syntax order
    • Constructor Detail

      • LexerGrammar

        public LexerGrammar​(String grammarText)
                     throws org.antlr.runtime.RecognitionException
        Throws:
        org.antlr.runtime.RecognitionException
      • LexerGrammar

        public LexerGrammar​(String grammarText,
                            ANTLRToolListener listener)
                     throws org.antlr.runtime.RecognitionException
        Throws:
        org.antlr.runtime.RecognitionException
      • LexerGrammar

        public LexerGrammar​(String fileName,
                            String grammarText,
                            ANTLRToolListener listener)
                     throws org.antlr.runtime.RecognitionException
        Throws:
        org.antlr.runtime.RecognitionException
    • Method Detail

      • defineRule

        public boolean defineRule​(Rule r)
        Description copied from class: Grammar
        Define the specified rule in the grammar. This method assigns the rule's Rule.index according to the Grammar.ruleNumber field, and adds the Rule instance to Grammar.rules and Grammar.indexToRule.
        Overrides:
        defineRule in class Grammar
        Parameters:
        r - The rule to define in the grammar.
        Returns:
        true if the rule was added to the Grammar instance; otherwise, false if a rule with this name already existed in the grammar instance.
      • undefineRule

        public boolean undefineRule​(Rule r)
        Description copied from class: Grammar
        Undefine the specified rule from this Grammar instance. The instance r is removed from Grammar.rules and Grammar.indexToRule. This method updates the Rule.index field for all rules defined after r, and decrements Grammar.ruleNumber in preparation for adding new rules.

        This method does nothing if the current Grammar does not contain the instance r at index r.index in Grammar.indexToRule.

        Overrides:
        undefineRule in class Grammar
        Returns:
        true if the rule was removed from the Grammar instance; otherwise, false if the specified rule was not defined in the grammar.