Example #1
0
 private void AddActionToProduction(Production prod, ActionProxy proxy)
 {
     // Version 1.3.1 no longer explicitly calls FixInternalReduction().
     // It is easier to adopt a consistent approach and
     // let AddXxxToProd check for a trailing action
     // prior to adding symbols or a new action.
     //
     if (proxy != null)
     {
         if (prod.semanticAction != null || prod.precSpan != null)
         {
             FixInternalReduction(prod);
         }
         LexSpan cSpan = proxy.codeBlock;            // LexSpan of action code
         LexSpan pSpan = proxy.precedenceToken;      // LexSpan of ident in %prec ident
         if (pSpan != null)
         {
             prod.prec     = grammar.LookupTerminal(Token.ident, pSpan.ToString()).prec;
             prod.precSpan = proxy.precedenceSpan;
         }
         if (cSpan != null)
         {
             prod.semanticAction = new SemanticAction(prod, prod.rhs.Count, cSpan);
         }
     }
 }
Example #2
0
        private Production NewProduction(List <string> symbols, ActionProxy proxy)
        {
            Production rslt = new Production(currentLHS);

            if (symbols != null)
            {
                AddSymbolsToProduction(rslt, symbols);
            }
            if (proxy != null)
            {
                AddActionToProduction(rslt, proxy);
            }
            return(rslt);
        }