Ejemplo n.º 1
0
        private static void RecomputeLRState(LRStateBuild State)
        {
            short num2 = (short)(State.Count - 1);

            for (short i = 0; i <= num2; i = (short)(i + 1))
            {
                LRAction action = State[i];
                switch (((int)action.Type()))
                {
                case 1:
                case 3:
                {
                    Symbol      symbol    = action.Symbol;
                    SymbolBuild theSymbol = (SymbolBuild)symbol;
                    symbol = theSymbol;
                    LRStateBuild build  = GotoSymbol(State, theSymbol);
                    LRStateBuild build2 = BuilderApp.BuildTables.LALR[action.Value()];
                    if (build.ConfigSet.CompareCore(build2.ConfigSet) == LRConfigCompare.EqualCore)
                    {
                        build2.ConfigSet.UnionWith(build.ConfigSet);
                        build2.Modified = true;
                    }
                    Notify.Analyzed++;
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
 // Methods
 public void Add(LRAction Action)
 {
     base.Add(Action);
 }
Ejemplo n.º 3
0
        private ParseResult ParseLALR(Token NextToken)
        {
            Token       token;
            short       index;
            Production  production;
            ParseResult reduceEliminated;
            LRAction    action = this.m_Tables.LALR[this.m_CurrentLALR][NextToken.Parent];

            if (action == null)
            {
                IEnumerator enumerator;
                this.m_ExpectedSymbols.Clear();
                try
                {
                    enumerator = this.m_Tables.LALR[this.m_CurrentLALR].GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        LRAction current = (LRAction)enumerator.Current;
                        if ((current.Symbol.Type == SymbolType.Content) | (current.Symbol.Type == SymbolType.End))
                        {
                            this.m_ExpectedSymbols.Add(current.Symbol);
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                return(ParseResult.SyntaxError);
            }
            this.m_HaveReduction = false;
            switch (((int)action.Type()))
            {
            case 1:
                this.m_CurrentLALR = action.Value();
                NextToken.State    = (short)this.m_CurrentLALR;
                this.m_Stack.Push(NextToken);
                return(ParseResult.Shift);

            case 2:
                production = this.m_Tables.Production[action.Value()];
                if (!(this.m_TrimReductions & production.ContainsOneNonTerminal()))
                {
                    short num4;
                    this.m_HaveReduction = true;
                    Reduction data       = new Reduction(production.Handle().Count());
                    Reduction reduction2 = data;
                    reduction2.Parent = production;
                    index             = (short)(production.Handle().Count() - 1);
Label_0147:
                    num4 = 0;
                    if (index >= num4)
                    {
                        reduction2[index] = this.m_Stack.Pop();
                        index             = (short)(index + -1);
                        goto Label_0147;
                    }
                    reduction2       = null;
                    token            = new Token(production.Head, data);
                    reduceEliminated = ParseResult.ReduceNormal;
                    break;
                }
                token            = this.m_Stack.Pop();
                token.Parent     = production.Head;
                reduceEliminated = ParseResult.ReduceEliminated;
                break;

            case 3:
                return(reduceEliminated);

            case 4:
                this.m_HaveReduction = true;
                return(ParseResult.Accept);

            default:
                return(reduceEliminated);
            }
            short state = this.m_Stack.Top().State;

            index = this.m_Tables.LALR[state].IndexOf(production.Head);
            if (index != -1)
            {
                this.m_CurrentLALR = this.m_Tables.LALR[state][index].Value();
                token.State        = (short)this.m_CurrentLALR;
                this.m_Stack.Push(token);
                return(reduceEliminated);
            }
            return(ParseResult.InternalError);
        }