antlr
Class DefineGrammarSymbols

java.lang.Object
  |
  +--antlr.DefineGrammarSymbols
All Implemented Interfaces:
ANTLRGrammarParseBehavior
Direct Known Subclasses:
MakeGrammar

public class DefineGrammarSymbols
extends Object
implements ANTLRGrammarParseBehavior

Untamed: 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
(package private)  LLkAnalyzer analyzer
           
(package private)  String[] args
           
(package private) static String DEFAULT_TOKENMANAGER_NAME
           
protected  Grammar grammar
           
protected  Hashtable grammars
           
protected  Hashtable headerActions
           
(package private)  String language
           
protected  int numLexers
           
protected  int numParsers
           
protected  int numTreeParsers
           
(package private)  Token thePreambleAction
           
protected  Hashtable tokenManagers
           
protected  Tool tool
           
 
Constructor Summary
DefineGrammarSymbols(Tool tool_, String[] args_, LLkAnalyzer analyzer_)
          Enabled:
 
Method Summary
 void _refStringLiteral(Token lit, Token label, int autoGenType, boolean lastInRule)
          Enabled:
 void _refToken(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule)
          Enabled: Reference a token
 void abortGrammar()
          Enabled: Abort the processing of a grammar due to syntax errors
 void beginAlt(boolean doAST_)
          Enabled:
 void beginChildList()
          Enabled:
 void beginExceptionGroup()
          Enabled:
 void beginExceptionSpec(Token label)
          Enabled:
 void beginSubRule(Token label, int line, boolean not)
          Enabled:
 void beginTree(int line)
          Enabled:
 void defineRuleName(Token r, String access, boolean ruleAutoGen, String docComment)
          Enabled: Define a lexer or parser rule
 void defineToken(Token tokname, Token tokliteral)
          Enabled: Define a token from tokens {...}.
 void endAlt()
          Enabled:
 void endChildList()
          Enabled:
 void endExceptionGroup()
          Enabled:
 void endExceptionSpec()
          Enabled:
 void endGrammar()
          Enabled:
 void endOptions()
          Enabled: Called after the optional options section, to compensate for options that may not have been set.
 void endRule(String r)
          Enabled:
 void endSubRule()
          Enabled:
 void endTree()
          Enabled:
 String getHeaderAction(String name)
          Enabled:
 void hasError()
          Enabled:
 void noASTSubRule()
          Enabled:
 void oneOrMoreSubRule()
          Enabled:
 void optionalSubRule()
          Enabled:
 void refAction(Token action)
          Enabled:
 void refArgAction(Token action)
          Enabled:
 void refCharLiteral(Token lit, Token label, boolean inverted, int autoGenType, boolean lastInRule)
          Enabled:
 void refCharRange(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule)
          Enabled:
 void refElementOption(Token option, Token value)
          Enabled:
 void refExceptionHandler(Token exTypeAndName, Token action)
          Enabled:
 void refHeaderAction(Token name, Token act)
          Enabled:
 void refInitAction(Token action)
          Enabled:
 void refMemberAction(Token act)
          Enabled:
 void refPreambleAction(Token act)
          Enabled:
 void refReturnAction(Token returnAction)
          Enabled:
 void refRule(Token idAssign, Token r, Token label, Token args, int autoGenType)
          Enabled:
 void refSemPred(Token pred)
          Enabled:
 void refStringLiteral(Token lit, Token label, int autoGenType, boolean lastInRule)
          Enabled:
 void refToken(Token assignId, Token t, Token label, Token args, boolean inverted, int autoGenType, boolean lastInRule)
          Enabled: Reference a token
 void refTokenRange(Token t1, Token t2, Token label, int autoGenType, boolean lastInRule)
          Enabled:
 void refTokensSpecElementOption(Token tok, Token option, Token value)
          Enabled:
 void refTreeSpecifier(Token treeSpec)
          Enabled:
 void refWildcard(Token t, Token label, int autoGenType)
          Enabled:
 void reset()
          Enabled: Get ready to process a new grammar
 void setArgOfRuleRef(Token argaction)
          Enabled:
 void setCharVocabulary(BitSet b)
          Enabled: Set the character vocabulary for a lexer
 void setFileOption(Token key, Token value, String filename)
          Enabled: setFileOption: Associate an option value with a key.
 void setGrammarOption(Token key, Token value)
          Enabled: setGrammarOption: Associate an option value with a key.
 void setRuleOption(Token key, Token value)
          Enabled:
 void setSubruleOption(Token key, Token value)
          Enabled:
 void setUserExceptions(String thr)
          Enabled:
 void startLexer(String file, Token name, String superClass, String doc)
          Enabled: Start a new lexer
 void startParser(String file, Token name, String superClass, String doc)
          Enabled: Start a new parser
 void startTreeWalker(String file, Token name, String superClass, String doc)
          Enabled: Start a new tree-walker
 void synPred()
          Enabled:
 void zeroOrMoreSubRule()
          Enabled:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grammars

