Logo Search packages:      
Sourcecode: antlr version File versions

antlr::CodeGenerator Class Reference

Inheritance diagram for antlr::CodeGenerator:

antlr::CppCodeGenerator antlr::CSharpCodeGenerator antlr::DiagnosticCodeGenerator antlr::DocBookCodeGenerator antlr::HTMLCodeGenerator antlr::JavaCodeGenerator

List of all members.


Detailed Description

A generic ANTLR code generator. All code generators Derive from this class.

A CodeGenerator knows about a Grammar data structure and a grammar analyzer. The Grammar is walked to generate the appropriate code for both a parser and lexer (if present). This interface may change slightly so that the lexer is itself living inside of a Grammar object (in which case, this class generates only one recognizer). The main method to call is gen(), which initiates all code gen.

The interaction of the code generator with the analyzer is simple: each subrule block calls deterministic() before generating code for the block. Method deterministic() sets lookahead caches in each Alternative object. Technically, a code generator doesn't need the grammar analyzer if all lookahead analysis is done at runtime, but this would result in a slower parser.

This class provides a set of support utilities to handle argument list parsing and so on.

Author:
Terence Parr, John Lilley
Version:
2.00a
See also:
antlr.JavaCodeGenerator

antlr.DiagnosticCodeGenerator

antlr.LLkAnalyzer

antlr.Grammar

antlr.AlternativeElement

antlr.Lookahead

Definition at line 50 of file CodeGenerator.java.


Public Member Functions

 CodeGenerator ()
abstract void gen (ZeroOrMoreBlock blk)
abstract void gen (WildcardElement wc)
abstract void gen (TreeWalkerGrammar g) throws IOException
abstract void gen (TreeElement t)
abstract void gen (TokenRefElement atom)
abstract void gen (TokenRangeElement r)
abstract void gen (StringLiteralElement atom)
abstract void gen (RuleRefElement rr)
abstract void gen (ParserGrammar g) throws IOException
abstract void gen (OneOrMoreBlock blk)
abstract void gen (LexerGrammar g) throws IOException
abstract void gen (CharRangeElement r)
abstract void gen (CharLiteralElement atom)
abstract void gen (BlockEndElement end)
abstract void gen (AlternativeBlock blk)
abstract void gen (ActionElement action)
abstract void gen ()
abstract String getASTCreateString (GrammarAtom atom, String str)
abstract String getASTCreateString (Vector v)
String getFIRSTBitSet (String ruleName, int k)
String getFOLLOWBitSet (String ruleName, int k)
abstract String mapTreeId (String id, ActionTransInfo tInfo)
String processStringForASTConstructor (String str)
void setAnalyzer (LLkGrammarAnalyzer analyzer_)
void setBehavior (DefineGrammarSymbols behavior_)
void setTool (Tool tool)

Static Public Member Functions

static String decodeLexerRuleName (String id)
static boolean elementsAreRange (int[] elems)
static String encodeLexerRuleName (String id)
static String reverseLexerRuleName (String id)

Static Public Attributes

static String TokenTypesFileExt = ".txt"
static String TokenTypesFileSuffix = "TokenTypes"

Protected Member Functions

void _print (String s)
void _printAction (String s)
void _println (String s)
String extractIdOfAction (String s, int line, int column)
String extractIdOfAction (Token t)
String extractTypeOfAction (String s, int line, int column)
String extractTypeOfAction (Token t)
void genTokenInterchange (TokenManager tm) throws IOException
String getBitsetName (int index)
int markBitsetForGen (BitSet p)
void print (String s)
void printAction (String s)
void println (String s)
void printTabs ()
abstract String processActionForSpecialSymbols (String actionStr, int line, RuleBlock currentRule, ActionTransInfo tInfo)
String removeAssignmentFromDeclaration (String d)
void setGrammar (Grammar g)

Protected Attributes

LLkGrammarAnalyzer analyzer
antlr.Tool antlrTool
DefineGrammarSymbols behavior
Vector bitsetsUsed
int bitsetTestThreshold = DEFAULT_BITSET_TEST_THRESHOLD
CharFormatter charFormatter
transient PrintWriter currentOutput
boolean DEBUG_CODE_GENERATOR = false
Grammar grammar = null
int makeSwitchThreshold = DEFAULT_MAKE_SWITCH_THRESHOLD
int tabs = 0

Static Protected Attributes

static final int BITSET_OPTIMIZE_INIT_THRESHOLD = 8
static final int DEFAULT_BITSET_TEST_THRESHOLD = 4
static final int DEFAULT_MAKE_SWITCH_THRESHOLD = 2

Private Member Functions

void reset ()

Static Private Attributes

static boolean OLD_ACTION_TRANSLATOR = true

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index