|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.codegen.Target
public class Target
The code generator for ANTLR can usually be retargeted just by providing a new X.stg file for language X, however, sometimes the files that must be generated vary enough that some X-specific functionality is required. For example, in C, you must generate header files whereas in Java you do not. Other languages may want to keep DFA separate from the main generated recognizer file. The notion of a Code Generator target abstracts out the creation of the various files. As new language targets get added to the ANTLR system, this target class may have to be altered to handle more functionality. Eventually, just about all language generation issues will be expressible in terms of these methods. If org.antlr.codegen.XTarget class exists, it is used else Target base class is used. I am using a superclass rather than an interface for this target concept because I can add functionality later without breaking previously written targets (extra interface methods would force adding dummy functions to all code generator target classes).
Field Summary | |
---|---|
protected java.lang.String[] |
targetCharValueEscape
For pure strings of Java 16-bit unicode char, how can we display it in the target language as a literal. |
Constructor Summary | |
---|---|
Target()
|
Method Summary | |
---|---|
java.lang.String |
encodeIntAsCharEscape(int v)
|
protected void |
genRecognizerFile(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate outputFileST)
|
protected void |
genRecognizerHeaderFile(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate headerFileST,
java.lang.String extName)
|
int |
getMaxCharValue(CodeGenerator generator)
Some targets only support ASCII or 8-bit chars/strings. |
java.lang.String |
getTarget64BitStringFromValue(long word)
Convert long to 0xNNNNNNNNNNNNNNNN by default for spitting out with bitsets. |
java.lang.String |
getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator,
java.lang.String literal)
Convert from an ANTLR char literal found in a grammar file to an equivalent char literal in the target language. |
java.lang.String |
getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator,
java.lang.String literal)
Convert from an ANTLR string literal found in a grammar file to an equivalent string literal in the target language. |
java.lang.String |
getTargetStringLiteralFromString(java.lang.String s)
|
java.lang.String |
getTargetStringLiteralFromString(java.lang.String s,
boolean quoted)
Given a random string of Java unicode chars, return a new string with optionally appropriate quote characters for target language and possibly with some escaped characters. |
java.lang.String |
getTokenTypeAsTargetLabel(CodeGenerator generator,
int ttype)
Target must be able to override the labels used for token types |
boolean |
isValidActionScope(int grammarType,
java.lang.String scope)
Is scope in @scope::name {action} valid for this kind of grammar? Targets like C++ may want to allow new scopes like headerfile or some such. |
protected void |
performGrammarAnalysis(CodeGenerator generator,
Grammar grammar)
|
java.util.List |
postProcessAction(java.util.List chunks,
antlr.Token actionToken)
Give target a chance to do some postprocessing on actions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String[] targetCharValueEscape
Constructor Detail |
---|
public Target()
Method Detail |
---|
protected void genRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, StringTemplate outputFileST) throws java.io.IOException
java.io.IOException
protected void genRecognizerHeaderFile(Tool tool, CodeGenerator generator, Grammar grammar, StringTemplate headerFileST, java.lang.String extName) throws java.io.IOException
java.io.IOException
protected void performGrammarAnalysis(CodeGenerator generator, Grammar grammar)
public boolean isValidActionScope(int grammarType, java.lang.String scope)
public java.lang.String getTokenTypeAsTargetLabel(CodeGenerator generator, int ttype)
public java.lang.String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, java.lang.String literal)
public java.lang.String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator generator, java.lang.String literal)
public java.lang.String getTargetStringLiteralFromString(java.lang.String s, boolean quoted)
public java.lang.String getTargetStringLiteralFromString(java.lang.String s)
public java.lang.String getTarget64BitStringFromValue(long word)
public java.lang.String encodeIntAsCharEscape(int v)
public int getMaxCharValue(CodeGenerator generator)
public java.util.List postProcessAction(java.util.List chunks, antlr.Token actionToken)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |