コード例 #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
ファイル: ActionSniffer.cs プロジェクト: sharwell/antlr4cs
 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
ファイル: ActionSniffer.cs プロジェクト: sharwell/antlr4cs
 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
ファイル: ActionSniffer.cs プロジェクト: yuanyong00/antlr4cs
        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
ファイル: UseDefAnalyzer.cs プロジェクト: sharwell/antlr4cs
 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
ファイル: ActionSniffer.cs プロジェクト: yuanyong00/antlr4cs
        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
ファイル: ActionTranslator.cs プロジェクト: sharwell/antlr4cs
 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;
 }