antlr

Class MakeGrammar

Implemented Interfaces:
ANTLRGrammarParseBehavior

public class MakeGrammar
extends DefineGrammarSymbols

Field Summary

protected Stack
blocks
(package private) ExceptionSpec
currentExceptionSpec
protected boolean
grammarError
protected RuleRefElement
lastRuleRef
protected int
nested
protected RuleBlock
ruleBlock
protected RuleEndElement
ruleEnd

Fields inherited from class antlr.DefineGrammarSymbols

DEFAULT_TOKENMANAGER_NAME, analyzer, args, grammar, grammars, headerActions, language, numLexers, numParsers, numTreeParsers, thePreambleAction, tokenManagers, tool

Constructor Summary

MakeGrammar(Tool tool_, String[] args_, LLkAnalyzer analyzer_)

Method Summary

void
abortGrammar()
Abort the processing of a grammar (due to syntax errors)
protected void
addElementToCurrentAlt(AlternativeElement e)
void
beginAlt(boolean doAutoGen_)
void
beginChildList()
void
beginExceptionGroup()
Add an exception group to a rule (currently a no-op)
void
beginExceptionSpec(Token label)
Add an exception spec to an exception group or rule block
void
beginSubRule(Token label, Token start, boolean not)
void
beginTree(Token tok)
BlockContext
context()
static RuleBlock
createNextTokenRule(Grammar g, Vector lexRules, String rname)
Used to build nextToken() for the lexer.
void
defineRuleName(Token r, String access, boolean ruleAutoGen, String docComment)
Define a lexer or parser rule
void
endAlt()
void
endChildList()
void
endExceptionGroup()
void
endExceptionSpec()
void
endGrammar()
Called at the end of processing a grammar
void
endRule(String rule)
void
endSubRule()
void
endTree()
void
hasError()
Remember that a major error occured in the grammar
void
noAutoGenSubRule()
void
oneOrMoreSubRule()
void
optionalSubRule()
void
refAction(Token action)
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)
Add an exception handler to an exception spec
void
refInitAction(Token action)
void
refMemberAction(Token act)
void
refPreambleAction(Token act)
void
refReturnAction(Token returnAction)
void
refRule(Token idAssign, Token r, Token label, Token args, int autoGenType)
void
refSemPred(Token pred)
void
refStringLiteral(Token lit, Token label, int autoGenType, boolean lastInRule)
void
refToken(Token idAssign, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule)
Reference a token
void
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 grammar
void
setArgOfRuleRef(Token argAction)
static void
setBlock(AlternativeBlock b, AlternativeBlock src)
void
setRuleOption(Token key, Token value)
void
setSubruleOption(Token key, Token value)
void
setUserExceptions(String thr)
void
synPred()
void
zeroOrMoreSubRule()

Methods inherited from class antlr.DefineGrammarSymbols

_refStringLiteral, _refToken, abortGrammar, beginAlt, beginChildList, beginExceptionGroup, beginExceptionSpec, beginSubRule, beginTree, defineRuleName, defineToken, endAlt, endChildList, endExceptionGroup, endExceptionSpec, endGrammar, endOptions, endRule, endSubRule, endTree, getHeaderAction, hasError, noASTSubRule, oneOrMoreSubRule, optionalSubRule, refAction, refArgAction, refCharLiteral, refCharRange, refElementOption, refExceptionHandler, refHeaderAction, refInitAction, refMemberAction, refPreambleAction, refReturnAction, refRule, refSemPred, refStringLiteral, refToken, refTokenRange, refTokensSpecElementOption, refTreeSpecifier, refWildcard, reset, setArgOfRuleRef, setCharVocabulary, setFileOption, setGrammarOption, setRuleOption, setSubruleOption, setUserExceptions, startLexer, startParser, startTreeWalker, synPred, zeroOrMoreSubRule

Field Details

blocks

protected Stack blocks

currentExceptionSpec

(package private)  ExceptionSpec currentExceptionSpec

grammarError

protected boolean grammarError

lastRuleRef

protected RuleRefElement lastRuleRef

nested

protected int nested

ruleBlock

protected RuleBlock ruleBlock

ruleEnd

protected RuleEndElement ruleEnd

Constructor Details

MakeGrammar

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

Method Details

abortGrammar

public void abortGrammar()
Abort the processing of a grammar (due to syntax errors)
Specified by:
abortGrammar in interface ANTLRGrammarParseBehavior
Overrides:
abortGrammar in interface DefineGrammarSymbols

addElementToCurrentAlt

protected void addElementToCurrentAlt(AlternativeElement e)

beginAlt

public void beginAlt(boolean doAutoGen_)
Specified by:
beginAlt in interface ANTLRGrammarParseBehavior
Overrides:
beginAlt in interface DefineGrammarSymbols

beginChildList

public void beginChildList()
Specified by:
beginChildList in interface ANTLRGrammarParseBehavior
Overrides:
beginChildList in interface DefineGrammarSymbols

