Package org.antlr.v4.tool
Class LexerGrammar
java.lang.Object
org.antlr.v4.tool.Grammar
org.antlr.v4.tool.LexerGrammar
- All Implemented Interfaces:
AttributeResolver
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe grammar from which this lexer grammar was derived (if implicit)DEFAULT_MODE rules are added first due to grammar syntax orderFields inherited from class org.antlr.v4.tool.Grammar
actionOptions, ast, atn, AUTO_GENERATED_TOKEN_NAME_PREFIX, caseInsensitiveOptionName, channelNameToValueMap, channelValueToNameList, decisionDFAs, decisionLOOK, doNotCopyOptionsToLexer, fileName, GRAMMAR_FROM_STRING_NAME, grammarAndLabelRefTypeToScope, implicitLexer, importedGrammars, indexToPredMap, indexToRule, INVALID_RULE_NAME, INVALID_TOKEN_NAME, lexerActions, lexerBlockOptions, lexerOptions, lexerRuleOptions, maxChannelType, maxTokenType, name, namedActions, originalGrammar, originalTokenStream, parent, parserBlockOptions, parserOptions, parseRuleOptions, ruleNumber, ruleRefOptions, rules, semPredOptions, sempreds, stateToGrammarRegionMap, stringLiteralRuleNumber, stringLiteralToTypeMap, text, tokenNameToTypeMap, tokenOptions, tokenStream, tool, typeToStringLiteralList, typeToTokenList -
Constructor Summary
ConstructorsConstructorDescriptionLexerGrammar(String grammarText) LexerGrammar(String fileName, String grammarText, ANTLRToolListener listener) LexerGrammar(String grammarText, ANTLRToolListener listener) LexerGrammar(Tool tool, GrammarRootAST ast) -
Method Summary
Modifier and TypeMethodDescriptionbooleandefineRule(Rule r) Define the specified rule in the grammar.booleanundefineRule(Rule r) Undefine the specified rule from thisGrammarinstance.Methods inherited from class org.antlr.v4.tool.Grammar
createGrammarParserInterpreter, createLexerInterpreter, createParserInterpreter, defAlias, defineAction, defineChannelName, defineChannelName, defineStringLiteral, defineStringLiteral, defineTokenAlias, defineTokenName, defineTokenName, getAllCharValues, getAllImportedGrammars, getATN, getChannelValue, getDefaultActionScope, getGrammarAncestors, getGrammarTypeToFileNameSuffix, getImplicitLexer, getImportedGrammar, getImportedGrammars, getIndexToPredicateMap, getLanguage, getMaxCharValue, getMaxTokenType, getNewChannelNumber, getNewTokenType, getOptionString, getOutermostGrammar, getPredicateDisplayString, getRecognizerName, getRule, getRule, getRule, getRuleNames, getSemanticContextDisplayString, getStateToGrammarRegion, getStateToGrammarRegionMap, getStringLiteralAliasesFromLexerRules, getStringLiteralLexerRuleName, getStringLiterals, getTokenDisplayName, getTokenDisplayNames, getTokenLiteralNames, getTokenName, getTokenName, getTokenNames, getTokenStream, getTokenSymbolicNames, getTokenType, getTokenTypes, getType, getTypeString, getVocabulary, importTokensFromTokensFile, importVocab, initTokenSymbolTables, isCombined, isLexer, isParser, isTokenName, joinPredicateOperands, load, loadImportedGrammars, resolvesToAttributeDict, resolvesToLabel, resolvesToListLabel, resolvesToToken, resolveToAttribute, resolveToAttribute, setChannelNameForValue, setLookaheadDFA, setNodeOptions, setTokenForType
-
Field Details
-
DEFAULT_MODE_NAME
- See Also:
-
implicitLexerOwner
The grammar from which this lexer grammar was derived (if implicit) -
modes
DEFAULT_MODE rules are added first due to grammar syntax order
-
-
Constructor Details
-
LexerGrammar
-
LexerGrammar
- 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 Details
-
defineRule
Description copied from class:GrammarDefine the specified rule in the grammar. This method assigns the rule'sRule.indexaccording to theGrammar.ruleNumberfield, and adds theRuleinstance toGrammar.rulesandGrammar.indexToRule.- Overrides:
defineRulein classGrammar- Parameters:
r- The rule to define in the grammar.- Returns:
trueif the rule was added to theGrammarinstance; otherwise,falseif a rule with this name already existed in the grammar instance.
-
undefineRule
Description copied from class:GrammarUndefine the specified rule from thisGrammarinstance. The instanceris removed fromGrammar.rulesandGrammar.indexToRule. This method updates theRule.indexfield for all rules defined afterr, and decrementsGrammar.ruleNumberin preparation for adding new rules.This method does nothing if the current
Grammardoes not contain the instancerat indexr.indexinGrammar.indexToRule.- Overrides:
undefineRulein classGrammar- Parameters:
r-- Returns:
trueif the rule was removed from theGrammarinstance; otherwise,falseif the specified rule was not defined in the grammar.
-