本文整理汇总了C#中Statement.Push方法的典型用法代码示例。如果您正苦于以下问题:C# Statement.Push方法的具体用法?C# Statement.Push怎么用?C# Statement.Push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement.Push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Scan
/// <summary>
/// Scans the current parse engine for a matrix expression.
/// </summary>
/// <param name="engine">The parse engine to use.</param>
/// <returns>The found expression or NULL.</returns>
public override Expression Scan(ParseEngine engine)
{
var column = engine.CurrentColumn;
var line = engine.CurrentLine;
var chars = engine.Characters;
var start = engine.Pointer;
if (chars[start] == '[')
{
engine.Advance();
var terminated = false;
var statement = new Statement();
var ws = false;
var nl = false;
while (engine.Pointer < chars.Length && engine.IsParsing)
{
if (ParseEngine.IsWhiteSpace(chars[engine.Pointer]))
{
ws = true;
engine.Advance();
}
else if (ParseEngine.IsNewLine(chars[engine.Pointer]))
{
nl = true;
engine.Advance();
}
else if (chars[engine.Pointer] == ']')
{
terminated = true;
engine.Advance();
break;
}
else if (chars[engine.Pointer] == ',')
{
ws = false;
nl = false;
statement.Push(engine, new ColumnOperator(engine));
engine.Advance();
}
else if (chars[engine.Pointer] == ';')
{
ws = false;
nl = false;
statement.Push(engine, new RowOperator(engine));
engine.Advance();
}
else if (engine.Pointer < chars.Length - 1 && ParseEngine.IsComment(chars[engine.Pointer], chars[engine.Pointer + 1]))
{
if (ParseEngine.IsLineComment(chars[engine.Pointer], chars[engine.Pointer + 1]))
engine.AdvanceToNextLine();
else
engine.AdvanceTo("*/");
}
else
{
engine.ParseBlock(statement, nl ? (Operator)new RowOperator(engine) : (ws ? new ColumnOperator(engine) : null));
ws = false;
nl = false;
}
}
if (!terminated)
{
var err = new YAMPMatrixNotClosedError(line, column);
engine.AddError(err);
}
var container = statement.Finalize(engine).Container;
return new MatrixExpression(line, column, engine.Pointer - start, engine.Query, container ?? new ContainerExpression());
}
return null;
}
示例2: ParseBlock
/// <summary>
/// Parses a block with a default operator if no operator has been found.
/// </summary>
/// <param name="statement">The statement that should get the block.</param>
/// <param name="defaultOperator">The default operator if no operator has been found.</param>
/// <returns>The statement again (allows chaining).</returns>
internal Statement ParseBlock(Statement statement, Operator defaultOperator = null)
{
_currentStatement = statement;
if (statement.IsOperator)
{
var op = Elements.FindOperator(this) ?? defaultOperator;
if (op == null)
{
AddError(new YAMPOperatorMissingError(_currentLine, _currentColumn));
}
statement.Push(this, op);
}
else
{
var op = Elements.FindLeftUnaryOperator(this);
if (op == null)
{
var exp = Elements.FindExpression(this);
if (exp == null)
{
AddError(new YAMPExpressionExpectedError(_currentLine, _currentColumn));
}
statement.Push(this, exp);
}
else
{
statement.Push(this, op);
}
}
return statement;
}