|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.antlr.runtime.BaseRecognizer
org.antlr.runtime.tree.TreeParser
jaitools.jiffle.parser.ErrorHandlingTreeParser
jaitools.jiffle.parser.AbstractSourceGenerator
public abstract class AbstractSourceGenerator
Base class for tree parsers that generate Jiffle runtime source.
The runtime source generator is created from the ANTLR grammar
(RuntimeSourceGenerator.g. This class provides a small number
of common methods and fields.
| Field Summary | |
|---|---|
protected String |
baseClassName
The name of the base class for the runtime class. |
protected String |
className
The runtime class name. |
protected List<String> |
imports
The imports to be included with the runtime class. |
protected Jiffle.RuntimeModel |
model
The runtime model to generate source for. |
protected String |
pkgName
The package name to use for the runtime class. |
protected int |
varIndex
A counter used in naming variables inserted into the runtime source. |
| Fields inherited from class jaitools.jiffle.parser.ErrorHandlingTreeParser |
|---|
errorReporter |
| Fields inherited from class org.antlr.runtime.tree.TreeParser |
|---|
DOWN, input, UP |
| Fields inherited from class org.antlr.runtime.BaseRecognizer |
|---|
DEFAULT_TOKEN_CHANNEL, HIDDEN, INITIAL_FOLLOW_STACK_SIZE, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, NEXT_TOKEN_RULE_NAME, state |
| Constructor Summary | |
|---|---|
|
AbstractSourceGenerator(org.antlr.runtime.tree.TreeNodeStream input)
Constructor called by ANTLR. |
protected |
AbstractSourceGenerator(org.antlr.runtime.tree.TreeNodeStream input,
org.antlr.runtime.RecognizerSharedState state)
Constructor called by ANTLR. |
| Method Summary | |
|---|---|
protected void |
addImport(String... importNames)
Adds the given imports to those that will be included in the runtime source. |
protected abstract org.antlr.runtime.RuleReturnScope |
generate()
Starts generating source code based on the abstract syntax tree produced by the Jiffle compiler. |
protected String |
getOptionExpr(String name,
String value)
Gets the runtime source for a script option name:value pair. |
protected String |
getRuntimeExpr(String name,
List<String> argTypes)
Looks up the runtime source for a Jiffle function. |
protected String |
getRuntimeExpr(String name,
String... argTypes)
Looks up the runtime source for a Jiffle function. |
String |
getSource()
Returns the source for the runtime class. |
void |
setBaseClassName(String baseClassName)
Sets the runtime base class name. |
void |
setRuntimeModel(Jiffle.RuntimeModel model)
Sets the runtime model. |
abstract void |
setTemplateLib(org.antlr.stringtemplate.StringTemplateGroup templateLib)
Used internally to set the string templates for source generation. |
| Methods inherited from class jaitools.jiffle.parser.ErrorHandlingTreeParser |
|---|
emitErrorMessage, getErrorReporter, setErrorReporter |
| Methods inherited from class org.antlr.runtime.tree.TreeParser |
|---|
getCurrentInputSymbol, getErrorHeader, getErrorMessage, getMissingSymbol, getSourceName, getTreeNodeStream, matchAny, recoverFromMismatchedToken, reset, setTreeNodeStream, traceIn, traceOut |
| Methods inherited from class org.antlr.runtime.BaseRecognizer |
|---|
alreadyParsedRule, beginResync, combineFollows, computeContextSensitiveRuleFOLLOW, computeErrorRecoverySet, consumeUntil, consumeUntil, displayRecognitionError, endResync, failed, getBacktrackingLevel, getGrammarFileName, getNumberOfSyntaxErrors, getRuleInvocationStack, getRuleInvocationStack, getRuleMemoization, getRuleMemoizationCacheSize, getTokenErrorDisplay, getTokenNames, match, memoize, mismatchIsMissingToken, mismatchIsUnwantedToken, pushFollow, recover, recoverFromMismatchedSet, reportError, setBacktrackingLevel, toStrings, traceIn, traceOut |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Jiffle.RuntimeModel model
protected String pkgName
protected List<String> imports
protected String className
protected String baseClassName
protected int varIndex
| Constructor Detail |
|---|
public AbstractSourceGenerator(org.antlr.runtime.tree.TreeNodeStream input)
input - AST node stream
protected AbstractSourceGenerator(org.antlr.runtime.tree.TreeNodeStream input,
org.antlr.runtime.RecognizerSharedState state)
input - AST node streamstate - parser state (not used by Jiffle directly)| Method Detail |
|---|
public void setRuntimeModel(Jiffle.RuntimeModel model)
setRuntimeModel in interface SourceGeneratormodel - runtime modelpublic void setBaseClassName(String baseClassName)
setBaseClassName in interface SourceGeneratorbaseClassName - base class name
public String getSource()
throws JiffleException
getSource in interface SourceGeneratorJiffleException - on errors creating source
protected abstract org.antlr.runtime.RuleReturnScope generate()
throws org.antlr.runtime.RecognitionException
org.antlr.runtime.RecognitionException - on errors processing the ASTpublic abstract void setTemplateLib(org.antlr.stringtemplate.StringTemplateGroup templateLib)
templateLib - source generation templates
protected String getRuntimeExpr(String name,
List<String> argTypes)
name - function nameargTypes - argument type names; null or empty for no-arg functions
protected String getRuntimeExpr(String name,
String... argTypes)
name - function nameargTypes - argument type names; null or empty for no-arg functions
protected String getOptionExpr(String name,
String value)
name - option namevalue - option value
protected void addImport(String... importNames)
importNames - fully qualified class names
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||