protected Hashtable grammars

tokenManagers

protected Hashtable tokenManagers

grammar

protected Grammar grammar

tool

protected Tool tool

analyzer

LLkAnalyzer analyzer

args

String[] args

DEFAULT_TOKENMANAGER_NAME

static final String DEFAULT_TOKENMANAGER_NAME

headerActions

protected Hashtable headerActions

thePreambleAction

Token thePreambleAction

language

String language

numLexers

protected int numLexers

numParsers

protected int numParsers

numTreeParsers

protected int numTreeParsers
Constructor Detail

DefineGrammarSymbols

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

Method Detail

_refStringLiteral

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


_refToken

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


abortGrammar

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

Specified by:
abortGrammar in interface ANTLRGrammarParseBehavior

beginAlt

public void beginAlt(boolean doAST_)
Enabled:

Specified by:
beginAlt in interface ANTLRGrammarParseBehavior

beginChildList

public void beginChildList()
Enabled:

Specified by:
beginChildList in interface ANTLRGrammarParseBehavior

beginExceptionGroup

public void beginExceptionGroup()
Enabled:

Specified by:
beginExceptionGroup in interface ANTLRGrammarParseBehavior

beginExceptionSpec

public void beginExceptionSpec(Token label)
Enabled:

Specified by:
beginExceptionSpec in interface ANTLRGrammarParseBehavior

beginSubRule

public void beginSubRule(Token label,
                         int line,
                         boolean not)
Enabled:

Specified by:
beginSubRule in interface ANTLRGrammarParseBehavior

beginTree

public void beginTree(int line)
               throws SemanticException
Enabled:

Specified by:
beginTree in interface ANTLRGrammarParseBehavior
SemanticException

defineRuleName

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

Specified by:
defineRuleName in interface ANTLRGrammarParseBehavior
SemanticException

defineToken

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

Specified by:
defineToken in interface ANTLRGrammarParseBehavior

endAlt

public void endAlt()
Enabled:

Specified by:
endAlt in interface ANTLRGrammarParseBehavior

endChildList

public void endChildList()
Enabled:

Specified by:
endChildList in interface ANTLRGrammarParseBehavior

endExceptionGroup

public void endExceptionGroup()
Enabled:

Specified by:
endExceptionGroup in interface ANTLRGrammarParseBehavior

endExceptionSpec

public void endExceptionSpec()
Enabled:

Specified by:
endExceptionSpec in interface ANTLRGrammarParseBehavior

endGrammar

public void endGrammar()
Enabled:

Specified by:
endGrammar in interface ANTLRGrammarParseBehavior

endOptions

public void endOptions()
Enabled: 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 interface ANTLRGrammarParseBehavior

endRule

public void endRule(String r)
Enabled:

Specified by:
endRule in interface ANTLRGrammarParseBehavior

endSubRule

public void endSubRule()
Enabled:

Specified by:
endSubRule in interface ANTLRGrammarParseBehavior

endTree

public void endTree()
Enabled:

Specified by:
endTree in interface ANTLRGrammarParseBehavior

hasError

public void hasError()
Enabled:

Specified by:
hasError in interface ANTLRGrammarParseBehavior

noASTSubRule

public void noASTSubRule()
Enabled:

Specified by:
noASTSubRule in interface ANTLRGrammarParseBehavior

oneOrMoreSubRule

public void oneOrMoreSubRule()
Enabled:

Specified by:
oneOrMoreSubRule in interface ANTLRGrammarParseBehavior

optionalSubRule

public void optionalSubRule()
Enabled:

Specified by:
optionalSubRule in interface ANTLRGrammarParseBehavior

