static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Compiler myCompiler = new Compiler(); Application.Run(myCompiler); }
private void Compile(string sourceFile, string assemblyFile) { var comiler = new Compiler.Compiler(); var myProgram = File.ReadAllText(sourceFile); var outputAssembly = comiler.Compile(myProgram); File.WriteAllText(assemblyFile, outputAssembly); }
/// <summary> /// Outputs parse tree as xml... for now... /// </summary> /// <param name="args"></param> static void Main(string[] args) { try { string inputPath = @"../../../TestFiles/Square"; //string inputPath = @"../../../TestFiles/UnitTestFiles"; foreach (string filepath in Directory.GetFiles(inputPath, @"*.jack")) { string outputPath = Program.GetOutputFilePath(inputPath, filepath); Compiler compiler = new Compiler(filepath); Program.WriteOuput(compiler.Compile(), outputPath); } } catch (Exception ex) { Console.WriteLine(ex); Console.ReadKey(); } }
/// <summary> /// Outputs parse tree as xml... for now... /// </summary> /// <param name="args"></param> static void Main(string[] args) { try { if (args != null && args.Length > 0) { string inputPath = args[0]; string outputPathDirectory = null; if(args.Length == 2) { outputPathDirectory = args[1]; } if (PathIsDirectory(inputPath)) { foreach (string filepath in Directory.GetFiles(inputPath, @"*.jack")) { Compiler compiler = new Compiler(filepath, outputPathDirectory); compiler.Compile(); } } else { Compiler compiler = new Compiler(inputPath, outputPathDirectory); compiler.Compile(); } } else { Console.WriteLine("Please specify a directory or file path."); } } catch (Exception ex) { Console.WriteLine(ex); Console.ReadKey(); } }
static void Main(string[] args) { Variables.Integer.Add("a", 0); Variables.Integer.Add("b", 0); Variables.Integer.Add("num", 10); Compiler.Compiler compiler = new Compiler.Compiler(new Lexer(), new Parser()); compiler.FilePath = @"Pascal\test.ps"; bool lex = compiler.CodeAnalysis(); if (lex) { SyntaxError syntaxError; syntaxError = compiler.CheckSyntax(); if (syntaxError == SyntaxError.NoError) { compiler.MakeSyntaxTree(); compiler.Run(); } } Console.ReadKey(); }
private void ToHandlerException(Compiler.Exception e, String stop_chars = ";") { if (e.line == -1 && e.index == -1) { e.line = this.scan.GetLine(); e.index = this.scan.GetPos(); } this.logger.Add(e); if (!(e is Symbols.Exception)) { this.PassExpr(stop_chars); } }