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 StringDEFAULT_MODE_NAMEGrammarimplicitLexerOwnerThe grammar from which this lexer grammar was derived (if implicit)MultiMap<String,Rule>modesDEFAULT_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 booleandefineRule(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 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: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
public boolean undefineRule(Rule r)
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- Returns:
trueif the rule was removed from theGrammarinstance; otherwise,falseif the specified rule was not defined in the grammar.
-
-