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


C# ITokenStream.Get方法代码示例

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


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

示例1: TokenStreamVisualizerForm

        public TokenStreamVisualizerForm( ITokenStream tokenStream )
        {
            if (tokenStream == null)
                throw new ArgumentNullException("tokenStream");

            InitializeComponent();

            List<IToken> tokens = new List<IToken>();

            int marker = tokenStream.Mark();
            int currentPosition = tokenStream.Index;
            try
            {
                tokenStream.Seek(0);
                while (tokenStream.LA(1) != CharStreamConstants.EndOfFile)
                    tokenStream.Consume();

                for (int i = 0; i < tokenStream.Count; i++)
                    tokens.Add(tokenStream.Get(i));
            }
            finally
            {
                tokenStream.Rewind(marker);
            }

            this._tokenStream = tokenStream;
            this._tokens = tokens.ToArray();

            if (tokenStream.TokenSource != null)
                this._tokenNames = tokenStream.TokenSource.TokenNames;

            this._tokenNames = this._tokenNames ?? new string[0];

            UpdateTokenTypes();
            UpdateHighlighting();

            listBox1.BackColor = Color.Wheat;
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:38,代码来源:TokenStreamVisualizerForm.cs

示例2: NoViableAlt

        protected NoViableAltException NoViableAlt(ITokenStream input,
												ParserRuleContext outerContext,
												ATNConfigSet configs,
												int startIndex)
        {
            return new NoViableAltException(parser, input,
                                                input.Get(startIndex),
                                                input.LT(1),
                                                configs, outerContext);
        }
开发者ID:antlr,项目名称:antlr4,代码行数:10,代码来源:ParserATNSimulator.cs

示例3: getLastOpTokenIndex

    /** Find stop token index of next operator; return -1 if not operator. */

    public static int getLastOpTokenIndex(ITokenStream tokens) {
        var i = tokens.Index; // current on-channel lookahead token index
        var lt = tokens.Get(i);
        if (lt.getType() == SwiftParser.DOT && tokens.get(i + 1).getType() == SwiftParser.DOT) {
            // dot-operator
            i += 2; // point at token after ".."
            lt = tokens.get(i);
            while (lt.getType() != Token.EOF &&
                   (lt.getType() == SwiftParser.DOT || isOperatorChar(lt.getType()))) {
                i++;
                lt = tokens.get(i);
            }
            return i - 1;
        }
        // Is it regular operator?
        if (!isOperatorHead(lt.getType())) {
            return -1;
        }
        i++;
        lt = tokens.get(i);
        while (lt.getType() != Token.EOF && isOperatorChar(lt.getType())) {
            i++;
            lt = tokens.get(i);
        }
        int stop = i - 1;
        return stop;
    }
开发者ID:exKAZUu,项目名称:Code2Xml,代码行数:29,代码来源:SwiftSupport.cs

示例4: isOpNext

 public static boolean isOpNext(ITokenStream tokens) {
     var start = tokens.Index;
     var lt = tokens.Get(start);
     var stop = getLastOpTokenIndex(tokens);
     if (stop == -1) return false;
     Console.WriteLine("isOpNext: i={0} t='{1}'", start, lt.getText());
     Console.WriteLine(", op='{0}'\n", tokens.GetText(Interval.Of(start, stop)));
     return true;
 }
开发者ID:exKAZUu,项目名称:Code2Xml,代码行数:9,代码来源:SwiftSupport.cs


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