Ejemplo n.º 1
0
        private void FixInternalReduction(Production prod)
        {
            // This production has an action or precedence.
            // Before more symbols can be added to the rhs
            // the existing action must be turned into an
            // internal reduction, and the action (and
            // precedence, if any) moved to the new reduction.
            //
            if (prod.semanticAction != null)
            {
                string      anonName  = "Anon@" + (++grammar.NumActions).ToString(CultureInfo.InvariantCulture);
                NonTerminal anonNonT  = grammar.LookupNonTerminal(anonName);
                Production  EmptyProd = new Production(anonNonT);
                EmptyProd.semanticAction = prod.semanticAction;
                EmptyProd.prec           = prod.prec;

                grammar.AddProduction(EmptyProd);
                prod.rhs.Add(anonNonT);
            }
            if (prod.precSpan != null)
            {
                handler.ListError(prod.precSpan, 102);
            }
            prod.semanticAction = null;
            prod.precSpan       = null;
            prod.prec           = null;
        }