类 CTarget
- java.lang.Object
-
- org.antlr.codegen.Target
-
- org.antlr.codegen.CTarget
-
public class CTarget extends Target
-
-
字段概要
-
从类继承的字段 org.antlr.codegen.Target
targetCharValueEscape
-
-
构造器概要
构造器 构造器 说明 CTarget()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected org.stringtemplate.v4.ST
chooseWhereCyclicDFAsGo(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST recognizerST, org.stringtemplate.v4.ST cyclicDFAST)
protected void
genRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST outputFileST)
protected void
genRecognizerHeaderFile(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST 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 C target.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)
Overrides the standard grammar analysis so we can prepare the analyser a little differently from the other targets.
-
-
-
方法详细资料
-
genRecognizerFile
protected void genRecognizerFile(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST outputFileST) throws java.io.IOException
- 覆盖:
genRecognizerFile
在类中Target
- 抛出:
java.io.IOException
-
genRecognizerHeaderFile
protected void genRecognizerHeaderFile(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST headerFileST, java.lang.String extName) throws java.io.IOException
- 覆盖:
genRecognizerHeaderFile
在类中Target
- 抛出:
java.io.IOException
-
chooseWhereCyclicDFAsGo
protected org.stringtemplate.v4.ST chooseWhereCyclicDFAsGo(Tool tool, CodeGenerator generator, Grammar grammar, org.stringtemplate.v4.ST recognizerST, org.stringtemplate.v4.ST 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.- 覆盖:
isValidActionScope
在类中Target
-
getTargetCharLiteralFromANTLRCharLiteral
public java.lang.String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator generator, java.lang.String literal)
从类复制的说明: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.
-
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 C target. Because we must support Unicode character sets and have chosen to have the lexer match UTF32 characters, then we must encode string matches to use 32 bit character arrays. Here then we must produce the C array and cater for the case where the lexer has been encoded with a string such as 'xyz\n',
-
performGrammarAnalysis
protected void performGrammarAnalysis(CodeGenerator generator, Grammar grammar)
Overrides the standard grammar analysis so we can prepare the analyser a little differently from the other targets. In particular we want to influence the way the code generator makes assumptions about switchs vs ifs, vs table driven DFAs. In general, C code should be generated that has the minimum use of tables, and tha meximum use of large switch statements. This allows the optimizers to generate very efficient code, it can reduce object code size by about 30% and give about a 20% performance improvement over not doing this. Hence, for the C target only, we change the defaults here, but only if they are still set to the defaults.- 覆盖:
performGrammarAnalysis
在类中Target
- 参数:
generator
- An instance of the generic code generator class.grammar
- The grammar that we are currently analyzing
-
-