CompileFile() public static method

Parse and compile a PEG grammar from a file.
public static CompileFile ( string inputFile, string outputFile, Action logError ) : void
inputFile string The source filename.
outputFile string The desired destination filename, or null to use the default.
logError Action An action that will be called for every warning or error.
return void
コード例 #1
0
        /// <summary>
        /// Reads and compiles the specified grammars.
        /// </summary>
        /// <returns>true, if the compilation was successful; false, otherwise.</returns>
        public override bool Execute()
        {
            var inputs  = this.InputFiles.ToList();
            var outputs = (this.OutputFiles ?? new string[inputs.Count]).ToList();

            if (inputs.Count != outputs.Count)
            {
                this.Log.LogError(Resources.PEG0027_ERROR_WrongNumberOfOutputFiles);
                return(false);
            }

            for (int i = 0; i < this.InputFiles.Length; i++)
            {
                CompileManager.CompileFile(inputs[i], outputs[i], this.LogError);
            }

            return(!this.Log.HasLoggedErrors);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tatleung/Pegasus
        public static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowUsage();
                return(-1);
            }

            var errorCount = 0;

            foreach (var arg in args)
            {
                var errors = new List <CompilerError>();
                CompileManager.CompileFile(arg, null, errors.Add);
                ShowErrors(errors);
                errorCount += errors.Count;
            }

            return(errorCount);
        }