本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}