public class Grammar extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Grammar.Decision |
class |
Grammar.LabelElementPair |
Modifier and Type | Field and Description |
---|---|
protected Map |
actions
Map a scope to a map of name:action pairs.
|
protected boolean |
allDecisionDFACreated |
static String[] |
ANTLRLiteralCharValueEscape
Given a char, we need to be able to show as an ANTLR literal.
|
static int[] |
ANTLRLiteralEscapedCharValue
When converting ANTLR char and string literals, here is the
value set of escape chars.
|
static String |
ARTIFICIAL_TOKENS_RULENAME |
boolean |
atLeastOneBacktrackOption
At least one backtrack=true in rule or decision or grammar.
|
boolean |
atLeastOneRuleMemoizes
At least one rule has memoize=true
|
static String |
AUTO_GENERATED_TOKEN_NAME_PREFIX |
Set<GrammarAST> |
blocksWithSemPreds
Track decisions with syn preds specified for reporting.
|
Set<GrammarAST> |
blocksWithSynPreds
Track decisions with syn preds specified for reporting.
|
protected boolean |
builtFromString
We need a way to detect when a lexer grammar is autogenerated from
another grammar or we are just sending in a string representing a
grammar.
|
static int |
CHAR_LABEL |
protected IntSet |
charVocabulary
TODO: hook this to the charVocabulary option
|
static int |
COMBINED |
CompositeGrammar |
composite
If this grammar is part of a larger composite grammar via delegate
statement, then this points at the composite.
|
CompositeGrammarTree |
compositeTreeNode
A pointer back into grammar tree.
|
protected int |
decisionCount
Be able to assign a number to every decision in grammar;
decisions in 1..n
|
Set<DFA> |
decisionsWhoseDFAsUsesSemPreds
Track decisions that actually use the syn preds in the DFA.
|
Set<DFA> |
decisionsWhoseDFAsUsesSynPreds
Track decisions that actually use the syn preds in the DFA.
|
static Map |
defaultBlockOptions
What are the default options for a subrule?
|
static Map |
defaultLexerBlockOptions |
static Map |
defaultOptions |
static String |
defaultTokenOption |
protected Set<Rule> |
delegatedRuleReferences
The list of all rules referenced in this grammar, not defined here,
and defined in a delegate grammar.
|
long |
DFACreationWallClockTimeInMS
How long in ms did it take to build DFAs for this grammar?
If this grammar is a combined grammar, it only records time for
the parser grammar component.
|
static Set |
doNotCopyOptionsToLexer |
protected boolean |
externalAnalysisAbort
An external tool requests that DFA analysis abort prematurely.
|
protected NFAFactory |
factory |
protected String |
fileName
What file name holds this grammar?
|
static String |
FRAGMENT_RULE_MODIFIER |
protected CodeGenerator |
generator
If non-null, this is the code generator we will use to generate
recognizers in the target language.
|
protected int |
global_k
Is there a global fixed lookahead set for this grammar?
If 0, nothing specified.
|
static String |
GRAMMAR_FILE_EXTENSION |
protected GrammarAST |
grammarTree
An AST that records entire input grammar with all rules.
|
static String[] |
grammarTypeToFileNameSuffix |
static String[] |
grammarTypeToString |
static String |
IGNORE_STRING_IN_GRAMMAR_FILE_NAME |
boolean |
implicitLexer
Was this created from a COMBINED grammar?
|
protected Vector<Grammar.Decision> |
indexToDecision
Each subrule/rule is a decision point and we must track them so we
can go back later and build DFA predictors for them.
|
static int |
INITIAL_DECISION_LIST_SIZE |
static int |
INVALID_RULE_INDEX |
String |
label
If this is a delegate of another grammar, this is the label used
as an instance var by that grammar to point at this grammar.
|
static String[] |
LabelTypeToString |
protected Set<Rule> |
leftRecursiveRules
A list of all rules that are in any left-recursive cycle.
|
static Set |
legalBlockOptions |
static Set |
legalLexerOptions |
static Set |
legalParserOptions |
static Set |
legalTokenOptions
Legal options for terminal refs like ID
|
static Set |
legalTreeParserOptions |
static int |
LEXER |
static String |
LEXER_GRAMMAR_FILE_EXTENSION
used for generating lexer temp files
|
protected org.antlr.stringtemplate.StringTemplate |
lexerGrammarST
For merged lexer/parsers, we must construct a separate lexer spec.
|
List<String> |
lexerRuleNamesInCombined
The ANTLRParser tracks lexer rules when reading combined grammars
so we can build the Tokens rule.
|
LL1Analyzer |
ll1Analyzer |
String |
name
What name did the user provide for this grammar?
|
NameSpaceChecker |
nameSpaceChecker |
protected LinkedHashMap<String,Rule> |
nameToRuleMap
Map a rule to it's Rule object
|
protected LinkedHashMap |
nameToSynpredASTMap
When we read in a grammar, we track the list of syntactic predicates
and build faux rules for them later.
|
NFA |
nfa
The NFA that represents the grammar with edges labelled with tokens
or epsilon.
|
int |
numberOfManualLookaheadOptions |
int |
numberOfSemanticPredicates |
protected Map |
options
A list of options specified at the grammar level such as language=Java.
|
Set<String> |
overriddenRules
If this rule is a delegate, some rules might be overridden; don't
want to gen code for them.
|
static int |
PARSER |
static int |
RULE_LABEL |
static int |
RULE_LIST_LABEL |
protected Set<GrammarAST> |
ruleRefs
The unique set of all rule references in any rule; set of tree node
objects so two refs to same rule can exist but at different line/position.
|
protected Set<GrammarAST> |
scopedRuleRefs |
protected Map |
scopes
Track the scopes defined outside of rules and the scopes associated
with all rules (even if empty).
|
Set |
setOfDFAWhoseAnalysisTimedOut |
Set<Integer> |
setOfNondeterministicDecisionNumbers |
Set<Integer> |
setOfNondeterministicDecisionNumbersResolvedWithPredicates |
static String |
SYNPRED_RULE_PREFIX |
static String |
SYNPREDGATE_ACTION_NAME |
Set<String> |
synPredNamesUsedInDFA
Track names of preds so we can avoid generating preds that aren't used
Computed during NFA to DFA conversion.
|
static int |
TOKEN_LABEL |
static int |
TOKEN_LIST_LABEL |
protected antlr.TokenStreamRewriteEngine |
tokenBuffer
This is the buffer of *all* tokens found in the grammar file
including whitespace tokens etc...
|
protected Set<antlr.Token> |
tokenIDRefs
The unique set of all token ID references in any rule
|
Tool |
tool |
static int |
TREE_PARSER |
int |
type
What type of grammar is this: lexer, parser, tree walker
|
static MultiMap<Integer,Integer> |
validDelegations
Set of valid imports.
|
static int |
WILDCARD_TREE_LABEL |
static int |
WILDCARD_TREE_LIST_LABEL |
Constructor and Description |
---|
Grammar()
Useful for when you are sure that you are not part of a composite
already.
|
Grammar(String grammarString)
Used for testing; only useful on noncomposite grammars.
|
Grammar(Tool tool,
String grammarString)
Used for testing and Interp/RandomPhrase.
|
Grammar(Tool tool,
String fileName,
CompositeGrammar composite)
Create a grammar from file name.
|
Modifier and Type | Method and Description |
---|---|
GrammarAST |
addArtificialMatchTokensRule(GrammarAST grammarAST,
List<String> ruleNames,
List<String> delegateNames,
boolean filterMode)
Parse a rule we add artificially that is a list of the other lexer
rules like this: "Tokens : ID | INT | SEMI ;" nextToken() will invoke
this to set the current token.
|
protected void |
addDelegateGrammar(Grammar delegateGrammar)
add new delegate to composite tree
|
boolean |
allDecisionDFAHaveBeenCreated() |
void |
altReferencesRule(String enclosingRuleName,
GrammarAST refScopeAST,
GrammarAST refAST,
int outerAltNum)
Track a rule reference within an outermost alt of a rule.
|
void |
altReferencesTokenID(String ruleName,
GrammarAST refAST,
int outerAltNum)
Track a token reference within an outermost alt of a rule.
|
int |
assignDecisionNumber(NFAState state) |
boolean |
buildAST() |
void |
buildNFA() |
boolean |
buildTemplate() |
List |
checkAllRulesForLeftRecursion() |
void |
checkAllRulesForUselessLabels()
Remove all labels on rule refs whose target rules have no return value.
|
void |
checkNameSpaceAndActions()
ANALYZE ACTIONS, LOOKING FOR LABEL AND ATTR REFS, sanity check
|
void |
checkRuleReference(GrammarAST scopeAST,
GrammarAST refAST,
GrammarAST argsAST,
String currentRuleName) |
IntSet |
complement(int atom) |
IntSet |
complement(IntSet set)
For lexer grammars, return everything in unicode not in set.
|
String |
computeTokenNameFromLiteral(int tokenType,
String literal)
given a token type and the text of the literal, come up with a
decent token type label.
|
protected Grammar.Decision |
createDecision(int decision) |
DFA |
createLL_1_LookaheadDFA(int decision) |
DFA |
createLookaheadDFA(int decision,
boolean wackTempStructures) |
void |
createLookaheadDFAs()
For each decision in this grammar, compute a single DFA using the
NFA states associated with the decision.
|
void |
createLookaheadDFAs(boolean wackTempStructures) |
AttributeScope |
createParameterScope(String ruleName,
antlr.Token argAction) |
AttributeScope |
createReturnScope(String ruleName,
antlr.Token retAction) |
AttributeScope |
createRuleScope(String ruleName,
antlr.Token scopeAction) |
void |
createRuleStartAndStopNFAStates()
Define all the rule begin/end NFAStates to solve forward reference
issues.
|
protected void |
dealWithTreeFilterMode() |
AttributeScope |
defineGlobalScope(String name,
antlr.Token scopeAction) |
void |
defineGrammarSymbols() |
protected void |
defineLabel(Rule r,
antlr.Token label,
GrammarAST element,
int type)
Define a label defined in a rule r; check the validity then ask the
Rule object to actually define it.
|
void |
defineLexerRuleForAliasedStringLiteral(String tokenID,
String literal,
int tokenType)
If someone does PLUS='+' in the parser, must make sure we get
"PLUS : '+' ;" in lexer not "T73 : '+';"
|
void |
defineLexerRuleForStringLiteral(String literal,
int tokenType) |
void |
defineLexerRuleFoundInParser(antlr.Token ruleToken,
GrammarAST ruleAST) |
void |
defineNamedAction(GrammarAST ampersandAST,
String scope,
GrammarAST nameAST,
GrammarAST actionAST)
Given @scope::name {action} define it for this grammar.
|
void |
defineRule(antlr.Token ruleToken,
String modifier,
Map options,
GrammarAST tree,
GrammarAST argActionAST,
int numAlts)
Define a new rule.
|
void |
defineRuleListLabel(String ruleName,
antlr.Token label,
GrammarAST element) |
void |
defineRuleRefLabel(String ruleName,
antlr.Token label,
GrammarAST ruleRef) |
String |
defineSyntacticPredicate(GrammarAST blockAST,
String currentRuleName)
Define a new predicate and get back its name for use in building
a semantic predicate reference to the syn pred.
|
void |
defineToken(String text,
int tokenType)
Define a token at a particular token type value.
|
void |
defineTokenListLabel(String ruleName,
antlr.Token label,
GrammarAST element) |
void |
defineTokenRefLabel(String ruleName,
antlr.Token label,
GrammarAST tokenRef) |
void |
defineWildcardTreeLabel(String ruleName,
antlr.Token label,
GrammarAST tokenRef) |
void |
defineWildcardTreeListLabel(String ruleName,
antlr.Token label,
GrammarAST tokenRef) |
protected void |
examineAllExecutableActions()
Before generating code, we examine all actions that can have
$x.y and $y stuff in them because some code generation depends on
Rule.referencedPredefinedRuleAttributes.
|
void |
externallyAbortNFAToDFAConversion()
Terminate DFA creation (grammar analysis).
|
LookaheadSet |
FIRST(NFAState s) |
boolean |
generateMethodForRule(String ruleName)
Should codegen.g gen rule for ruleName?
If synpred, only gen if used in a DFA.
|
Map |
getActions() |
IntSet |
getAllCharValues()
If there is a char vocabulary, use it; else return min to max char
as defined by the target.
|
Set<Rule> |
getAllImportedRules()
Get set of all rules imported from all delegate grammars even if
indirectly delegated.
|
static String |
getANTLRCharLiteralForChar(int c)
Return a string representing the escaped char for code c.
|
protected List |
getArtificialRulesForSyntacticPredicates(ANTLRParser parser,
LinkedHashMap nameToSynpredASTMap)
for any syntactic predicates, we need to define rules for them; they will get
defined automatically like any other rule.
|
boolean |
getAutoBacktrackMode(int decision) |
Object |
getBlockOption(GrammarAST blockAST,
String key) |
static int |
getCharValueFromGrammarCharLiteral(String literal)
Given a literal like (the 3 char sequence with single quotes) 'a',
return the int value of 'a'.
|
CodeGenerator |
getCodeGenerator() |
protected Grammar.Decision |
getDecision(int decision) |
GrammarAST |
getDecisionBlockAST(int decision) |
NFAState |
getDecisionNFAStartState(int decision) |
List |
getDecisionNFAStartStateList() |
String |
getDefaultActionScope(int grammarType)
Given a grammar type, what should be the default action scope?
If I say @members in a COMBINED grammar, for example, the
default scope should be "parser".
|
Set<Rule> |
getDelegatedRuleReferences() |
Set<Rule> |
getDelegatedRules()
Get the set of Rules that need to have manual delegations
like "void rule() { importedGrammar.rule(); }"
If this grammar is master, get list of all rule definitions from all
delegate grammars.
|
List<String> |
getDelegateNames() |
List<Grammar> |
getDelegates()
Get list of all delegates from all grammars directly or indirectly
imported into this grammar.
|
Grammar |
getDelegator()
Who's my direct parent grammar?
|
List<Grammar> |
getDelegators()
Get list of all delegators.
|
List<Grammar> |
getDirectDelegates() |
String |
getFileName() |
AttributeScope |
getGlobalScope(String name)
Get a global scope
|
Map |
getGlobalScopes() |
boolean |
getGrammarIsRoot() |
int |
getGrammarMaxLookahead() |
GrammarAST |
getGrammarTree() |
String |
getGrammarTypeString() |
String |
getImplicitlyGeneratedLexerFileName() |
List<Grammar> |
getIndirectDelegates()
Get delegates below direct delegates
|
Set<String> |
getLabels(Set<GrammarAST> rewriteElements,
int labelType)
Given a set of all rewrite elements on right of ->, filter for
label types such as Grammar.TOKEN_LABEL, Grammar.TOKEN_LIST_LABEL, ...
|
Set<Rule> |
getLeftRecursiveRules()
Return a list of left-recursive rules; no analysis can be done
successfully on these.
|
String |
getLexerGrammar()
If the grammar is a combined grammar, return the text of the implicit
lexer grammar.
|
Map |
getLineColumnToLookaheadDFAMap() |
Object |
getLocallyDefinedOption(String key) |
Rule |
getLocallyDefinedRule(String ruleName) |
DFA |
getLookaheadDFA(int decision) |
List |
getLookaheadDFAColumnsForLineInFile(int line)
returns a list of column numbers for all decisions
on a particular line so ANTLRWorks choose the decision
depending on the location of the cursor (otherwise,
ANTLRWorks has to give the *exact* location which
is not easy from the user point of view).
|
DFA |
getLookaheadDFAFromPositionInFile(int line,
int col)
Useful for ANTLRWorks to map position in file to the DFA for display
|
int |
getMaxCharValue()
What is the max char value possible for this grammar's target? Use
unicode max if no target defined.
|
int |
getMaxTokenType()
How many token types have been allocated so far?
|
int |
getNewTokenType()
Return a new unique integer in the token type space
|
NFAState |
getNFAStateForAltOfDecision(NFAState decisionState,
int alt)
Get the ith alternative (1..n) from a decision; return null when
an invalid alt is requested.
|
int |
getNumberOfAltsForDecisionNFA(NFAState decisionState)
Decisions are linked together with transition(1).
|
int |
getNumberOfCyclicDecisions() |
int |
getNumberOfDecisions() |
Object |
getOption(String key) |
String |
getRecognizerName()
Get the name of the generated recognizer; may or may not be same
as grammar name.
|
Rule |
getRule(String ruleName) |
Rule |
getRule(String scopeName,
String ruleName) |
int |
getRuleIndex(String ruleName) |
int |
getRuleIndex(String scopeName,
String ruleName) |
String |
getRuleModifier(String ruleName) |
String |
getRuleName(int ruleIndex) |
Collection<Rule> |
getRules() |
NFAState |
getRuleStartState(String ruleName) |
NFAState |
getRuleStartState(String scopeName,
String ruleName) |
NFAState |
getRuleStopState(String ruleName) |
IntSet |
getSetFromRule(TreeToNFAConverter nfabuilder,
String ruleName)
Get the set equivalent (if any) of the indicated rule from this
grammar.
|
Set<String> |
getStringLiterals()
Get the list of ANTLR String literals
|
GrammarAST |
getSyntacticPredicate(String name) |
LinkedHashMap |
getSyntacticPredicates() |
String |
getTokenDisplayName(int ttype)
Given a token type, get a meaningful name for it such as the ID
or string literal.
|
Set<String> |
getTokenDisplayNames()
Get a list of all token IDs and literals that have an associated
token type.
|
Set |
getTokenIDs()
Get the list of tokens that are IDs like BLOCK and LPAREN
|
int |
getTokenType(String tokenName) |
IntSet |
getTokenTypes()
Return a set of all possible token or char types for this grammar
|
Collection |
getTokenTypesWithoutID()
Return an ordered integer list of token types that have no
corresponding token ID like INT or KEYWORD_BEGIN; for stuff
like 'begin'.
|
Tool |
getTool() |
static StringBuffer |
getUnescapedStringFromGrammarStringLiteral(String literal)
ANTLR does not convert escape sequences during the parse phase because
it could not know how to print String/char literals back out when
printing grammars etc...
|
int |
getUserMaxLookahead(int decision) |
String |
grammarTreeToString(GrammarAST t) |
String |
grammarTreeToString(GrammarAST t,
boolean showActions) |
void |
importGrammar(GrammarAST grammarNameAST,
String label)
Import the rules/tokens of a delegate grammar.
|
int |
importTokenVocabulary(Grammar importFromGr)
Pull your token definitions from an existing grammar in memory.
|
int |
importTokenVocabulary(GrammarAST tokenVocabOptionAST,
String vocabName)
Load a vocab file
|
boolean |
isAtomTokenType(int ttype) |
boolean |
isBuiltFromString() |
boolean |
isEmptyRule(GrammarAST block)
Rules like "a : ;" and "a : {...} ;" should not generate
try/catch blocks for RecognitionException.
|
boolean |
isValidSet(TreeToNFAConverter nfabuilder,
GrammarAST t)
Given set tree like ( SET A B ), check that A and B
are both valid sets themselves, else we must tree like a BLOCK
|
boolean |
legalOption(String key) |
LookaheadSet |
LOOK(NFAState s) |
protected List<IntervalSet> |
makeEdgeSetsDisjoint(List<IntervalSet> edges) |
boolean |
NFAToDFAConversionExternallyAborted() |
boolean |
optionIsValid(String key,
Object value) |
void |
parseAndBuildAST() |
void |
parseAndBuildAST(Reader r) |
void |
printGrammar(PrintStream output) |
void |
referenceRuleLabelPredefinedAttribute(String ruleName)
To yield smaller, more readable code, track which rules have their
predefined attributes accessed.
|
protected void |
removeUselessLabels(Map ruleToElementLabelPairMap)
A label on a rule is useless if the rule has no return value, no
tree or template output, and it is not referenced in an action.
|
boolean |
rewriteMode() |
void |
setCodeGenerator(CodeGenerator generator) |
void |
setDecisionBlockAST(int decision,
GrammarAST blockAST) |
void |
setDecisionNFA(int decision,
NFAState state) |
void |
setFileName(String fileName) |
void |
setGrammarContent(String grammarString) |
void |
setLookaheadDFA(int decision,
DFA lookaheadDFA)
Set the lookahead DFA for a particular decision.
|
void |
setName(String name) |
String |
setOption(String key,
Object value,
antlr.Token optionsStartToken)
Save the option key/value pair and process it; return the key
or null if invalid option.
|
void |
setOptions(Map options,
antlr.Token optionsStartToken) |
void |
setRuleAST(String ruleName,
GrammarAST t) |
void |
setSynPredGateIfNotAlready(org.antlr.stringtemplate.StringTemplate gateST) |
void |
setTool(Tool tool) |
void |
synPredUsedInDFA(DFA dfa,
SemanticContext semCtx) |
String |
toString() |
boolean |
validImport(Grammar delegate)
Many imports are illegal such as lexer into a tree grammar
|
public static final String SYNPRED_RULE_PREFIX
public static final String GRAMMAR_FILE_EXTENSION
public static final String LEXER_GRAMMAR_FILE_EXTENSION
public static final int INITIAL_DECISION_LIST_SIZE
public static final int INVALID_RULE_INDEX
public static final int RULE_LABEL
public static final int TOKEN_LABEL
public static final int RULE_LIST_LABEL
public static final int TOKEN_LIST_LABEL
public static final int CHAR_LABEL
public static final int WILDCARD_TREE_LABEL
public static final int WILDCARD_TREE_LIST_LABEL
public static String[] LabelTypeToString
public static final String ARTIFICIAL_TOKENS_RULENAME
public static final String FRAGMENT_RULE_MODIFIER
public static final String SYNPREDGATE_ACTION_NAME
public static int[] ANTLRLiteralEscapedCharValue
public static String[] ANTLRLiteralCharValueEscape
public static final int LEXER
public static final int PARSER
public static final int TREE_PARSER
public static final int COMBINED
public static final String[] grammarTypeToString
public static final String[] grammarTypeToFileNameSuffix
public static MultiMap<Integer,Integer> validDelegations
protected antlr.TokenStreamRewriteEngine tokenBuffer
public static final String IGNORE_STRING_IN_GRAMMAR_FILE_NAME
public static final String AUTO_GENERATED_TOKEN_NAME_PREFIX
public String name
public int type
protected Map options
public static final Set legalLexerOptions
public static final Set legalParserOptions
public static final Set legalTreeParserOptions
public static final Set doNotCopyOptionsToLexer
public static final Map defaultOptions
public static final Set legalBlockOptions
public static final Map defaultBlockOptions
public static final Map defaultLexerBlockOptions
public static final Set legalTokenOptions
public static final String defaultTokenOption
protected int global_k
protected Map actions
public NFA nfa
protected NFAFactory factory
public CompositeGrammar composite
public CompositeGrammarTree compositeTreeNode
public String label
protected IntSet charVocabulary
public Tool tool
protected Set<GrammarAST> ruleRefs
protected Set<GrammarAST> scopedRuleRefs
protected Set<antlr.Token> tokenIDRefs
protected int decisionCount
protected Set<Rule> leftRecursiveRules
protected boolean externalAnalysisAbort
protected LinkedHashMap nameToSynpredASTMap
public boolean atLeastOneRuleMemoizes
public boolean atLeastOneBacktrackOption
public boolean implicitLexer
protected LinkedHashMap<String,Rule> nameToRuleMap
public Set<String> overriddenRules
protected Set<Rule> delegatedRuleReferences
NameSpaceChecker.lookForReferencesToUndefinedSymbols()
public List<String> lexerRuleNamesInCombined
protected Map scopes
protected GrammarAST grammarTree
protected Vector<Grammar.Decision> indexToDecision
protected CodeGenerator generator
public NameSpaceChecker nameSpaceChecker
public LL1Analyzer ll1Analyzer
protected org.antlr.stringtemplate.StringTemplate lexerGrammarST
protected String fileName
public long DFACreationWallClockTimeInMS
public int numberOfSemanticPredicates
public int numberOfManualLookaheadOptions
public Set<Integer> setOfNondeterministicDecisionNumbersResolvedWithPredicates
public Set setOfDFAWhoseAnalysisTimedOut
public Set<GrammarAST> blocksWithSynPreds
public Set<DFA> decisionsWhoseDFAsUsesSynPreds
public Set<String> synPredNamesUsedInDFA
public Set<GrammarAST> blocksWithSemPreds
public Set<DFA> decisionsWhoseDFAsUsesSemPreds
protected boolean allDecisionDFACreated
protected boolean builtFromString
public Grammar(Tool tool, String fileName, CompositeGrammar composite)
public Grammar()
public Grammar(String grammarString) throws antlr.RecognitionException, antlr.TokenStreamException
antlr.RecognitionException
antlr.TokenStreamException
public void setFileName(String fileName)
public String getFileName()
public void setName(String name)
public void setGrammarContent(String grammarString) throws antlr.RecognitionException
antlr.RecognitionException
public void parseAndBuildAST() throws IOException
IOException
public void parseAndBuildAST(Reader r)
protected void dealWithTreeFilterMode()
public void defineGrammarSymbols()
public void checkNameSpaceAndActions()
public boolean validImport(Grammar delegate)
public String getLexerGrammar()
public String getImplicitlyGeneratedLexerFileName()
public String getRecognizerName()
public GrammarAST addArtificialMatchTokensRule(GrammarAST grammarAST, List<String> ruleNames, List<String> delegateNames, boolean filterMode)
protected List getArtificialRulesForSyntacticPredicates(ANTLRParser parser, LinkedHashMap nameToSynpredASTMap)
public void createRuleStartAndStopNFAStates()
public void buildNFA()
public void createLookaheadDFAs()
public void createLookaheadDFAs(boolean wackTempStructures)
public DFA createLL_1_LookaheadDFA(int decision)
protected List<IntervalSet> makeEdgeSetsDisjoint(List<IntervalSet> edges)
public DFA createLookaheadDFA(int decision, boolean wackTempStructures)
public void externallyAbortNFAToDFAConversion()
public boolean NFAToDFAConversionExternallyAborted()
public int getNewTokenType()
public void defineToken(String text, int tokenType)
public void defineRule(antlr.Token ruleToken, String modifier, Map options, GrammarAST tree, GrammarAST argActionAST, int numAlts)
public String defineSyntacticPredicate(GrammarAST blockAST, String currentRuleName)
public LinkedHashMap getSyntacticPredicates()
public GrammarAST getSyntacticPredicate(String name)
public void synPredUsedInDFA(DFA dfa, SemanticContext semCtx)
public void defineNamedAction(GrammarAST ampersandAST, String scope, GrammarAST nameAST, GrammarAST actionAST)
public void setSynPredGateIfNotAlready(org.antlr.stringtemplate.StringTemplate gateST)
public Map getActions()
public String getDefaultActionScope(int grammarType)
public void defineLexerRuleFoundInParser(antlr.Token ruleToken, GrammarAST ruleAST)
public void defineLexerRuleForAliasedStringLiteral(String tokenID, String literal, int tokenType)
public void defineLexerRuleForStringLiteral(String literal, int tokenType)
public int getRuleIndex(String ruleName)
public String getRuleName(int ruleIndex)
public boolean generateMethodForRule(String ruleName)
public AttributeScope defineGlobalScope(String name, antlr.Token scopeAction)
public AttributeScope createReturnScope(String ruleName, antlr.Token retAction)
public AttributeScope createRuleScope(String ruleName, antlr.Token scopeAction)
public AttributeScope createParameterScope(String ruleName, antlr.Token argAction)
public AttributeScope getGlobalScope(String name)
public Map getGlobalScopes()
protected void defineLabel(Rule r, antlr.Token label, GrammarAST element, int type)
public void defineTokenRefLabel(String ruleName, antlr.Token label, GrammarAST tokenRef)
public void defineWildcardTreeLabel(String ruleName, antlr.Token label, GrammarAST tokenRef)
public void defineWildcardTreeListLabel(String ruleName, antlr.Token label, GrammarAST tokenRef)
public void defineRuleRefLabel(String ruleName, antlr.Token label, GrammarAST ruleRef)
public void defineTokenListLabel(String ruleName, antlr.Token label, GrammarAST element)
public void defineRuleListLabel(String ruleName, antlr.Token label, GrammarAST element)
public Set<String> getLabels(Set<GrammarAST> rewriteElements, int labelType)
protected void examineAllExecutableActions()
public void checkAllRulesForUselessLabels()
protected void removeUselessLabels(Map ruleToElementLabelPairMap)
public void altReferencesRule(String enclosingRuleName, GrammarAST refScopeAST, GrammarAST refAST, int outerAltNum)
public void altReferencesTokenID(String ruleName, GrammarAST refAST, int outerAltNum)
public void referenceRuleLabelPredefinedAttribute(String ruleName)
public List checkAllRulesForLeftRecursion()
public Set<Rule> getLeftRecursiveRules()
public void checkRuleReference(GrammarAST scopeAST, GrammarAST refAST, GrammarAST argsAST, String currentRuleName)
public boolean isEmptyRule(GrammarAST block)
public boolean isAtomTokenType(int ttype)
public int getTokenType(String tokenName)
public Set getTokenIDs()
public Collection getTokenTypesWithoutID()
public Set<String> getTokenDisplayNames()
public static int getCharValueFromGrammarCharLiteral(String literal)
public static StringBuffer getUnescapedStringFromGrammarStringLiteral(String literal)
public int importTokenVocabulary(Grammar importFromGr)
public void importGrammar(GrammarAST grammarNameAST, String label)
protected void addDelegateGrammar(Grammar delegateGrammar)
public int importTokenVocabulary(GrammarAST tokenVocabOptionAST, String vocabName)
public String getTokenDisplayName(int ttype)
public String getGrammarTypeString()
public int getGrammarMaxLookahead()
public String setOption(String key, Object value, antlr.Token optionsStartToken)
public boolean legalOption(String key)
public void setOptions(Map options, antlr.Token optionsStartToken)
public Object getBlockOption(GrammarAST blockAST, String key)
public int getUserMaxLookahead(int decision)
public boolean getAutoBacktrackMode(int decision)
public boolean buildAST()
public boolean rewriteMode()
public boolean isBuiltFromString()
public boolean buildTemplate()
public Collection<Rule> getRules()
public Set<Rule> getDelegatedRules()
public Set<Rule> getAllImportedRules()
public List<Grammar> getDelegates()
public List<Grammar> getIndirectDelegates()
public List<Grammar> getDelegators()
public Grammar getDelegator()
public boolean getGrammarIsRoot()
public void setRuleAST(String ruleName, GrammarAST t)
public int assignDecisionNumber(NFAState state)
protected Grammar.Decision getDecision(int decision)
protected Grammar.Decision createDecision(int decision)
public List getDecisionNFAStartStateList()
public NFAState getDecisionNFAStartState(int decision)
public DFA getLookaheadDFA(int decision)
public GrammarAST getDecisionBlockAST(int decision)
public List getLookaheadDFAColumnsForLineInFile(int line)
public DFA getLookaheadDFAFromPositionInFile(int line, int col)
public Map getLineColumnToLookaheadDFAMap()
public int getNumberOfDecisions()
public int getNumberOfCyclicDecisions()
public void setLookaheadDFA(int decision, DFA lookaheadDFA)
public void setDecisionNFA(int decision, NFAState state)
public void setDecisionBlockAST(int decision, GrammarAST blockAST)
public boolean allDecisionDFAHaveBeenCreated()
public int getMaxTokenType()
public int getMaxCharValue()
public IntSet getTokenTypes()
public IntSet getAllCharValues()
public static String getANTLRCharLiteralForChar(int c)
public IntSet complement(IntSet set)
public IntSet complement(int atom)
public boolean isValidSet(TreeToNFAConverter nfabuilder, GrammarAST t)
public IntSet getSetFromRule(TreeToNFAConverter nfabuilder, String ruleName) throws antlr.RecognitionException
antlr.RecognitionException
public int getNumberOfAltsForDecisionNFA(NFAState decisionState)
public NFAState getNFAStateForAltOfDecision(NFAState decisionState, int alt)
public LookaheadSet FIRST(NFAState s)
public LookaheadSet LOOK(NFAState s)
public void setCodeGenerator(CodeGenerator generator)
public CodeGenerator getCodeGenerator()
public GrammarAST getGrammarTree()
public Tool getTool()
public void setTool(Tool tool)
public String computeTokenNameFromLiteral(int tokenType, String literal)
public String grammarTreeToString(GrammarAST t)
public String grammarTreeToString(GrammarAST t, boolean showActions)
public void printGrammar(PrintStream output)
Copyright © 2020. All rights reserved.