Inheritance: ActionSplitterListener
Example #1
0
        public static IList <ActionChunk> TranslateActionChunk(OutputModelFactory factory,
                                                               RuleFunction rf,
                                                               string action,
                                                               ActionAST node)
        {
            IToken           tokenWithinAction = node.Token;
            ActionTranslator translator        = new ActionTranslator(factory, node);

            translator.rf = rf;
            factory.GetGrammar().tool.Log("action-translator", "translate " + action);
            string altLabel = node.GetAltLabel();

            if (rf != null)
            {
                translator.nodeContext = rf.ruleCtx;
                if (altLabel != null)
                {
                    AltLabelStructDecl decl;
                    rf.altLabelCtxs.TryGetValue(altLabel, out decl);
                    translator.nodeContext = decl;
                }
            }
            ANTLRStringStream @in = new ANTLRStringStream(action);

            @in.Line = tokenWithinAction.Line;
            @in.CharPositionInLine = tokenWithinAction.CharPositionInLine;
            ActionSplitter trigger = new ActionSplitter(@in, translator);

            // forces eval, triggers listener methods
            trigger.GetActionTokens();
            return(translator.chunks);
        }
Example #2
0
 public static IList<ActionChunk> TranslateActionChunk(OutputModelFactory factory,
                                                      RuleFunction rf,
                                                      string action,
                                                      ActionAST node)
 {
     IToken tokenWithinAction = node.Token;
     ActionTranslator translator = new ActionTranslator(factory, node);
     translator.rf = rf;
     factory.GetGrammar().tool.Log("action-translator", "translate " + action);
     string altLabel = node.GetAltLabel();
     if (rf != null)
     {
         translator.nodeContext = rf.ruleCtx;
         if (altLabel != null)
         {
             AltLabelStructDecl decl;
             rf.altLabelCtxs.TryGetValue(altLabel, out decl);
             translator.nodeContext = decl;
         }
     }
     ANTLRStringStream @in = new ANTLRStringStream(action);
     @in.Line = tokenWithinAction.Line;
     @in.CharPositionInLine = tokenWithinAction.CharPositionInLine;
     ActionSplitter trigger = new ActionSplitter(@in, translator);
     // forces eval, triggers listener methods
     trigger.GetActionTokens();
     return translator.chunks;
 }