org.antlr.codegen
Class CPPTarget

java.lang.Object
  extended by org.antlr.codegen.Target
      extended by org.antlr.codegen.CPPTarget

public class CPPTarget
extends Target


Field Summary
 
Fields inherited from class org.antlr.codegen.Target
targetCharValueEscape
 
Constructor Summary
CPPTarget()
           
 
Method Summary
 java.lang.String escapeChar(int c)
           
 java.lang.String escapeString(java.lang.String s)
          Converts a String into a representation that can be use as a literal when surrounded by double-quotes.
protected  void genRecognizerHeaderFile(Tool tool, CodeGenerator generator, Grammar grammar, org.antlr.stringtemplate.StringTemplate headerFileST, java.lang.String extName)
           
 int getMaxCharValue(CodeGenerator codegen)
          Character constants get truncated to this value.
 java.lang.String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator codegen, 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 codegen, java.lang.String literal)
          Convert from an ANTLR string literal found in a grammar file to an equivalent string literal in the target language.
 
Methods inherited from class org.antlr.codegen.Target
encodeIntAsCharEscape, genRecognizerFile, getTarget64BitStringFromValue, getTargetStringLiteralFromString, getTargetStringLiteralFromString, getTokenTypeAsTargetLabel, isValidActionScope, performGrammarAnalysis, postProcessAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CPPTarget

public CPPTarget()
Method Detail

escapeChar

public java.lang.String escapeChar(int c)

escapeString

public java.lang.String escapeString(java.lang.String s)
Converts a String into a representation that can be use as a literal when surrounded by double-quotes. Used for escaping semantic predicate strings for exceptions.

Parameters:
s - The String to be changed into a literal

genRecognizerHeaderFile

protected void genRecognizerHeaderFile(Tool tool,
                                       CodeGenerator generator,
                                       Grammar grammar,
                                       org.antlr.stringtemplate.StringTemplate headerFileST,
                                       java.lang.String extName)
                                throws java.io.IOException
Overrides:
genRecognizerHeaderFile in class Target
Throws:
java.io.IOException

getTargetCharLiteralFromANTLRCharLiteral

public java.lang.String getTargetCharLiteralFromANTLRCharLiteral(CodeGenerator codegen,
                                                                 java.lang.String literal)
Convert from an ANTLR char literal found in a grammar file to an equivalent char literal in the target language. For Java, this is the identify translation; i.e., '\n' -> '\n'. Most languages will be able to use this 1-to-1 mapping. Expect single quotes around the incoming literal. Depending on the charvocabulary the charliteral should be prefixed with a 'L'

Overrides:
getTargetCharLiteralFromANTLRCharLiteral in class Target

getTargetStringLiteralFromANTLRStringLiteral

public java.lang.String getTargetStringLiteralFromANTLRStringLiteral(CodeGenerator codegen,
                                                                     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 identify translation; i.e., "\"\n" -> "\"\n". Most languages will be able to use this 1-to-1 mapping. Expect double quotes around the incoming literal. Depending on the charvocabulary the string should be prefixed with a 'L'

Overrides:
getTargetStringLiteralFromANTLRStringLiteral in class Target

getMaxCharValue

public int getMaxCharValue(CodeGenerator codegen)
Character constants get truncated to this value. TODO: This should be derived from the charVocabulary. Depending on it being 255 or 0xFFFF the templates should generate normal character constants or multibyte ones.

Overrides:
getMaxCharValue in class Target


Copyright © 2013. All Rights Reserved.