antlr

Class DefineGrammarSymbols

public class DefineGrammarSymbols extends Object implements ANTLRGrammarParseBehavior

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
LLkAnalyzeranalyzer
String[]args
static StringDEFAULT_TOKENMANAGER_NAME
protected Grammargrammar
protected Hashtablegrammars
protected HashtableheaderActions
Stringlanguage
protected intnumLexers
protected intnumParsers
protected intnumTreeParsers
TokenthePreambleAction
protected HashtabletokenManagers
protected Tooltool
Constructor Summary
DefineGrammarSymbols(Tool tool_, String[] args_, LLkAnalyzer analyzer_)
Method Summary
voidabortGrammar()
Abort the processing of a grammar due to syntax errors
voidbeginAlt(boolean doAST_)
voidbeginChildList()
voidbeginExceptionGroup()
voidbeginExceptionSpec(Token label)
voidbeginSubRule(Token label, Token start, boolean not)
voidbeginTree(Token tok)
voiddefineRuleName(Token r, String access, boolean ruleAutoGen, String docComment)
Define a lexer or parser rule
voiddefineToken(Token tokname, Token tokliteral)
Define a token from tokens {...}.
voidendAlt()
voidendChildList()
voidendExceptionGroup()
voidendExceptionSpec()
voidendGrammar()
voidendOptions()
Called after the optional options section, to compensate for options that may not have been set.
voidendRule(String r)
voidendSubRule()
voidendTree()
StringgetHeaderAction(String name)
intgetHeaderActionLine(String name)
voidhasError()
voidnoASTSubRule()
voidoneOrMoreSubRule()
voidoptionalSubRule()
voidrefAction(Token action)
voidrefArgAction(Token action)
voidrefCharLiteral(Token lit, Token label, boolean inverted, int autoGenType, boolean lastInRule)
voidrefCharRange(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule)
voidrefElementOption(Token option, Token value)
voidrefExceptionHandler(Token exTypeAndName, Token action)
voidrefHeaderAction(Token name, Token act)
voidrefInitAction(Token action)
voidrefMemberAction(Token act)
voidrefPreambleAction(Token act)
voidrefReturnAction(Token returnAction)
voidrefRule(Token idAssign, Token r, Token label, Token args, int autoGenType)
voidrefSemPred(Token pred)
voidrefStringLiteral(Token lit, Token label, int autoGenType, boolean lastInRule)
voidrefToken(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule)
Reference a token
voidrefTokenRange(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule)
voidrefTokensSpecElementOption(Token tok, Token option, Token value)
voidrefTreeSpecifier(Token treeSpec)
voidrefWildcard(Token t, Token label, int autoGenType)
voidreset()
Get ready to process a new grammar
voidsetArgOfRuleRef(Token argaction)
voidsetCharVocabulary(BitSet b)
Set the character vocabulary for a lexer
voidsetFileOption(Token key, Token value, String filename)
setFileOption: Associate an option value with a key.
voidsetGrammarOption(Token key, Token value)
setGrammarOption: Associate an option value with a key.
voidsetRuleOption(Token key, Token value)
voidsetSubruleOption(Token key, Token value)
voidsetUserExceptions(String thr)
voidstartLexer(String file, Token name, String superClass, String doc)
Start a new lexer
voidstartParser(String file, Token name, String superClass, String doc)
Start a new parser
voidstartTreeWalker(String file, Token name, String superClass, String doc)
Start a new tree-walker
voidsynPred()
voidzeroOrMoreSubRule()
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 token

Field Detail

analyzer

LLkAnalyzer analyzer

args

String[] args

DEFAULT_TOKENMANAGER_NAME

static final String DEFAULT_TOKENMANAGER_NAME

grammar

protected Grammar grammar

grammars

protected Hashtable grammars

headerActions

protected Hashtable headerActions

language

String language

numLexers

protected int numLexers

numParsers

protected int numParsers

numTreeParsers

protected int numTreeParsers

thePreambleAction

Token thePreambleAction

tokenManagers

protected Hashtable tokenManagers

tool

protected Tool tool

Constructor Detail

DefineGrammarSymbols

