当前位置: 首页>>代码示例>>C#>>正文


C# ICharStream.La方法代码示例

本文整理汇总了C#中ICharStream.La方法的典型用法代码示例。如果您正苦于以下问题:C# ICharStream.La方法的具体用法?C# ICharStream.La怎么用?C# ICharStream.La使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICharStream的用法示例。


在下文中一共展示了ICharStream.La方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Consume

 public virtual void Consume(ICharStream input)
 {
     int curChar = input.La(1);
     if (curChar == '\n')
     {
         line++;
         charPositionInLine = 0;
     }
     else
     {
         charPositionInLine++;
     }
     input.Consume();
 }
开发者ID:hustsii,项目名称:antlr4cs,代码行数:14,代码来源:LexerATNSimulator.cs

示例2: Accept

 protected internal virtual void Accept(ICharStream input, int ruleIndex, int actionIndex
     , int index, int line, int charPos)
 {
     if (actionIndex >= 0 && recog != null)
     {
         recog.Action(null, ruleIndex, actionIndex);
     }
     // seek to after last char in token
     input.Seek(index);
     this.line = line;
     this.charPositionInLine = charPos;
     if (input.La(1) != IntStreamConstants.Eof)
     {
         Consume(input);
     }
 }
开发者ID:hustsii,项目名称:antlr4cs,代码行数:16,代码来源:LexerATNSimulator.cs

示例3: Accept

 protected internal virtual void Accept(ICharStream input, LexerActionExecutor lexerActionExecutor, int startIndex, int index, int line, int charPos)
 {
     // seek to after last char in token
     input.Seek(index);
     this.line = line;
     this.charPositionInLine = charPos;
     if (input.La(1) != IntStreamConstants.Eof)
     {
         Consume(input);
     }
     if (lexerActionExecutor != null && recog != null)
     {
         lexerActionExecutor.Execute(recog, input, startIndex);
     }
 }
开发者ID:nickdurcholz,项目名称:antlr4cs,代码行数:15,代码来源:LexerATNSimulator.cs

示例4: ExecATN

 protected internal virtual int ExecATN(ICharStream input, DFAState ds0)
 {
     //System.out.println("enter exec index "+input.index()+" from "+ds0.configs);
     int t = input.La(1);
     DFAState s = ds0;
     // s is current/from DFA state
     while (true)
     {
         // while more work
         // As we move src->trg, src->trg, we keep track of the previous trg to
         // avoid looking up the DFA state again, which is expensive.
         // If the previous target was already part of the DFA, we might
         // be able to avoid doing a reach operation upon t. If s!=null,
         // it means that semantic predicates didn't prevent us from
         // creating a DFA state. Once we know s!=null, we check to see if
         // the DFA state has an edge already for t. If so, we can just reuse
         // it's configuration set; there's no point in re-computing it.
         // This is kind of like doing DFA simulation within the ATN
         // simulation because DFA simulation is really just a way to avoid
         // computing reach/closure sets. Technically, once we know that
         // we have a previously added DFA state, we could jump over to
         // the DFA simulator. But, that would mean popping back and forth
         // a lot and making things more complicated algorithmically.
         // This optimization makes a lot of sense for loops within DFA.
         // A character will take us back to an existing DFA state
         // that already has lots of edges out of it. e.g., .* in comments.
         DFAState target = GetExistingTargetState(s, t);
         if (target == null)
         {
             target = ComputeTargetState(input, s, t);
         }
         if (target == Error)
         {
             break;
         }
         if (target.isAcceptState)
         {
             CaptureSimState(prevAccept, input, target);
             if (t == IntStreamConstants.Eof)
             {
                 break;
             }
         }
         if (t != IntStreamConstants.Eof)
         {
             Consume(input);
             t = input.La(1);
         }
         s = target;
     }
     // flip; current DFA target becomes new src/from state
     return FailOrAccept(prevAccept, input, s.configs, t);
 }
开发者ID:hustsii,项目名称:antlr4cs,代码行数:53,代码来源:LexerATNSimulator.cs

示例5: ExecATN

        protected internal virtual int ExecATN(ICharStream input, DFAState ds0)
        {
            //System.out.println("enter exec index "+input.index()+" from "+ds0.configs);
            int t = input.La(1);
            DFAState s = ds0;
            // s is current/from DFA state
            while (true)
            {
                // while more work
                // As we move src->trg, src->trg, we keep track of the previous trg to
                // avoid looking up the DFA state again, which is expensive.
                // If the previous target was already part of the DFA, we might
                // be able to avoid doing a reach operation upon t. If s!=null,
                // it means that semantic predicates didn't prevent us from
                // creating a DFA state. Once we know s!=null, we check to see if
                // the DFA state has an edge already for t. If so, we can just reuse
                // it's configuration set; there's no point in re-computing it.
                // This is kind of like doing DFA simulation within the ATN
                // simulation because DFA simulation is really just a way to avoid
                // computing reach/closure sets. Technically, once we know that
                // we have a previously added DFA state, we could jump over to
                // the DFA simulator. But, that would mean popping back and forth
                // a lot and making things more complicated algorithmically.
                // This optimization makes a lot of sense for loops within DFA.
                // A character will take us back to an existing DFA state
                // that already has lots of edges out of it. e.g., .* in comments.
                ATNConfigSet closure = s.configs;
                DFAState target = null;
                target = s.GetTarget(t);
                if (target == Error)
                {
                    break;
                }
#if !PORTABLE
                if (debug && target != null)
                {
                    System.Console.Out.WriteLine("reuse state " + s.stateNumber + " edge to " + target
                        .stateNumber);
                }
#endif
                if (target == null)
                {
                    ATNConfigSet reach = new OrderedATNConfigSet();
                    // if we don't find an existing DFA state
                    // Fill reach starting from closure, following t transitions
                    GetReachableConfigSet(input, closure, reach, t);
                    if (reach.Count == 0)
                    {
                        // we got nowhere on t from s
                        // we reached state associated with closure for sure, so
                        // make sure it's defined. worst case, we define s0 from
                        // start state configs.
                        DFAState from = s != null ? s : AddDFAState(closure);
                        // we got nowhere on t, don't throw out this knowledge; it'd
                        // cause a failover from DFA later.
                        AddDFAEdge(from, t, Error);
                        break;
                    }
                    // stop when we can't match any more char
                    // Add an edge from s to target DFA found/created for reach
                    target = AddDFAEdge(s, t, reach);
                }
                if (target.isAcceptState)
                {
                    CaptureSimState(prevAccept, input, target);
                    if (t == IntStreamConstants.Eof)
                    {
                        break;
                    }
                }
                if (t != IntStreamConstants.Eof)
                {
                    Consume(input);
                    t = input.La(1);
                }
                s = target;
            }
            // flip; current DFA target becomes new src/from state
            return FailOrAccept(prevAccept, input, s.configs, t);
        }
开发者ID:pabloescribano,项目名称:antlr4cs,代码行数:80,代码来源:LexerATNSimulator.cs


注:本文中的ICharStream.La方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。