示例#1
0
        void EventManager_OnCompileScript(string scriptSource, OpenSim.Region.Framework.Interfaces.ICompilationListener compListener)
        {
            //compile script to get error output only, do not start a run
            CompilerFrontend frontEnd = new CompilerFrontend(new CompilationListenerAdaptor(compListener), ".");

            frontEnd.Compile(scriptSource);
        }
 public void Setup()
 {
     _compiler                  = new CompilerFrontend();
     _listener                  = new TestListener();
     _compiler.Listener         = _listener;
     _compiler.TraceDestination = Console.Error;
 }
示例#3
0
 public void Setup()
 {
     _compiler                  = new CompilerFrontend(System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "grammar"));
     _listener                  = new TestListener();
     _compiler.Listener         = _listener;
     _compiler.TraceDestination = Console.Error;
 }
示例#4
0
 public void Setup()
 {
     _compiler = new CompilerFrontend();
     _listener = new TestListener();
     _compiler.Listener = _listener;
     _compiler.TraceDestination = Console.Error;
 }
示例#5
0
        public static void Main(string[] args)
        {
            IPrinter printer = new ConsolePrinter();

            if (args.Length < 1)
            {
                printer.printLine("Nothing to compile.");
                printer.printLine("Please supply the Mini-Pascal source code file as the first argument when running this program.");
                printer.printLine("If you want to save the the translation to a file, please supply the target file name as the second argument.");
                return;
            }

            string sourceFilename = @args [0];

            if (!
                File.Exists(sourceFilename))
            {
                printer.printLine(String.Format("Unable to open the source file {0}.\n", sourceFilename));
                return;
            }

            CompilerFrontend cf   = new CompilerFrontend();
            SyntaxTree       tree = cf.Compile(sourceFilename);

            if (cf.getErrors().Count > 0)
            {
                printer.printLine(String.Format("The following errors were encountered during compilation of file {0}:\n", sourceFilename));
                printer.SourceLines = cf.SourceLines;
                printer.printErrors(cf.getErrors());
                return;
            }

            printer.printLine(String.Format("Translation of the file {0} from Mini-Pascal to an AST finished succesfully.", sourceFilename));

            SimplifiedCSynthesizer synthesizer = new SimplifiedCSynthesizer(tree);
            List <string>          translation = synthesizer.Translate();

            printer = new ConsolePrinter(translation.ToArray());

            if (args.Length > 1)
            {
                string targetFilename = @args [1];
                bool   fileWritten    = FileWriter.writeListToFile(translation, targetFilename);

                if (fileWritten)
                {
                    printer.printLine(String.Format("Synthesis of the AST to Simplified C was successfully written to {0}.\n", targetFilename));
                    return;
                }

                printer.printLine(String.Format("Unable to write to the target file {0}.\n", targetFilename));
            }

            printer.printLine("Synthesis of the AST to Simplified C:\n");
            printer.printSourceLines();
        }
示例#6
0
    protected EchelonScript_Compiler()
    {
        errorsList   = new List <EchelonScriptErrorMessage> ();
        warningsList = new List <EchelonScriptErrorMessage> ();
        infoList     = new List <EchelonScriptErrorMessage> ();

        parser   = new EchelonScriptParser(errorsList);
        frontend = new CompilerFrontend(errorsList, warningsList, infoList);
        backend  = null;

        disposeBackend = false;
    }
示例#7
0
        public static void Main(string[] args)
        {
            ConsolePrinter cp = new ConsolePrinter();
            ConsoleReader  cr = new ConsoleReader();

            if (args.Length < 1)
            {
                cp.printLine("Please give a file path to open as argument, e.g.\nInterpreter.exe C:\\path\\file.txt");
                return;
            }

            string filePath = @args [0];

            CompilerFrontend cf         = new CompilerFrontend();
            SyntaxTree       syntaxTree = null;

            try {
                syntaxTree = cf.Compile(filePath);
            } catch (Exception ex) {
                Console.WriteLine("Unexpected exception:\n" + ex.GetType().Name + " " + ex.Message);
                Console.WriteLine("\nExecution halted");
            }

            cp.SourceLines = cf.SourceLines;
            List <Error> errors = cf.getErrors();

            if (cf.getErrors().Count > 0)
            {
                cp.printErrors(errors);
                return;
            }

            try {
                MiniPLInterpreter.Interpreter interpreter = new MiniPLInterpreter.Interpreter(syntaxTree, cp, cr);
                interpreter.Interpret();
            } catch {
                Console.WriteLine("\nExecution halted");
            }
        }