本文整理汇总了C#中Iodine.Compiler.TokenStream.ReadToken方法的典型用法代码示例。如果您正苦于以下问题:C# TokenStream.ReadToken方法的具体用法?C# TokenStream.ReadToken怎么用?C# TokenStream.ReadToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iodine.Compiler.TokenStream
的用法示例。
在下文中一共展示了TokenStream.ReadToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseTerm
public static AstNode ParseTerm(TokenStream stream)
{
switch (stream.Current.Class) {
case TokenClass.Identifier:
return new NameExpression (stream.Location, stream.ReadToken ().Value);
case TokenClass.IntLiteral:
return new IntegerExpression (stream.Location, long.Parse (
stream.ReadToken ().Value));
case TokenClass.FloatLiteral:
return new FloatExpression (stream.Location, double.Parse (
stream.ReadToken ().Value));
case TokenClass.InterpolatedStringLiteral:
AstNode val = ParseString (stream.Location, stream.ReadToken ().Value);
if (val == null) {
stream.MakeError ();
return new StringExpression (stream.Location, "");
}
return val;
case TokenClass.StringLiteral:
return new StringExpression (stream.Location, stream.ReadToken ().Value);
case TokenClass.OpenBracket:
return ParseList (stream);
case TokenClass.OpenBrace:
return ParseHash (stream);
case TokenClass.OpenParan:
stream.ReadToken ();
AstNode expr = ParseExpression (stream);
if (stream.Accept (TokenClass.Comma)) {
return ParseTuple (expr, stream);
}
stream.Expect (TokenClass.CloseParan);
return expr;
case TokenClass.Keyword:
switch (stream.Current.Value) {
case "self":
stream.ReadToken ();
return new SelfStatement (stream.Location);
case "true":
stream.ReadToken ();
return new TrueExpression (stream.Location);
case "false":
stream.ReadToken ();
return new FalseExpression (stream.Location);
case "null":
stream.ReadToken ();
return new NullExpression (stream.Location);
case "lambda":
return ParseLambda (stream);
case "match":
return ParseMatch (stream);
}
break;
}
stream.MakeError ();
return null;
}