Ejemplo n.º 1
0
 void onErrorFound(CompilerMessage message)
 {
     var copy = ErrorFound;
     if (copy != null)
         copy (message);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Compile the specified grammar 
        /// </summary>
        /// <param name="grammarFile">Grammar file to compile</param>
        /// <param name="outputFile">The name of the binary file output</param>
        /// <remarks>The GOLD compiler outputs 2 versions of binary grammar tables:
        /// CGT and EGT. The format generated depends on the file extension of the 
        /// output file (.cgt or .egt)</remarks>
        public void Compile(string grammarFile, string outputFile)
        {
            //create a helper that will classify the error messages emitted by GOLD
            inputFileName = grammarFile;
            string text = slurpFile (inputFileName);
            outputParser = new GoldBuildOutputParser (inputFileName);

            //perform an initial parse on the file.
            //this will get the error locations for us,
            //since we can't get this info from the gold compiler
            parser.Parse (text);

            //launch the GOLD command line compiler
            startInfo.Arguments = constructArguments (grammarFile, outputFile);
            startInfo.WorkingDirectory = Path.GetDirectoryName (outputFile);
            var p = new Process();
            p.StartInfo = startInfo;
            p.OutputDataReceived += outputHandler;
            try
            {
                p.Start();
                p.BeginOutputReadLine();
                p.BeginErrorReadLine();
                p.WaitForExit();
                p.Close();
            }
            catch(Win32Exception)
            {
                var message = new CompilerMessage (MessageSeverity.Error,
                    goldCmdPath + " was not found on path",
                    string.Empty, 0, 0);
                onCompileStepComplete (message);
            }
        }
Ejemplo n.º 3
0
 void parseErrorFound(CompilerMessage message)
 {
     //file information should be included for outgoing message
     var completeMessage = new CompilerMessage (message.Severity,
                                               message.Text,
                                               inputFileName,
                                               message.Line,
                                               message.Column);
     onCompileStepComplete (completeMessage);
 }
Ejemplo n.º 4
0
        void outputHandler(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != null)
            {
                var message = outputParser.ParseRawMessage(e.Data);

                //some messages need to be suppressed because they were already checked
                //by the parser. Otherwise, duplicates will show in the Errors Pad
                string rawText = message.RawText;
                if(rawText.Contains("Grammar") && (rawText.Contains("Syntax") || rawText.Contains("Lexical") || rawText.Contains("Comment")))
                {
                    message = new CompilerMessage (MessageSeverity.Info, string.Empty, string.Empty, 0, 0, rawText);
                }

                onCompileStepComplete (message);
            }
        }
Ejemplo n.º 5
0
 void onCompileStepComplete(CompilerMessage message)
 {
     CompilerEventHandler copy = MessageOutput;
     if (copy != null)
         copy(message);
 }
Ejemplo n.º 6
0
        void compilerOutputHandler(CompilerMessage message)
        {
            //write to Build Output Window
            if (message.RawText.Length > 0)
                monitor.Log.WriteLine (message.RawText);

            //write to Message Window
            if (message.Severity == MessageSeverity.Error)
                currentBuildResult.AddError (message.File, message.Line, message.Column, "", message.Text);
            else if (message.Severity == MessageSeverity.Warning)
                currentBuildResult.AddWarning(message.File, message.Line, message.Column, "", message.Text);
        }