예제 #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);
        }
예제 #2
0
 public virtual void ProcessNested(IToken actionToken)
 {
     ANTLRStringStream @in = new ANTLRStringStream(actionToken.Text);
     @in.Line = actionToken.Line;
     @in.CharPositionInLine = actionToken.CharPositionInLine;
     ActionSplitter splitter = new ActionSplitter(@in, this);
     // forces eval, triggers listener methods
     splitter.GetActionTokens();
 }
예제 #3
0
 public virtual void ExamineAction()
 {
     //System.out.println("examine "+actionToken);
     ANTLRStringStream @in = new ANTLRStringStream(actionToken.Text);
     @in.Line = actionToken.Line;
     @in.CharPositionInLine = actionToken.CharPositionInLine;
     ActionSplitter splitter = new ActionSplitter(@in, this);
     // forces eval, triggers listener methods
     node.chunks = splitter.GetActionTokens();
 }
예제 #4
0
        public virtual void ProcessNested(IToken actionToken)
        {
            ANTLRStringStream @in = new ANTLRStringStream(actionToken.Text);

            @in.Line = actionToken.Line;
            @in.CharPositionInLine = actionToken.CharPositionInLine;
            ActionSplitter splitter = new ActionSplitter(@in, this);

            // forces eval, triggers listener methods
            splitter.GetActionTokens();
        }
예제 #5
0
 public static bool ActionIsContextDependent(ActionAST actionAST)
 {
     ANTLRStringStream @in = new ANTLRStringStream(actionAST.Token.Text);
     @in.Line = actionAST.Token.Line;
     @in.CharPositionInLine = actionAST.Token.CharPositionInLine;
     var listener = new ContextDependentListener();
     ActionSplitter splitter = new ActionSplitter(@in, listener);
     // forces eval, triggers listener methods
     splitter.GetActionTokens();
     return listener.dependent;
 }
예제 #6
0
        public virtual void ExamineAction()
        {
            //System.out.println("examine "+actionToken);
            ANTLRStringStream @in = new ANTLRStringStream(actionToken.Text);

            @in.Line = actionToken.Line;
            @in.CharPositionInLine = actionToken.CharPositionInLine;
            ActionSplitter splitter = new ActionSplitter(@in, this);

            // forces eval, triggers listener methods
            node.chunks = splitter.GetActionTokens();
        }
예제 #7
0
        public static bool ActionIsContextDependent(ActionAST actionAST)
        {
            ANTLRStringStream @in = new ANTLRStringStream(actionAST.Token.Text);

            @in.Line = actionAST.Token.Line;
            @in.CharPositionInLine = actionAST.Token.CharPositionInLine;
            var            listener = new ContextDependentListener();
            ActionSplitter splitter = new ActionSplitter(@in, listener);

            // forces eval, triggers listener methods
            splitter.GetActionTokens();
            return(listener.dependent);
        }
예제 #8
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;
 }