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


C# ITreeNodeStream.LT方法代码示例

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


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

示例1: ToNodesOnlyString

 public string ToNodesOnlyString( ITreeNodeStream nodes )
 {
     ITreeAdaptor adaptor = nodes.TreeAdaptor;
     StringBuilder buf = new StringBuilder();
     object o = nodes.LT( 1 );
     int type = adaptor.GetType( o );
     while ( o != null && type != TokenTypes.EndOfFile )
     {
         if ( !( type == TokenTypes.Down || type == TokenTypes.Up ) )
         {
             buf.Append( " " );
             buf.Append( type );
         }
         nodes.Consume();
         o = nodes.LT( 1 );
         type = adaptor.GetType( o );
     }
     return buf.ToString();
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:19,代码来源:TestTreeNodeStream.cs

示例2: ExtractInformationFromTreeNodeStream

 protected virtual void ExtractInformationFromTreeNodeStream(ITreeNodeStream input)
 {
     this._node = input.LT(1);
     ITokenStreamInformation streamInformation = input as ITokenStreamInformation;
     if (streamInformation != null)
     {
         IToken lastToken = streamInformation.LastToken;
         IToken lastRealToken = streamInformation.LastRealToken;
         if (lastRealToken != null)
         {
             this._token = lastRealToken;
             this._line = lastRealToken.Line;
             this._charPositionInLine = lastRealToken.CharPositionInLine;
             this._approximateLineInfo = lastRealToken.Equals(lastToken);
         }
     }
     else
     {
         ITreeAdaptor adaptor = input.TreeAdaptor;
         IToken payload = adaptor.GetToken(_node);
         if (payload != null)
         {
             this._token = payload;
             if (payload.Line <= 0)
             {
                 // imaginary node; no line/pos info; scan backwards
                 int i = -1;
                 object priorNode = input.LT(i);
                 while (priorNode != null)
                 {
                     IToken priorPayload = adaptor.GetToken(priorNode);
                     if (priorPayload != null && priorPayload.Line > 0)
                     {
                         // we found the most recent real line / pos info
                         this._line = priorPayload.Line;
                         this._charPositionInLine = priorPayload.CharPositionInLine;
                         this._approximateLineInfo = true;
                         break;
                     }
                     --i;
                     try
                     {
                         priorNode = input.LT(i);
                     }
                     catch (ArgumentException)
                     {
                         priorNode = null;
                     }
                 }
             }
             else
             {
                 // node created from real token
                 this._line = payload.Line;
                 this._charPositionInLine = payload.CharPositionInLine;
             }
         }
         else if (this._node is Tree.ITree)
         {
             this._line = ((Tree.ITree)this._node).Line;
             this._charPositionInLine = ((Tree.ITree)this._node).CharPositionInLine;
             if (this._node is CommonTree)
             {
                 this._token = ((CommonTree)this._node).Token;
             }
         }
         else
         {
             int type = adaptor.GetType(this._node);
             string text = adaptor.GetText(this._node);
             this._token = new CommonToken(type, text);
         }
     }
 }
开发者ID:biddyweb,项目名称:azfone-ios,代码行数:74,代码来源:RecognitionException.cs

示例3: ExtractInformationFromTreeNodeStream

 protected virtual void ExtractInformationFromTreeNodeStream(ITreeNodeStream input)
 {
     this._node = input.LT(1);
     ITokenStreamInformation information = input as ITokenStreamInformation;
     if (information != null)
     {
         IToken lastToken = information.LastToken;
         IToken lastRealToken = information.LastRealToken;
         if (lastRealToken != null)
         {
             this._token = lastRealToken;
             this._line = lastRealToken.Line;
             this._charPositionInLine = lastRealToken.CharPositionInLine;
             this._approximateLineInfo = lastRealToken.Equals(lastToken);
         }
     }
     else
     {
         ITreeAdaptor treeAdaptor = input.TreeAdaptor;
         IToken token = treeAdaptor.GetToken(this._node);
         if (token == null)
         {
             if (this._node is ITree)
             {
                 this._line = ((ITree) this._node).Line;
                 this._charPositionInLine = ((ITree) this._node).CharPositionInLine;
                 if (this._node is CommonTree)
                 {
                     this._token = ((CommonTree) this._node).Token;
                 }
             }
             else
             {
                 int type = treeAdaptor.GetType(this._node);
                 string text = treeAdaptor.GetText(this._node);
                 this._token = new CommonToken(type, text);
             }
         }
         else
         {
             this._token = token;
             if (token.Line > 0)
             {
                 this._line = token.Line;
                 this._charPositionInLine = token.CharPositionInLine;
             }
             else
             {
                 int k = -1;
                 object t = input.LT(k);
                 while (t != null)
                 {
                     IToken token4 = treeAdaptor.GetToken(t);
                     if ((token4 != null) && (token4.Line > 0))
                     {
                         this._line = token4.Line;
                         this._charPositionInLine = token4.CharPositionInLine;
                         this._approximateLineInfo = true;
                         return;
                     }
                     k--;
                     try
                     {
                         t = input.LT(k);
                         continue;
                     }
                     catch (ArgumentException)
                     {
                         t = null;
                         continue;
                     }
                 }
             }
         }
     }
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:76,代码来源:RecognitionException.cs


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