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 String
The 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 TypeMethodDescriptionboolean
defineRule
(Rule r) Define the specified rule in the grammar.boolean
undefineRule
(Rule r) Undefine the specified rule from thisGrammar
instance.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:Grammar
Define the specified rule in the grammar. This method assigns the rule'sRule.index
according to theGrammar.ruleNumber
field, and adds theRule
instance toGrammar.rules
andGrammar.indexToRule
.- Overrides:
defineRule
in classGrammar
- Parameters:
r
- The rule to define in the grammar.- Returns:
true
if the rule was added to theGrammar
instance; otherwise,false
if a rule with this name already existed in the grammar instance.
-
undefineRule
Description copied from class:Grammar
Undefine the specified rule from thisGrammar
instance. The instancer
is removed fromGrammar.rules
andGrammar.indexToRule
. This method updates theRule.index
field for all rules defined afterr
, and decrementsGrammar.ruleNumber
in preparation for adding new rules.This method does nothing if the current
Grammar
does not contain the instancer
at indexr.index
inGrammar.indexToRule
.- Overrides:
undefineRule
in classGrammar
- Parameters:
r
-- Returns:
true
if the rule was removed from theGrammar
instance; otherwise,false
if the specified rule was not defined in the grammar.
-