Exemple #1
0
        /// <summary>
        /// Does the same as calling 'yapg make'.
        /// </summary>
        /// <param name="inputFile">The name of the file containing the grammar definition.</param>
        /// <param name="outputFile">The name of the file to which the parser's runtime data will be written.</param>
        /// <param name="logFile">The name of the file to which the automaton's states should be logged.</param>
        /// <param name="explicitLogging">When set to <b>true</b>, logs the automaton's states even if the
        /// parses is alright.</param>
        /// <param name="forceLalr1"></param>
        public static void MakeGrammar(string inputFile, string outputFile, string logFile,
                                       bool explicitLogging, bool forceLalr1, string compilerOptions)
        {
            IList <string> warningMessages;
            Grammar        grammar = GrammarParser.ParseGrammar(Path.GetFullPath(inputFile), out warningMessages);

            foreach (string warning in warningMessages)
            {
                Console.Error.WriteLine(warning);
            }

            if (warningMessages.Count > 0)
            {
                Console.Error.WriteLine();
            }

            GrammarProcessor processor = new GrammarProcessor();

            processor.ForceLALR1Lookaheads = forceLalr1;
            processor.ComputeTables(grammar, logFile, explicitLogging, Console.Out);

            GrammarCompiler compiler = new GrammarCompiler();

            compiler.CompileGrammarCode(grammar, compilerOptions);

            grammar.WriteRuntimeDataToFile(outputFile);

            Console.Out.Flush();
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of SLROracle, supplying it with a link to the grammar data.
 /// </summary>
 /// <param name="processor">The GrammarProcessor instance which is processing the Grammar in question.</param>
 public SLROracle(GrammarProcessor processor)
 {
     this.processor = processor;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of ReadsOracle, supplying it with a link to the grammar data.
 /// </summary>
 /// <param name="processor">The GrammarProcessor instance which is processing the Grammar in question.</param>
 public ReadsOracle(GrammarProcessor processor)
 {
     this.processor = processor;
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of ReadsOracle, supplying it with a link to the grammar data.
 /// </summary>
 /// <param name="processor">The GrammarProcessor instance which is processing the Grammar in question.</param>
 public IncludesOracle(GrammarProcessor processor)
 {
     this.processor = processor;
 }