public DefineGrammarSymbols(Tool tool_, String[] args_, LLkAnalyzer analyzer_)

Method Detail

abortGrammar

public void abortGrammar()
Abort the processing of a grammar due to syntax errors

beginAlt

public void beginAlt(boolean doAST_)

beginChildList

public void beginChildList()

beginExceptionGroup

public void beginExceptionGroup()

beginExceptionSpec

public void beginExceptionSpec(Token label)

beginSubRule

public void beginSubRule(Token label, Token start, boolean not)

beginTree

public void beginTree(Token tok)

defineRuleName

public void defineRuleName(Token r, String access, boolean ruleAutoGen, String docComment)
Define a lexer or parser rule

defineToken

public void defineToken(Token tokname, Token tokliteral)
Define a token from tokens {...}. Must be label and literal or just label or just a literal.

endAlt

public void endAlt()

endChildList

public void endChildList()

endExceptionGroup

public void endExceptionGroup()

endExceptionSpec

public void endExceptionSpec()

endGrammar

public void endGrammar()

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.

endRule

public void endRule(String r)

endSubRule

public void endSubRule()

endTree

public void endTree()

getHeaderAction

public String getHeaderAction(String name)

getHeaderActionLine

public int getHeaderActionLine(String name)

hasError

public void hasError()

noASTSubRule

public void noASTSubRule()

oneOrMoreSubRule

public void oneOrMoreSubRule()

optionalSubRule

public void optionalSubRule()

refAction

public void refAction(Token action)

refArgAction

public void refArgAction(Token action)

refCharLiteral

public void refCharLiteral(Token lit, Token label, boolean inverted, int autoGenType, boolean lastInRule)

refCharRange

public void refCharRange(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule)

refElementOption

public void refElementOption(Token option, Token value)

refExceptionHandler

public void refExceptionHandler(Token exTypeAndName, Token action)

refHeaderAction

public void refHeaderAction(Token name, Token act)

refInitAction

public void refInitAction(Token action)

refMemberAction

public void refMemberAction(Token act)

refPreambleAction

public void refPreambleAction(Token act)

refReturnAction

public void refReturnAction(Token returnAction)

refRule

public void refRule(Token idAssign, Token r, Token label, Token args, int autoGenType)

refSemPred

public void refSemPred(Token pred)

refStringLiteral

public void refStringLiteral(Token lit, Token label, int autoGenType, boolean lastInRule)

refToken

public void refToken(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule)
Reference a token

refTokenRange

public void refTokenRange(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule)

refTokensSpecElementOption

public void refTokensSpecElementOption(Token tok, Token option, Token value)

refTreeSpecifier

public void refTreeSpecifier(Token treeSpec)

refWildcard

public void refWildcard(Token t, Token label, int autoGenType)

reset

public void reset()
Get ready to process a new grammar

setArgOfRuleRef

public void setArgOfRuleRef(Token argaction)

setCharVocabulary

public void setCharVocabulary(BitSet b)
Set the character vocabulary for a lexer

setFileOption

public void setFileOption(Token key, Token value, String filename)
setFileOption: Associate an option value with a key. This applies to options for an entire grammar file.

Parameters: key The token containing the option name value The token containing the option value.

setGrammarOption

public void setGrammarOption(Token key, Token value)
setGrammarOption: Associate an option value with a key. This function forwards to Grammar.setOption for some options.

Parameters: key The token containing the option name value The token containing the option value.

setRuleOption

public void setRuleOption(Token key, Token value)

setSubruleOption

public void setSubruleOption(Token key, Token value)

setUserExceptions

public void setUserExceptions(String thr)

startLexer

public void startLexer(String file, Token name, String superClass, String doc)
Start a new lexer

startParser

public void startParser(String file, Token name, String superClass, String doc)
Start a new parser

startTreeWalker

public void startTreeWalker(String file, Token name, String superClass, String doc)
Start a new tree-walker

synPred

public void synPred()

zeroOrMoreSubRule

public void zeroOrMoreSubRule()

_refStringLiteral

public void _refStringLiteral(Token lit, Token label, int autoGenType, boolean lastInRule)

_refToken

public void _refToken(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule)
Reference a token