beginExceptionGroup

public void beginExceptionGroup()
Add an exception group to a rule (currently a no-op)
Specified by:
beginExceptionGroup in interface ANTLRGrammarParseBehavior
Overrides:
beginExceptionGroup in interface DefineGrammarSymbols

beginExceptionSpec

public void beginExceptionSpec(Token label)
Add an exception spec to an exception group or rule block
Specified by:
beginExceptionSpec in interface ANTLRGrammarParseBehavior
Overrides:
beginExceptionSpec in interface DefineGrammarSymbols

beginSubRule

public void beginSubRule(Token label,
                         Token start,
                         boolean not)
Specified by:
beginSubRule in interface ANTLRGrammarParseBehavior
Overrides:
beginSubRule in interface DefineGrammarSymbols

beginTree

public void beginTree(Token tok)
            throws SemanticException
Specified by:
beginTree in interface ANTLRGrammarParseBehavior
Overrides:
beginTree in interface DefineGrammarSymbols

context

public BlockContext context()

createNextTokenRule

public static RuleBlock createNextTokenRule(Grammar g,
                                            Vector lexRules,
                                            String rname)
Used to build nextToken() for the lexer. This builds a rule which has every "public" rule in the given Vector of rules as it's alternate. Each rule ref generates a Token object.
Parameters:
g - The Grammar that is being processed
lexRules - A vector of lexer rules that will be used to create an alternate block.
rname - The name of the resulting rule.

defineRuleName

public void defineRuleName(Token r,
                           String access,
                           boolean ruleAutoGen,
                           String docComment)
            throws SemanticException
Define a lexer or parser rule
Specified by:
defineRuleName in interface ANTLRGrammarParseBehavior
Overrides:
defineRuleName in interface DefineGrammarSymbols

endAlt

public void endAlt()
Specified by:
endAlt in interface ANTLRGrammarParseBehavior
Overrides:
endAlt in interface DefineGrammarSymbols

endChildList

public void endChildList()
Specified by:
endChildList in interface ANTLRGrammarParseBehavior
Overrides:
endChildList in interface DefineGrammarSymbols

endExceptionGroup

public void endExceptionGroup()
Specified by:
endExceptionGroup in interface ANTLRGrammarParseBehavior
Overrides:
endExceptionGroup in interface DefineGrammarSymbols

endExceptionSpec

public void endExceptionSpec()
Specified by:
endExceptionSpec in interface ANTLRGrammarParseBehavior
Overrides:
endExceptionSpec in interface DefineGrammarSymbols

endGrammar

public void endGrammar()
Called at the end of processing a grammar
Specified by:
endGrammar in interface ANTLRGrammarParseBehavior
Overrides:
endGrammar in interface DefineGrammarSymbols

endRule

public void endRule(String rule)
Specified by:
endRule in interface ANTLRGrammarParseBehavior
Overrides:
endRule in interface DefineGrammarSymbols

endSubRule

public void endSubRule()
Specified by:
endSubRule in interface ANTLRGrammarParseBehavior
Overrides:
endSubRule in interface DefineGrammarSymbols

endTree

public void endTree()
Specified by:
endTree in interface ANTLRGrammarParseBehavior
Overrides:
endTree in interface DefineGrammarSymbols

hasError

public void hasError()
Remember that a major error occured in the grammar
Specified by:
hasError in interface ANTLRGrammarParseBehavior
Overrides:
hasError in interface DefineGrammarSymbols

noAutoGenSubRule

public void noAutoGenSubRule()

oneOrMoreSubRule

public void oneOrMoreSubRule()
Specified by:
oneOrMoreSubRule in interface ANTLRGrammarParseBehavior
Overrides:
oneOrMoreSubRule in interface DefineGrammarSymbols

optionalSubRule

public void optionalSubRule()
Specified by:
optionalSubRule in interface ANTLRGrammarParseBehavior
Overrides:
optionalSubRule in interface DefineGrammarSymbols

refAction

public void refAction(Token action)
Specified by:
refAction in interface ANTLRGrammarParseBehavior
Overrides:
refAction in interface DefineGrammarSymbols

refArgAction

public void refArgAction(Token action)
Specified by:
refArgAction in interface ANTLRGrammarParseBehavior
Overrides:
refArgAction in interface DefineGrammarSymbols

refCharLiteral

public void refCharLiteral(Token lit,
                           Token label,
                           boolean inverted,
                           int autoGenType,
                           boolean lastInRule)
Specified by:
refCharLiteral in interface ANTLRGrammarParseBehavior
Overrides:
refCharLiteral in interface DefineGrammarSymbols

refCharRange

public void refCharRange(Token t1,
                         Token t2,
                         Token label,
                         int autoGenType,
                         boolean lastInRule)
Specified by:
refCharRange in interface ANTLRGrammarParseBehavior
Overrides:
refCharRange in interface DefineGrammarSymbols

