Provides a simple interface for parsing and compiling a PEG grammar.
Пример #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
        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);
        }