本文整理汇总了C#中Statement.Finalize方法的典型用法代码示例。如果您正苦于以下问题:C# Statement.Finalize方法的具体用法?C# Statement.Finalize怎么用?C# Statement.Finalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement.Finalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseStatement
/// <summary>
/// More custom parsing of a statement (ends with a custom termination char).
/// </summary>
/// <param name="termination">The custom termination character (e.g. ; for the standard case).</param>
/// <param name="terminationMissing">Function (to generate an error) that is called if the termination character is not found.</param>
/// <param name="handleCharacter">An optional function that is invoked for every character.</param>
/// <returns>The finalized statement.</returns>
internal Statement ParseStatement(Char termination, Func<ParseEngine, YAMPParseError> terminationMissing = null, Func<Char, Statement, Boolean> handleCharacter = null)
{
var terminated = false;
var statement = new Statement();
while (_parsing && _ptr < _characters.Length)
{
if (handleCharacter == null || !handleCharacter(_characters[_ptr], statement))
{
if (IsWhiteSpace(_characters[_ptr]))
{
_ptr++;
_currentColumn++;
}
else if (IsNewLine(_characters[_ptr]))
{
_ptr++;
_currentColumn = 1;
_currentLine++;
}
else if (_characters[_ptr] == termination)
{
terminated = true;
_currentColumn++;
_ptr++;
break;
}
else if (_ptr < _characters.Length - 1 && IsComment(_characters[_ptr], _characters[_ptr + 1]))
{
if (IsLineComment(_characters[_ptr], _characters[_ptr + 1]))
AdvanceToNextLine();
else
AdvanceTo("*/");
}
else
{
ParseBlock(statement);
}
}
}
if (!terminated)
{
AddError(terminationMissing != null ? terminationMissing(this) : new YAMPTerminatorMissingError(_currentLine, _currentColumn, termination));
}
return statement.Finalize(this);
}
示例2: 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;
}