org.antlr.codegen
Class CTarget
java.lang.Object
org.antlr.codegen.Target
org.antlr.codegen.CTarget
public class CTarget
- extends Target
Method Summary |
protected StringTemplate |
chooseWhereCyclicDFAsGo(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate recognizerST,
StringTemplate cyclicDFAST)
|
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)
|
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. |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CTarget
public CTarget()
genRecognizerFile
protected void genRecognizerFile(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate outputFileST)
throws java.io.IOException
- Overrides:
genRecognizerFile
in class Target
- Throws:
java.io.IOException
genRecognizerHeaderFile
protected void genRecognizerHeaderFile(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate headerFileST,
java.lang.String extName)
throws java.io.IOException
- Overrides:
genRecognizerHeaderFile
in class Target
- Throws:
java.io.IOException
chooseWhereCyclicDFAsGo
protected StringTemplate chooseWhereCyclicDFAsGo(Tool tool,
CodeGenerator generator,
Grammar grammar,
StringTemplate recognizerST,
StringTemplate cyclicDFAST)
isValidActionScope
public 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. The action names themselves are not policed at the
moment so targets can add template actions w/o having to recompile
ANTLR.
- Overrides:
isValidActionScope
in class Target
getTargetCharLiteralFromANTLRCharLiteral
public java.lang.String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator,
java.lang.String literal)
- Description copied from class:
Target
- Convert from an ANTLR char literal found in a grammar file to
an equivalent char literal in the target language. For most
languages, this means leaving 'x' as 'x'. Actually, we need
to escape '
' so that it doesn't get converted to \n by
the compiler. Convert the literal to the char value and then
to an appropriate target char literal.
Expect single quotes around the incoming literal.
- Overrides:
getTargetCharLiteralFromANTLRCharLiteral
in class Target
getTargetStringLiteralFromANTLRStringLiteral
public 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. For Java, this
is the translation 'a\n"' -> "a\n\"". Expect single quotes
around the incoming literal. Just flip the quotes and replace
double quotes with \"
- Overrides:
getTargetStringLiteralFromANTLRStringLiteral
in class Target