本文整理汇总了C#中TokenStream.MoveNextToken方法的典型用法代码示例。如果您正苦于以下问题:C# TokenStream.MoveNextToken方法的具体用法?C# TokenStream.MoveNextToken怎么用?C# TokenStream.MoveNextToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenStream
的用法示例。
在下文中一共展示了TokenStream.MoveNextToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseStream
void ParseStream(TokenStream reader)
{
while (true)
{
var exp = reader.MoveNextToken();
switch (exp.Type)
{
case TokenType.EndOfStream:
case TokenType.ArgumentSeparator:
case TokenType.ArgumentEnd:
return;
case TokenType.Operator:
PushOperator(exp.ToOperator());
break;
case TokenType.Identifier:
//Get variable/unit/constant
var id = exp.ToIdentifier();
var def = block.GetDefinition(id);
if (def == null)
throw new SemanticError(id, "Undefined variable: " + id.Name);
if (def is FuncDefinition)
{
FunctionCall func = ParseFunctionCall(reader);
PushImplicitMultiplication(func);
}
else if (def is VarDefinition)
PushImplicitMultiplication(id);
else if (def is ConstDefinition)
{
//Preserve position of identifier
var c = ((ConstDefinition)def).Value;
var val = c.WithRangeOf(id);
PushImplicitMultiplication(val);
}
else if (def is UnitDefinition)
PushImplicitMultiplication(((UnitDefinition)def).GetLiteral(exp.CodeRange));
else
throw new NotImplementedException();
break;
case TokenType.Int:
case TokenType.Double:
case TokenType.Boolean:
case TokenType.String:
PushLiteral(exp.ToLiteral());
break;
default:
throw new NotImplementedException();
}
}
}