Esempio n. 1
0
        public GrammarTables Build()
        {
            Populate();
            AssignTableIndexes();
            LinkGroupSymbolsToGroup();
            AssignPriorities();

            int count = m_symbols.Count(s => s.Symbol.Type == ESymbolType.Content);

            Console.WriteLine($"The grammar contains a total of {count} formal terminals.");
            DoSemanticAnalysis();

            // create result table.
            var tables = new GrammarTables();

            // copy groups.
            foreach (var group in m_groups)
            {
                tables.Groups.Add(group);
            }

            // copy symbols.
            foreach (var sym in m_symbols)
            {
                tables.Symbols.Add(sym.Symbol);
            }

            // build the DFA table.
            BuildLALR.Build(tables, this);
            BuildDFA.Build(tables, this);

            // return result.
            return(tables);
        }
Esempio n. 2
0
 public Parser(GrammarTables tables)
 {
     m_tables = tables;
 }