Example #1
0
        private static void SetupNullableTable()
        {
            bool  flag;
            short num3 = (short)(BuilderApp.BuildTables.Symbol.Count() - 1);
            short num  = 0;

            while (num <= num3)
            {
                BuilderApp.BuildTables.Symbol[num].Nullable = false;
                num = (short)(num + 1);
            }
            do
            {
                flag = false;
                short num4 = (short)(BuilderApp.BuildTables.Production.Count() - 1);
                for (num = 0; num <= num4; num = (short)(num + 1))
                {
                    ProductionBuild build = BuilderApp.BuildTables.Production[num];
                    bool            flag2 = true;
                    for (short i = 0; (i < build.Handle().Count()) & flag2; i = (short)(i + 1))
                    {
                        SymbolBuild build2 = build.Handle()[i];
                        if (!build2.Nullable)
                        {
                            flag2 = false;
                        }
                    }
                    if (flag2 & !build.Head.Nullable)
                    {
                        build.Head.Nullable = true;
                        flag = true;
                    }
                }
            }while (flag);
        }
Example #2
0
 public LRConfig(ProductionBuild Rule)
 {
     this.LookaheadSet     = new LookaheadSymbolSet();
     this.Parent           = Rule;
     this.Position         = 0;
     this.LookaheadSet     = new LookaheadSymbolSet();
     this.Modified         = true;
     this.InheritLookahead = false;
 }
Example #3
0
 // Methods
 public LRConfig()
 {
     this.LookaheadSet     = new LookaheadSymbolSet();
     this.Parent           = null;
     this.Position         = 0;
     this.LookaheadSet     = new LookaheadSymbolSet();
     this.Modified         = true;
     this.InheritLookahead = false;
 }
Example #4
0
 public LRConfig(LRConfig Config)
 {
     this.LookaheadSet     = new LookaheadSymbolSet();
     this.Parent           = Config.Parent;
     this.Position         = Config.Position;
     this.LookaheadSet     = new LookaheadSymbolSet();
     this.Modified         = Config.Modified;
     this.InheritLookahead = Config.InheritLookahead;
     this.LookaheadSet.Copy(Config.LookaheadSet);
 }
Example #5
0
        public LRConfig(ProductionBuild Parent, int Position, LookaheadSymbolSet InitSet)
        {
            this.LookaheadSet     = new LookaheadSymbolSet();
            this.Parent           = Parent;
            this.Position         = (short)Position;
            this.LookaheadSet     = new LookaheadSymbolSet();
            this.Modified         = true;
            this.InheritLookahead = false;
            int num2 = InitSet.Count() - 1;

            for (int i = 0; i <= num2; i++)
            {
                this.LookaheadSet.Add(new LookaheadSymbol(InitSet[i]));
            }
        }
Example #6
0
        private static void SetupFirstTable()
        {
            bool        flag;
            short       num2;
            SymbolBuild build2;

            SetupNullableTable();
            short num4 = (short)(BuilderApp.BuildTables.Symbol.Count() - 1);

            for (num2 = 0; num2 <= num4; num2 = (short)(num2 + 1))
            {
                BuilderApp.BuildTables.Symbol[num2].First.Clear();
            }
            short num5 = (short)(BuilderApp.BuildTables.Symbol.Count() - 1);

            num2 = 0;
            while (num2 <= num5)
            {
                build2 = BuilderApp.BuildTables.Symbol[num2];
                if (build2.Type != SymbolType.Nonterminal)
                {
                    build2.First.Add(new LookaheadSymbol(build2));
                }
                num2 = (short)(num2 + 1);
            }

            do
            {
                flag = false;
                short num6 = (short)(BuilderApp.BuildTables.Production.Count() - 1);
                for (num2 = 0; num2 <= num6; num2 = (short)(num2 + 1))
                {
                    ProductionBuild build = BuilderApp.BuildTables.Production[num2];
                    short           num3  = 0;
                    for (bool flag2 = false; (num3 < build.Handle().Count()) & !flag2; flag2 = !build2.Nullable)
                    {
                        build2 = build.Handle()[num3];
                        short tableIndex = build2.TableIndex;
                        if (build.Head.First.UnionWith(build2.First))
                        {
                            flag = true;
                        }
                        num3 = (short)(num3 + 1);
                    }
                }
            }while (flag);
        }
Example #7
0
        private static LRStateBuild CreateInitialState(Symbol StartSymbol)
        {
            ProductionBuild rule        = new ProductionBuild();
            SymbolBuild     nonTerminal = new SymbolBuild
            {
                Type = SymbolType.Nonterminal,
                Name = "S'"
            };

            rule.SetHead(nonTerminal);
            rule.Handle().Add((SymbolBuild)StartSymbol);
            rule.Handle().Add((SymbolBuild)BuilderApp.BuildTables.Symbol.GetFirstOfType(SymbolType.End));
            LRConfig     item   = new LRConfig(rule);
            LRStateBuild build3 = new LRStateBuild();

            build3.ConfigSet.Add(item);
            build3.Expanded = false;
            Closure(build3.ConfigSet);
            return(build3);
        }
Example #8
0
 public int Add(ProductionBuild item)
 {
     return(base.Add(item));
 }