} // CaptureTokens // Read JavaScript source text and output a C# file. progClassName // is the name of the C# class we generate. inputFileLabel denotes // the source of the input text; it is inserted in a comment in the // C# source. public static void CompileToCSharp( TextReader input, TextWriter output, string progClassName, string inputFileLabel, bool forEvalCode ) { Tokenizer tokenizer = new Tokenizer(input); TokenListNode tokenList = CaptureTokens(tokenizer); Phase1Parser parser = new Phase1Parser(new Retokenizer(tokenList)); ProgramInfo programInfo = new ProgramInfo(); FunctionInfo rootFunc = new FunctionInfo(programInfo, null, null); parser.ParseProgram(rootFunc); PrettyPrinter pp = new PrettyPrinter(output); pp.Line("// JANET compiler output for source file " + inputFileLabel); pp.Line("// "); CSharpGenerator gen = new CSharpGenerator( rootFunc, pp, progClassName, forEvalCode ); Phase2Parser parser2 = new Phase2Parser( new Retokenizer(tokenList), gen ); parser2.ParseProgram(rootFunc); } // CompileToCSharp
// Construct a CSharpGenerator. Parameters: // // rootInfo Info object for the program's root function. // pp Object where we write the generated program. // progClassName C# class name to use for the generated program. // forEvalCode True if the code being compiled came from a // call to eval(). public CSharpGenerator( FunctionInfo rootInfo, PrettyPrinter pp, String progClassName, bool forEvalCode ) { this.rootInfo = rootInfo; this.pp = pp; this.progClassName = progClassName; this.forEvalCode = forEvalCode; } // CSharpGenerator constructor