refElementOption

public void refElementOption(Token option,
                             Token value)
Specified by:
refElementOption in interface ANTLRGrammarParseBehavior
Overrides:
refElementOption in interface DefineGrammarSymbols

refExceptionHandler

public void refExceptionHandler(Token exTypeAndName,
                                Token action)
Add an exception handler to an exception spec
Specified by:
refExceptionHandler in interface ANTLRGrammarParseBehavior
Overrides:
refExceptionHandler in interface DefineGrammarSymbols

refInitAction

public void refInitAction(Token action)
Specified by:
refInitAction in interface ANTLRGrammarParseBehavior
Overrides:
refInitAction in interface DefineGrammarSymbols

refMemberAction

public void refMemberAction(Token act)
Specified by:
refMemberAction in interface ANTLRGrammarParseBehavior
Overrides:
refMemberAction in interface DefineGrammarSymbols

refPreambleAction

public void refPreambleAction(Token act)
Specified by:
refPreambleAction in interface ANTLRGrammarParseBehavior
Overrides:
refPreambleAction in interface DefineGrammarSymbols

refReturnAction

public void refReturnAction(Token returnAction)
Specified by:
refReturnAction in interface ANTLRGrammarParseBehavior
Overrides:
refReturnAction in interface DefineGrammarSymbols

refRule

public void refRule(Token idAssign,
                    Token r,
                    Token label,
                    Token args,
                    int autoGenType)
Specified by:
refRule in interface ANTLRGrammarParseBehavior
Overrides:
refRule in interface DefineGrammarSymbols

refSemPred

public void refSemPred(Token pred)
Specified by:
refSemPred in interface ANTLRGrammarParseBehavior
Overrides:
refSemPred in interface DefineGrammarSymbols

refStringLiteral

public void refStringLiteral(Token lit,
                             Token label,
                             int autoGenType,
                             boolean lastInRule)
Specified by:
refStringLiteral in interface ANTLRGrammarParseBehavior
Overrides:
refStringLiteral in interface DefineGrammarSymbols

refToken

public void refToken(Token idAssign,
                     Token t,
                     Token label,
                     Token args,
                     boolean inverted,
                     int autoGenType,
                     boolean lastInRule)
Reference a token
Specified by:
refToken in interface ANTLRGrammarParseBehavior
Overrides:
refToken in interface DefineGrammarSymbols

refTokenRange

public void refTokenRange(Token t1,
                          Token t2,
                          Token label,
                          int autoGenType,
                          boolean lastInRule)
Specified by:
refTokenRange in interface ANTLRGrammarParseBehavior
Overrides:
refTokenRange in interface DefineGrammarSymbols

refTokensSpecElementOption

public void refTokensSpecElementOption(Token tok,
                                       Token option,
                                       Token value)
Specified by:
refTokensSpecElementOption in interface ANTLRGrammarParseBehavior
Overrides:
refTokensSpecElementOption in interface DefineGrammarSymbols

refTreeSpecifier

public void refTreeSpecifier(Token treeSpec)
Specified by:
refTreeSpecifier in interface ANTLRGrammarParseBehavior
Overrides:
refTreeSpecifier in interface DefineGrammarSymbols

refWildcard

public void refWildcard(Token t,
                        Token label,
                        int autoGenType)
Specified by:
refWildcard in interface ANTLRGrammarParseBehavior
Overrides:
refWildcard in interface DefineGrammarSymbols

reset

public void reset()
Get ready to process a new grammar
Overrides:
reset in interface DefineGrammarSymbols

setArgOfRuleRef

public void setArgOfRuleRef(Token argAction)
Specified by:
setArgOfRuleRef in interface ANTLRGrammarParseBehavior
Overrides:
setArgOfRuleRef in interface DefineGrammarSymbols

setBlock

public static void setBlock(AlternativeBlock b,
                            AlternativeBlock src)

setRuleOption

public void setRuleOption(Token key,
                          Token value)
Specified by:
setRuleOption in interface ANTLRGrammarParseBehavior
Overrides:
setRuleOption in interface DefineGrammarSymbols

setSubruleOption

public void setSubruleOption(Token key,
                             Token value)
Specified by:
setSubruleOption in interface ANTLRGrammarParseBehavior
Overrides:
setSubruleOption in interface DefineGrammarSymbols

setUserExceptions

public void setUserExceptions(String thr)
Specified by:
setUserExceptions in interface ANTLRGrammarParseBehavior
Overrides:
setUserExceptions in interface DefineGrammarSymbols

synPred

public void synPred()
Specified by:
synPred in interface ANTLRGrammarParseBehavior
Overrides:
synPred in interface DefineGrammarSymbols

zeroOrMoreSubRule

public void zeroOrMoreSubRule()
Specified by:
zeroOrMoreSubRule in interface ANTLRGrammarParseBehavior
Overrides:
zeroOrMoreSubRule in interface DefineGrammarSymbols