Package antlr
Class DefineGrammarSymbols
java.lang.Object
antlr.DefineGrammarSymbols
- All Implemented Interfaces:
ANTLRGrammarParseBehavior
- Direct Known Subclasses:
MakeGrammar
DefineGrammarSymbols is a behavior for the ANTLRParser that adds all
the token and rule symbols to the grammar symbol table.
Token types are assigned to token symbols in this class also.
The token type for a token is done in the order seen (lexically).
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) LLkAnalyzer
(package private) String[]
(package private) static final String
protected Grammar
protected Hashtable
protected Hashtable
(package private) String
protected int
protected int
protected int
(package private) Token
protected Hashtable
protected Tool
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
_refStringLiteral
(Token lit, Token label, int autoGenType, boolean lastInRule) void
_refToken
(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule) Reference a tokenvoid
Abort the processing of a grammar due to syntax errorsvoid
beginAlt
(boolean doAST_) void
void
void
beginExceptionSpec
(Token label) void
beginSubRule
(Token label, Token start, boolean not) void
void
defineRuleName
(Token r, String access, boolean ruleAutoGen, String docComment) Define a lexer or parser rulevoid
defineToken
(Token tokname, Token tokliteral) Define a token from tokens {...}.void
endAlt()
void
void
void
void
void
Called after the optional options section, to compensate for options that may not have been set.void
void
void
endTree()
getHeaderAction
(String name) int
getHeaderActionLine
(String name) void
hasError()
void
void
void
void
void
refArgAction
(Token action) void
refCharLiteral
(Token lit, Token label, boolean inverted, int autoGenType, boolean lastInRule) void
refCharRange
(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule) void
refElementOption
(Token option, Token value) void
refExceptionHandler
(Token exTypeAndName, Token action) void
refHeaderAction
(Token name, Token act) void
refInitAction
(Token action) void
refMemberAction
(Token act) void
refPreambleAction
(Token act) void
refReturnAction
(Token returnAction) void
void
refSemPred
(Token pred) void
refStringLiteral
(Token lit, Token label, int autoGenType, boolean lastInRule) void
refToken
(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule) Reference a tokenvoid
refTokenRange
(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule) void
refTokensSpecElementOption
(Token tok, Token option, Token value) void
refTreeSpecifier
(Token treeSpec) void
refWildcard
(Token t, Token label, int autoGenType) void
reset()
Get ready to process a new grammarvoid
setArgOfRuleRef
(Token argaction) void
Set the character vocabulary for a lexervoid
setFileOption
(Token key, Token value, String filename) setFileOption: Associate an option value with a key.void
setGrammarOption
(Token key, Token value) setGrammarOption: Associate an option value with a key.void
setRuleOption
(Token key, Token value) void
setSubruleOption
(Token key, Token value) void
setUserExceptions
(String thr) void
startLexer
(String file, Token name, String superClass, String doc) Start a new lexervoid
startParser
(String file, Token name, String superClass, String doc) Start a new parservoid
startTreeWalker
(String file, Token name, String superClass, String doc) Start a new tree-walkervoid
synPred()
void
-
Field Details
-
grammars
-
tokenManagers
-
grammar
-
tool
-
analyzer
LLkAnalyzer analyzer -
args
String[] args -
DEFAULT_TOKENMANAGER_NAME
- See Also:
-
headerActions
-
thePreambleAction
Token thePreambleAction -
language
String language -
numLexers
protected int numLexers -
numParsers
protected int numParsers -
numTreeParsers
protected int numTreeParsers
-
-
Constructor Details
-
DefineGrammarSymbols
-
-
Method Details
-
_refStringLiteral
-
_refToken
public void _refToken(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule) Reference a token -
abortGrammar
public void abortGrammar()Abort the processing of a grammar due to syntax errors- Specified by:
abortGrammar
in interfaceANTLRGrammarParseBehavior
-
beginAlt
public void beginAlt(boolean doAST_) - Specified by:
beginAlt
in interfaceANTLRGrammarParseBehavior
-
beginChildList
public void beginChildList()- Specified by:
beginChildList
in interfaceANTLRGrammarParseBehavior
-
beginExceptionGroup
public void beginExceptionGroup()- Specified by:
beginExceptionGroup
in interfaceANTLRGrammarParseBehavior
-
beginExceptionSpec
- Specified by:
beginExceptionSpec
in interfaceANTLRGrammarParseBehavior
-
beginSubRule
- Specified by:
beginSubRule
in interfaceANTLRGrammarParseBehavior
-
beginTree
- Specified by:
beginTree
in interfaceANTLRGrammarParseBehavior
- Throws:
SemanticException
-
defineRuleName
public void defineRuleName(Token r, String access, boolean ruleAutoGen, String docComment) throws SemanticException Define a lexer or parser rule- Specified by:
defineRuleName
in interfaceANTLRGrammarParseBehavior
- Throws:
SemanticException
-
defineToken
Define a token from tokens {...}. Must be label and literal or just label or just a literal.- Specified by:
defineToken
in interfaceANTLRGrammarParseBehavior
-
endAlt
public void endAlt()- Specified by:
endAlt
in interfaceANTLRGrammarParseBehavior
-
endChildList
public void endChildList()- Specified by:
endChildList
in interfaceANTLRGrammarParseBehavior
-
endExceptionGroup
public void endExceptionGroup()- Specified by:
endExceptionGroup
in interfaceANTLRGrammarParseBehavior
-
endExceptionSpec
public void endExceptionSpec()- Specified by:
endExceptionSpec
in interfaceANTLRGrammarParseBehavior
-
endGrammar
public void endGrammar()- Specified by:
endGrammar
in interfaceANTLRGrammarParseBehavior
-
endOptions
public void endOptions()Called after the optional options section, to compensate for options that may not have been set. This method is bigger than it needs to be, but is much more clear if I delineate all the cases.- Specified by:
endOptions
in interfaceANTLRGrammarParseBehavior
-
endRule
- Specified by:
endRule
in interfaceANTLRGrammarParseBehavior
-
endSubRule
public void endSubRule()- Specified by:
endSubRule
in interfaceANTLRGrammarParseBehavior
-
endTree
public void endTree()- Specified by:
endTree
in interfaceANTLRGrammarParseBehavior
-
hasError
public void hasError()- Specified by:
hasError
in interfaceANTLRGrammarParseBehavior
-
noASTSubRule
public void noASTSubRule()- Specified by:
noASTSubRule
in interfaceANTLRGrammarParseBehavior
-
oneOrMoreSubRule
public void oneOrMoreSubRule()- Specified by:
oneOrMoreSubRule
in interfaceANTLRGrammarParseBehavior
-
optionalSubRule
public void optionalSubRule()- Specified by:
optionalSubRule
in interfaceANTLRGrammarParseBehavior
-
setUserExceptions
- Specified by:
setUserExceptions
in interfaceANTLRGrammarParseBehavior
-
refAction
- Specified by:
refAction
in interfaceANTLRGrammarParseBehavior
-
refArgAction
- Specified by:
refArgAction
in interfaceANTLRGrammarParseBehavior
-
refCharLiteral
public void refCharLiteral(Token lit, Token label, boolean inverted, int autoGenType, boolean lastInRule) - Specified by:
refCharLiteral
in interfaceANTLRGrammarParseBehavior
-
refCharRange
- Specified by:
refCharRange
in interfaceANTLRGrammarParseBehavior
-
refElementOption
- Specified by:
refElementOption
in interfaceANTLRGrammarParseBehavior
-
refTokensSpecElementOption
- Specified by:
refTokensSpecElementOption
in interfaceANTLRGrammarParseBehavior
-
refExceptionHandler
- Specified by:
refExceptionHandler
in interfaceANTLRGrammarParseBehavior
-
refHeaderAction
- Specified by:
refHeaderAction
in interfaceANTLRGrammarParseBehavior
-
getHeaderAction
-
getHeaderActionLine
-
refInitAction
- Specified by:
refInitAction
in interfaceANTLRGrammarParseBehavior
-
refMemberAction
- Specified by:
refMemberAction
in interfaceANTLRGrammarParseBehavior
-
refPreambleAction
- Specified by:
refPreambleAction
in interfaceANTLRGrammarParseBehavior
-
refReturnAction
- Specified by:
refReturnAction
in interfaceANTLRGrammarParseBehavior
-
refRule
- Specified by:
refRule
in interfaceANTLRGrammarParseBehavior
-
refSemPred
- Specified by:
refSemPred
in interfaceANTLRGrammarParseBehavior
-
refStringLiteral
- Specified by:
refStringLiteral
in interfaceANTLRGrammarParseBehavior
-
refToken
public void refToken(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule) Reference a token- Specified by:
refToken
in interfaceANTLRGrammarParseBehavior
-
refTokenRange
- Specified by:
refTokenRange
in interfaceANTLRGrammarParseBehavior
-
refTreeSpecifier
- Specified by:
refTreeSpecifier
in interfaceANTLRGrammarParseBehavior
-
refWildcard
- Specified by:
refWildcard
in interfaceANTLRGrammarParseBehavior
-
reset
public void reset()Get ready to process a new grammar -
setArgOfRuleRef
- Specified by:
setArgOfRuleRef
in interfaceANTLRGrammarParseBehavior
-
setCharVocabulary
Set the character vocabulary for a lexer- Specified by:
setCharVocabulary
in interfaceANTLRGrammarParseBehavior
-
setFileOption
setFileOption: Associate an option value with a key. This applies to options for an entire grammar file.- Specified by:
setFileOption
in interfaceANTLRGrammarParseBehavior
- Parameters:
key
- The token containing the option namevalue
- The token containing the option value.
-
setGrammarOption
setGrammarOption: Associate an option value with a key. This function forwards to Grammar.setOption for some options.- Specified by:
setGrammarOption
in interfaceANTLRGrammarParseBehavior
- Parameters:
key
- The token containing the option namevalue
- The token containing the option value.
-
setRuleOption
- Specified by:
setRuleOption
in interfaceANTLRGrammarParseBehavior
-
setSubruleOption
- Specified by:
setSubruleOption
in interfaceANTLRGrammarParseBehavior
-
startLexer
Start a new lexer- Specified by:
startLexer
in interfaceANTLRGrammarParseBehavior
-
startParser
Start a new parser- Specified by:
startParser
in interfaceANTLRGrammarParseBehavior
-
startTreeWalker
Start a new tree-walker- Specified by:
startTreeWalker
in interfaceANTLRGrammarParseBehavior
-
synPred
public void synPred()- Specified by:
synPred
in interfaceANTLRGrammarParseBehavior
-
zeroOrMoreSubRule
public void zeroOrMoreSubRule()- Specified by:
zeroOrMoreSubRule
in interfaceANTLRGrammarParseBehavior
-