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


C# IIntStream.LA方法代码示例

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


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

示例1: RecognitionException

 public RecognitionException(string message, IIntStream input, Exception innerException) : base(message, innerException)
 {
     this._input = input;
     if (input != null)
     {
         this._index = input.Index;
         if (input is ITokenStream)
         {
             this._token = ((ITokenStream) input).LT(1);
             this._line = this._token.Line;
             this._charPositionInLine = this._token.CharPositionInLine;
         }
         ITreeNodeStream stream = input as ITreeNodeStream;
         if (stream != null)
         {
             this.ExtractInformationFromTreeNodeStream(stream);
         }
         else if (input is ICharStream)
         {
             this._c = input.LA(1);
             this._line = ((ICharStream) input).Line;
             this._charPositionInLine = ((ICharStream) input).CharPositionInLine;
         }
         else
         {
             this._c = input.LA(1);
         }
     }
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:29,代码来源:RecognitionException.cs

示例2: Match

 public override object Match(IIntStream input, int ttype, BitSet follow)
 {
     object currentInputSymbol = this.GetCurrentInputSymbol(input);
     DumpSymbol(currentInputSymbol);
     if (input.LA(1) == ttype)
     {
         input.Consume();
         this.state.errorRecovery = false;
         this.state.failed = false;
         return currentInputSymbol;
     }
     else
     {
         if (this.state.backtracking <= 0)
             return this.RecoverFromMismatchedToken(input, ttype, follow);
         this.state.failed = true;
         return currentInputSymbol;
     }
 }
开发者ID:QAMichaelPeng,项目名称:CoolCompiler,代码行数:19,代码来源:CalculatorParser.cs

示例3: Initialize

 private void Initialize(IIntStream input) {
     this.input = input;
     this.index = input.Index;
     if (input is ITokenStream) {
         this.token = ((ITokenStream)input).LT(1);
         this.line = token.Line;
         this.charPositionInLine = token.CharPositionInLine;
     }
     if (input is ITreeNodeStream) {
         ExtractInformationFromTreeNodeStream(input);
     } else if (input is ICharStream) {
         this.c = input.LA(1);
         this.line = ((ICharStream)input).Line;
         this.charPositionInLine = ((ICharStream)input).CharPositionInLine;
     } else {
         this.c = input.LA(1);
     }
 }
开发者ID:exaphaser,项目名称:cs2j,代码行数:18,代码来源:RecognitionException.cs

示例4: Predict

 public virtual int Predict(IIntStream input)
 {
     int num6;
     if (this.debug)
     {
         Console.Error.WriteLine("Enter DFA.predict for decision " + this.decisionNumber);
     }
     int marker = input.Mark();
     int index = 0;
     try
     {
     Label_0030:
         if (this.debug)
         {
             Console.Error.WriteLine(string.Concat(new object[] { "DFA ", this.decisionNumber, " state ", index, " LA(1)=", (char) input.LA(1), "(", input.LA(1), "), index=", input.Index }));
         }
         int s = this.special[index];
         if (s >= 0)
         {
             if (this.debug)
             {
                 Console.Error.WriteLine(string.Concat(new object[] { "DFA ", this.decisionNumber, " state ", index, " is special state ", s }));
             }
             index = this.SpecialStateTransition(this, s, input);
             if (this.debug)
             {
                 Console.Error.WriteLine(string.Concat(new object[] { "DFA ", this.decisionNumber, " returns from special state ", s, " to ", index }));
             }
             if (index == -1)
             {
                 this.NoViableAlt(index, input);
                 return 0;
             }
             input.Consume();
             goto Label_0030;
         }
         if (this.accept[index] >= 1)
         {
             if (this.debug)
             {
                 Console.Error.WriteLine(string.Concat(new object[] { "accept; predict ", this.accept[index], " from state ", index }));
             }
             return this.accept[index];
         }
         char ch = (char) input.LA(1);
         if ((ch >= this.min[index]) && (ch <= this.max[index]))
         {
             int num4 = this.transition[index][ch - this.min[index]];
             if (num4 < 0)
             {
                 if (this.eot[index] < 0)
                 {
                     this.NoViableAlt(index, input);
                     return 0;
                 }
                 if (this.debug)
                 {
                     Console.Error.WriteLine("EOT transition");
                 }
                 index = this.eot[index];
                 input.Consume();
             }
             else
             {
                 index = num4;
                 input.Consume();
             }
             goto Label_0030;
         }
         if (this.eot[index] >= 0)
         {
             if (this.debug)
             {
                 Console.Error.WriteLine("EOT transition");
             }
             index = this.eot[index];
             input.Consume();
             goto Label_0030;
         }
         if ((ch == 0xffff) && (this.eof[index] >= 0))
         {
             if (this.debug)
             {
                 Console.Error.WriteLine(string.Concat(new object[] { "accept via EOF; predict ", this.accept[this.eof[index]], " from ", this.eof[index] }));
             }
             return this.accept[this.eof[index]];
         }
         if (this.debug)
         {
             Console.Error.WriteLine(string.Concat(new object[] { "min[", index, "]=", this.min[index] }));
             Console.Error.WriteLine(string.Concat(new object[] { "max[", index, "]=", this.max[index] }));
             Console.Error.WriteLine(string.Concat(new object[] { "eot[", index, "]=", this.eot[index] }));
             Console.Error.WriteLine(string.Concat(new object[] { "eof[", index, "]=", this.eof[index] }));
             for (int i = 0; i < this.transition[index].Length; i++)
             {
                 Console.Error.Write(this.transition[index][i] + " ");
             }
             Console.Error.WriteLine();
         }
         this.NoViableAlt(index, input);
//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:101,代码来源:DFA.cs

示例5: RecognitionException

        public RecognitionException(string message, IIntStream input, int k, Exception innerException)
            : base(message, innerException)
        {
            this._input = input;
            this._k = k;
            if (input != null)
            {
                this._index = input.Index + k - 1;
                if (input is ITokenStream)
                {
                    this._token = ((ITokenStream)input).LT(k);
                    this._line = _token.Line;
                    this._charPositionInLine = _token.CharPositionInLine;
                }

                ITreeNodeStream tns = input as ITreeNodeStream;
                if (tns != null)
                {
                    ExtractInformationFromTreeNodeStream(tns, k);
                }
                else
                {
                    ICharStream charStream = input as ICharStream;
                    if (charStream != null)
                    {
                        int mark = input.Mark();
                        try
                        {
                            for (int i = 0; i < k - 1; i++)
                                input.Consume();

                            this._c = input.LA(1);
                            this._line = ((ICharStream)input).Line;
                            this._charPositionInLine = ((ICharStream)input).CharPositionInLine;
                        }
                        finally
                        {
                            input.Rewind(mark);
                        }
                    }
                    else
                    {
                        this._c = input.LA(k);
                    }
                }
            }
        }
开发者ID:benpriebe,项目名称:TypeSql,代码行数:47,代码来源:RecognitionException.cs

示例6: RecognitionException

		public RecognitionException(string message, Exception inner, IIntStream input)
			: base(message, inner)
		{
			this.input = input;
			this.index = input.Index();
			if (input is ITokenStream)
			{
				this.token = ((ITokenStream)input).LT(1);
				this.line = token.Line;
				this.charPositionInLine = token.CharPositionInLine;
			}
			//if (input is ITreeNodeStream)
			//{
			//  ExtractInformationFromTreeNodeStream(input);
			//}
			//else
			if (input is ICharStream)
			{
				this.c = input.LA(1);
				this.line = ((ICharStream)input).Line;
				this.charPositionInLine = ((ICharStream)input).CharPositionInLine;
			}
			else
			{
				this.c = input.LA(1);
			}
		}
开发者ID:SmallMobile,项目名称:ranet-uilibrary-olap.latest-unstabilized,代码行数:27,代码来源:RecognitionException.cs

示例7: ConsumeUntil

		public virtual void ConsumeUntil(IIntStream input, int tokenType)
		{
			int ttype = input.LA(1);
			while (ttype != Token.EOF && ttype != tokenType)
			{
				input.Consume();
				ttype = input.LA(1);
			}
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:9,代码来源:BaseRecognizer.cs

示例8: MismatchIsUnwantedToken

		public bool MismatchIsUnwantedToken(IIntStream input, int ttype) {
			return input.LA(2) == ttype;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:3,代码来源:BaseRecognizer.cs

示例9: ConsumeUntil

 public virtual void ConsumeUntil( IIntStream input, int tokenType )
 {
     //System.out.println("consumeUntil "+tokenType);
     int ttype = input.LA( 1 );
     while ( ttype != TokenTypes.EndOfFile && ttype != tokenType )
     {
         input.Consume();
         ttype = input.LA( 1 );
     }
 }
开发者ID:biddyweb,项目名称:azfone-ios,代码行数:10,代码来源:BaseRecognizer.cs

示例10: ConsumeUntil

 public virtual void ConsumeUntil(IIntStream input, int tokenType)
 {
     for (int i = input.LA(1); (i != -1) && (i != tokenType); i = input.LA(1))
     {
         input.Consume();
     }
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:7,代码来源:BaseRecognizer.cs

示例11: MismatchIsUnwantedToken

 public virtual bool MismatchIsUnwantedToken(IIntStream input, int ttype)
 {
     return (input.LA(2) == ttype);
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:4,代码来源:BaseRecognizer.cs

示例12: MismatchIsMissingToken

 public virtual bool MismatchIsMissingToken(IIntStream input, BitSet follow)
 {
     if (follow == null)
     {
         return false;
     }
     if (follow.Member(1))
     {
         BitSet a = this.ComputeContextSensitiveRuleFOLLOW();
         follow = follow.Or(a);
         if (this.state._fsp >= 0)
         {
             follow.Remove(1);
         }
     }
     if (!follow.Member(input.LA(1)) && !follow.Member(1))
     {
         return false;
     }
     return true;
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:21,代码来源:BaseRecognizer.cs

示例13: Predict

        /** <summary>
         *  From the input stream, predict what alternative will succeed
         *  using this DFA (representing the covering regular approximation
         *  to the underlying CFL).  Return an alternative number 1..n.  Throw
         *  an exception upon error.
         *  </summary>
         */
        public virtual int Predict( IIntStream input )
        {
            if (input == null)
                throw new ArgumentNullException("input");

            DfaDebugMessage("Enter DFA.Predict for decision {0}", decisionNumber);

            int mark = input.Mark(); // remember where decision started in input
            int s = 0; // we always start at s0
            try
            {
                while (true)
                {
                    DfaDebugMessage("DFA {0} state {1} LA(1)={2}({3}), index={4}", decisionNumber, s, (char)input.LA(1), input.LA(1), input.Index);

                    int specialState = special[s];
                    if ( specialState >= 0 )
                    {
                        DfaDebugMessage("DFA {0} state {1} is special state {2}", decisionNumber, s, specialState);

                        s = SpecialStateTransition( this, specialState, input );

                        DfaDebugMessage("DFA {0} returns from special state {1} to {2}", decisionNumber, specialState, s);

                        if ( s == -1 )
                        {
                            NoViableAlt( s, input );
                            return 0;
                        }

                        input.Consume();
                        continue;
                    }

                    if ( accept[s] >= 1 )
                    {
                        DfaDebugMessage("accept; predict {0} from state {1}", accept[s], s);
                        return accept[s];
                    }

                    // look for a normal char transition
                    char c = (char)input.LA( 1 ); // -1 == \uFFFF, all tokens fit in 65000 space
                    if ( c >= min[s] && c <= max[s] )
                    {
                        int snext = transition[s][c - min[s]]; // move to next state
                        if ( snext < 0 )
                        {
                            // was in range but not a normal transition
                            // must check EOT, which is like the else clause.
                            // eot[s]>=0 indicates that an EOT edge goes to another
                            // state.
                            if ( eot[s] >= 0 )
                            {
                                // EOT Transition to accept state?
                                DfaDebugMessage("EOT transition");
                                s = eot[s];
                                input.Consume();
                                // TODO: I had this as return accept[eot[s]]
                                // which assumed here that the EOT edge always
                                // went to an accept...faster to do this, but
                                // what about predicated edges coming from EOT
                                // target?
                                continue;
                            }

                            NoViableAlt( s, input );
                            return 0;
                        }

                        s = snext;
                        input.Consume();
                        continue;
                    }

                    if ( eot[s] >= 0 )
                    {
                        // EOT Transition?
                        DfaDebugMessage("EOT transition");
                        s = eot[s];
                        input.Consume();
                        continue;
                    }

                    if ( c == unchecked( (char)TokenTypes.EndOfFile ) && eof[s] >= 0 )
                    {
                        // EOF Transition to accept state?
                        DfaDebugMessage("accept via EOF; predict {0} from {1}", accept[eof[s]], eof[s]);
                        return accept[eof[s]];
                    }

                    // not in range and not EOF/EOT, must be invalid symbol
                    DfaDebugInvalidSymbol(s);

//.........这里部分代码省略.........
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:101,代码来源:DFA.cs

示例14: ParseEngine

        /** Fill a list of all NFA states visited during the parse */
        protected virtual void ParseEngine( String startRule,
                                   NFAState start,
                                   NFAState stop,
                                   IIntStream input,
                                   Stack<object> ruleInvocationStack,
                                   IDebugEventListener actions,
                                   IList visitedStates )
        {
            NFAState s = start;
            if ( actions != null )
            {
                actions.EnterRule( s.nfa.grammar.FileName, start.enclosingRule.Name );
            }
            int t = input.LA( 1 );
            while ( s != stop )
            {
                if ( visitedStates != null )
                {
                    visitedStates.Add( s );
                }
                //Console.Out.WriteLine( "parse state " + s.stateNumber + " input=" + s.nfa.grammar.getTokenDisplayName( t ) );
                // CASE 1: decision state
                if ( s.DecisionNumber > 0 && s.nfa.grammar.GetNumberOfAltsForDecisionNFA( s ) > 1 )
                {
                    // decision point, must predict and jump to alt
                    DFA dfa = s.nfa.grammar.GetLookaheadDFA( s.DecisionNumber );
                    //if ( s.nfa.grammar.type != GrammarType.Lexer )
                    //{
                    //    Console.Out.WriteLine( "decision: " +
                    //                   dfa.getNFADecisionStartState().Description +
                    //                   " input=" + s.nfa.grammar.getTokenDisplayName( t ) );
                    //}
                    int m = input.Mark();
                    int predictedAlt = Predict( dfa );
                    if ( predictedAlt == NFA.INVALID_ALT_NUMBER )
                    {
                        String description = dfa.NFADecisionStartState.Description;
                        NoViableAltException nvae =
                            new NoViableAltException( description,
                                                          dfa.DecisionNumber,
                                                          s.stateNumber,
                                                          input );
                        if ( actions != null )
                        {
                            actions.RecognitionException( nvae );
                        }
                        input.Consume(); // recover
                        throw nvae;
                    }
                    input.Rewind( m );
                    int parseAlt =
                        s.TranslateDisplayAltToWalkAlt( predictedAlt );
                    //if ( s.nfa.grammar.type != GrammarType.Lexer )
                    //{
                    //    Console.Out.WriteLine( "predicted alt " + predictedAlt + ", parseAlt " + parseAlt );
                    //}
                    NFAState alt;
                    if ( parseAlt > s.nfa.grammar.GetNumberOfAltsForDecisionNFA( s ) )
                    {
                        // implied branch of loop etc...
                        alt = s.nfa.grammar.nfa.GetState( s.endOfBlockStateNumber );
                    }
                    else
                    {
                        alt = s.nfa.grammar.GetNFAStateForAltOfDecision( s, parseAlt );
                    }
                    s = (NFAState)alt.transition[0].target;
                    continue;
                }

                // CASE 2: finished matching a rule
                if ( s.IsAcceptState )
                { // end of rule node
                    if ( actions != null )
                    {
                        actions.ExitRule( s.nfa.grammar.FileName, s.enclosingRule.Name );
                    }
                    if ( ruleInvocationStack.Count == 0 )
                    {
                        // done parsing.  Hit the start state.
                        //Console.Out.WriteLine( "stack empty in stop state for " + s.enclosingRule );
                        break;
                    }
                    // pop invoking state off the stack to know where to return to
                    NFAState invokingState = (NFAState)ruleInvocationStack.Pop();
                    RuleClosureTransition invokingTransition =
                            (RuleClosureTransition)invokingState.transition[0];
                    // move to node after state that invoked this rule
                    s = invokingTransition.followState;
                    continue;
                }

                Transition trans = s.transition[0];
                Label label = trans.label;
                if ( label.IsSemanticPredicate )
                {
                    FailedPredicateException fpe =
                        new FailedPredicateException( input,
                                                     s.enclosingRule.Name,
//.........这里部分代码省略.........
开发者ID:bszafko,项目名称:antlrcs,代码行数:101,代码来源:Interpreter.cs

示例15: Match

		/// <summary>
		/// Match current input symbol against ttype.  Attempt
		/// single token insertion or deletion error recovery.  If
		/// that fails, throw MismatchedTokenException.
		/// </summary>
		/// <remarks>
		/// To turn off single token insertion or deletion error
		/// recovery, override RecoverFromMismatchedToken() and have it call
		/// pthrow an exception. See TreeParser.RecoverFromMismatchedToken().
		/// This way any error in a rule will cause an exception and
     	/// immediate exit from rule.  Rule would recover by resynchronizing
     	/// to the set of symbols that can follow rule ref.
		/// </remarks>
		public virtual object Match(IIntStream input, int ttype, BitSet follow) {
			object matchedSymbol = GetCurrentInputSymbol(input);
			if (input.LA(1) == ttype) {
				input.Consume();
				state.errorRecovery = false;
				state.failed = false;
				return matchedSymbol;
			}
			if (state.backtracking > 0) {
				state.failed = true;
				return matchedSymbol;
			}
			matchedSymbol = RecoverFromMismatchedToken(input, ttype, follow);
			return matchedSymbol;
		}
开发者ID:sebasjm,项目名称:antlr,代码行数:28,代码来源:BaseRecognizer.cs


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