Package org.antlr.v4.tool
Class LexerGrammar
- java.lang.Object
-
- org.antlr.v4.tool.Grammar
-
- org.antlr.v4.tool.LexerGrammar
-
- All Implemented Interfaces:
AttributeResolver
public class LexerGrammar extends Grammar
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_MODE_NAME
Grammar
implicitLexerOwner
The grammar from which this lexer grammar was derived (if implicit)MultiMap<String,Rule>
modes
DEFAULT_MODE rules are added first due to grammar syntax order-
Fields 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, name, namedActions, originalGrammar, originalTokenStream, parent, parserBlockOptions, parserOptions, parseRuleOptions, ruleRefOptions, rules, semPredOptions, sempreds, stateToGrammarRegionMap, stringLiteralToTypeMap, text, tokenNameToTypeMap, tokenOptions, tokenStream, tool, typeToStringLiteralList, typeToTokenList
-
-
Constructor Summary
Constructors Constructor Description LexerGrammar(String grammarText)
LexerGrammar(String fileName, String grammarText, ANTLRToolListener listener)
LexerGrammar(String grammarText, ANTLRToolListener listener)
LexerGrammar(Tool tool, GrammarRootAST ast)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
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 Detail
-
DEFAULT_MODE_NAME
public static final String DEFAULT_MODE_NAME
- See Also:
- Constant Field Values
-
implicitLexerOwner
public Grammar implicitLexerOwner
The grammar from which this lexer grammar was derived (if implicit)
-
-
Constructor Detail
-
LexerGrammar
public LexerGrammar(Tool tool, GrammarRootAST ast)
-
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'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
public boolean undefineRule(Rule r)
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
- Returns:
true
if the rule was removed from theGrammar
instance; otherwise,false
if the specified rule was not defined in the grammar.
-
-