本文整理汇总了C#中ScriptEngine.IsStatementEnd方法的典型用法代码示例。如果您正苦于以下问题:C# ScriptEngine.IsStatementEnd方法的具体用法?C# ScriptEngine.IsStatementEnd怎么用?C# ScriptEngine.IsStatementEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScriptEngine
的用法示例。
在下文中一共展示了ScriptEngine.IsStatementEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
{
string text = "";
bool space = false;
bool isFloat = false;
if (sourceCode.CurrentCode == '-')
{
text = "-";
sourceCode++;
while (sourceCode.SpecialChar)
{
sourceCode++;
}
}
while (!sourceCode.EOF && !engine.IsStatementEnd(sourceCode.CurrentCode, true))
{
if (sourceCode.CurrentCode == ' ')
{
space = true;
}
else
{
if (space)
{
throw new Exception("Unexpected Whitespace");
}
if (sourceCode.CurrentCode == '.')
{
if (!char.IsNumber(sourceCode.GetOffset(1)))
{
break;
}
}
if (sourceCode.CurrentCode == 'f' || sourceCode.CurrentCode == 'F')
{
isFloat = true;
}
else
{
if (isFloat)
{
throw new Exception("Expected ending condition.");
}
text += sourceCode.CurrentCode;
}
}
sourceCode++;
}
if (sourceCode.EOF)
{
throw new Exception("Unexpected EOF");
}
return new ObjectToken<Number>(new Number(double.Parse(text)));
}
示例2: Build
public override Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
{
string text = "";
bool space = false;
bool isLocal = (sourceCode.CurrentCode == '@');
if (sourceCode.GetOffset(1) == '$')
{
// Special code.
}
sourceCode++;
while (!sourceCode.EOF)
{
if (sourceCode.CurrentCode == ' ')
{
space = true;
}
else
{
if (engine.IsStatementEnd(sourceCode.CurrentCode))
{
return new VaraibleToken(text, isLocal);
}
else
{
if (space)
{
//throw new Exception("Unexpected whitespace.");
// Treat this as another statement, return what we have.
sourceCode--;
return new VaraibleToken(text, isLocal);
}
text += sourceCode.CurrentCode;
}
}
sourceCode++;
}
if (sourceCode.EOF)
{
throw new Exception("Unexpected EOF");
}
return null;
}