Esempio n. 1
0
        public void AddError(ErrorRecord error)
        {
            if (m_errors == null)
            {
                m_errors = new List<ErrorRecord>();
            }

            m_errors.Add(error);
        }
Esempio n. 2
0
        public void Reduce(IProduction production, ReduceVisitor reducer, Lexeme lookahead)
        {
            #if HISTORY
            var from = m_topStack.StateIndex;
            #endif

            if (production == null)
            {
                //Accept
                Debug.Assert(m_topStack.PrevNode.StateIndex == 0);

                //TODO: accepted
                IsAccepted = true;
                return;
            }

            if (production.AggregatesAmbiguities)
            {
                AmbiguityAggregator = ((ProductionBase)production).CreateAggregator();
            }

            var reduceResult = production.Accept(reducer, m_topStack);

            m_topStack = reduceResult.NewTopStack;
            var reduceError = reduceResult.ReduceError;

            if (reduceError != null)
            {
                IncreaseErrorRecoverLevel();

                if (reduceError.ErrorPosition == null)
                {
                    reduceError = new ErrorRecord(reduceError.ErrorId, lookahead.Value.Span);
                }

                AddError(reduceError);
            }

            #if HISTORY
            var to = m_topStack.StateIndex;
            History.Add(String.Format("R{0}:{1}", from, to));
            #endif
        }