Class CodeGenerator

java.lang.Object
org.javacc.parser.CodeGenerator
Direct Known Subclasses:
LexGen, ParseGen

public class CodeGenerator extends Object
  • Field Details

    • mainBuffer

      protected StringBuffer mainBuffer
    • includeBuffer

      protected StringBuffer includeBuffer
    • staticsBuffer

      protected StringBuffer staticsBuffer
    • outputBuffer

      protected StringBuffer outputBuffer
    • cline

      protected int cline
    • ccol

      protected int ccol
  • Constructor Details

    • CodeGenerator

      public CodeGenerator()
  • Method Details

    • genStringLiteralArrayCPP

      public void genStringLiteralArrayCPP(String varName, String[] arr)
    • genStringLiteralInCPP

      public void genStringLiteralInCPP(String s)
    • genCodeLine

      public void genCodeLine(Object... code)
    • genCode

      public void genCode(Object... code)
    • saveOutput

      public void saveOutput(String fileName)
    • saveOutput

      public void saveOutput(String fileName, StringBuffer sb)
    • printTokenSetup

      protected void printTokenSetup(Token t)
    • printTokenList

      protected void printTokenList(List<Token> list)
    • printTokenOnly

      protected void printTokenOnly(Token t)
    • getStringForTokenOnly

      protected String getStringForTokenOnly(Token t)
    • printToken

      protected void printToken(Token t)
    • getStringToPrint

      protected String getStringToPrint(Token t)
    • printLeadingComments

      protected void printLeadingComments(Token t)
    • getLeadingComments

      protected String getLeadingComments(Token t)
    • printTrailingComments

      protected void printTrailingComments(Token t)
    • getTrailingComments

      protected String getTrailingComments(Token t)
    • getGeneratedCode

      public String getGeneratedCode()
      for testing
    • genAnnotation

      public void genAnnotation(String ann)
      Generate annotation. @XX syntax for java, comments in C++
    • genModifier

      public void genModifier(String mod)
      Generate a modifier
    • genClassStart

      public void genClassStart(String mod, String name, String[] superClasses, String[] superInterfaces)
      Generate a class with a given name, an array of superclass and another array of super interfaes
    • isJavaLanguage

      protected boolean isJavaLanguage()
    • switchToMainFile

      public void switchToMainFile()
    • switchToStaticsFile

      public void switchToStaticsFile()
    • switchToIncludeFile

      public void switchToIncludeFile()
    • generateMethodDefHeader

      public void generateMethodDefHeader(String modsAndRetType, String className, String nameAndParams)
    • generateMethodDefHeader

      public void generateMethodDefHeader(String qualifiedModsAndRetType, String className, String nameAndParams, String exceptions)
    • getClassQualifier

      protected String getClassQualifier(String className)
    • getCharStreamName

      public static String getCharStreamName()
    • writeTemplate

      protected void writeTemplate(String name, Map<String,Object> options, Object... additionalOptions) throws IOException
      Throws:
      IOException