setUserExceptions

public void setUserExceptions(String thr)
Enabled:

Specified by:
setUserExceptions in interface ANTLRGrammarParseBehavior

refAction

public void refAction(Token action)
Enabled:

Specified by:
refAction in interface ANTLRGrammarParseBehavior

refArgAction

public void refArgAction(Token action)
Enabled:

Specified by:
refArgAction in interface ANTLRGrammarParseBehavior

refCharLiteral

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

Specified by:
refCharLiteral in interface ANTLRGrammarParseBehavior

refCharRange

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

Specified by:
refCharRange in interface ANTLRGrammarParseBehavior

refElementOption

public void refElementOption(Token option,
                             Token value)
Enabled:

Specified by:
refElementOption in interface ANTLRGrammarParseBehavior

refTokensSpecElementOption

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

Specified by:
refTokensSpecElementOption in interface ANTLRGrammarParseBehavior

refExceptionHandler

public void refExceptionHandler(Token exTypeAndName,
                                Token action)
Enabled:

Specified by:
refExceptionHandler in interface ANTLRGrammarParseBehavior

refHeaderAction

public void refHeaderAction(Token name,
                            Token act)
Enabled:

Specified by:
refHeaderAction in interface ANTLRGrammarParseBehavior

getHeaderAction

public String getHeaderAction(String name)
Enabled:


refInitAction

public void refInitAction(Token action)
Enabled:

Specified by:
refInitAction in interface ANTLRGrammarParseBehavior

refMemberAction

public void refMemberAction(Token act)
Enabled:

Specified by:
refMemberAction in interface ANTLRGrammarParseBehavior

refPreambleAction

public void refPreambleAction(Token act)
Enabled:

Specified by:
refPreambleAction in interface ANTLRGrammarParseBehavior

refReturnAction

public void refReturnAction(Token returnAction)
Enabled:

Specified by:
refReturnAction in interface ANTLRGrammarParseBehavior

refRule

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

Specified by:
refRule in interface ANTLRGrammarParseBehavior

refSemPred

public void refSemPred(Token pred)
Enabled:

Specified by:
refSemPred in interface ANTLRGrammarParseBehavior

refStringLiteral

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

Specified by:
refStringLiteral in interface ANTLRGrammarParseBehavior

refToken

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

Specified by:
refToken in interface ANTLRGrammarParseBehavior

refTokenRange

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

Specified by:
refTokenRange in interface ANTLRGrammarParseBehavior

refTreeSpecifier

public void refTreeSpecifier(Token treeSpec)
Enabled:

Specified by:
refTreeSpecifier in interface ANTLRGrammarParseBehavior

refWildcard

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

Specified by:
refWildcard in interface ANTLRGrammarParseBehavior

reset

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


setArgOfRuleRef

public void setArgOfRuleRef(Token argaction)
Enabled:

Specified by:
setArgOfRuleRef in interface ANTLRGrammarParseBehavior

setCharVocabulary

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

Specified by:
setCharVocabulary in interface ANTLRGrammarParseBehavior

setFileOption

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

Specified by:
setFileOption in interface ANTLRGrammarParseBehavior
Parameters:
key - The token containing the option name
value - The token containing the option value.

setGrammarOption

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

Specified by:
setGrammarOption in interface ANTLRGrammarParseBehavior
Parameters:
key - The token containing the option name
value - The token containing the option value.

setRuleOption

public void setRuleOption(Token key,
                          Token value)
Enabled:

Specified by:
setRuleOption in interface ANTLRGrammarParseBehavior

setSubruleOption

public void setSubruleOption(Token key,
                             Token value)
Enabled:

Specified by:
setSubruleOption in interface ANTLRGrammarParseBehavior

startLexer

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

Specified by:
startLexer in interface ANTLRGrammarParseBehavior

startParser

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

Specified by:
startParser in interface ANTLRGrammarParseBehavior

startTreeWalker

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

Specified by:
startTreeWalker in interface ANTLRGrammarParseBehavior

synPred

public void synPred()
Enabled:

Specified by:
synPred in interface ANTLRGrammarParseBehavior

zeroOrMoreSubRule

public void zeroOrMoreSubRule()
Enabled:

Specified by:
zeroOrMoreSubRule in interface ANTLRGrammarParseBehavior


comments?