本文整理汇总了C#中ParseContext.AdvanceInput方法的典型用法代码示例。如果您正苦于以下问题:C# ParseContext.AdvanceInput方法的具体用法?C# ParseContext.AdvanceInput怎么用?C# ParseContext.AdvanceInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseContext
的用法示例。
在下文中一共展示了ParseContext.AdvanceInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLanguage
protected string GetLanguage(ParseContext context)
{
var languageBuilder = new StringBuilder();
context.AdvanceInput();
while (context.CurrentChar != '\n' && context.CurrentChar != ButterflyStringReader.NoValue) {
languageBuilder.Append((char)context.CurrentChar);
context.AdvanceInput();
}
return languageBuilder.ToString();
}
示例2: DoExecute
protected override void DoExecute(ParseContext context)
{
IScope rowScope = new TableRowLineScope();
if (context.Input.Peek() == '{') {
context.AdvanceInput();
rowScope = new TableRowScope();
}
var cellType = ScopeTypeCache.TableCell;
if (context.Input.Peek() == '!') {
context.AdvanceInput();
cellType = ScopeTypeCache.TableHeader;
}
context.Input.SeekToNonWhitespace();
context.UpdateCurrentChar();
if (!context.Scopes.ContainsType(ScopeTypeCache.Table)) {
//no tables, so create a new one
OpenScope(new TableScope(), context);
OpenScope(rowScope, context);
} else if (context.Scopes.ContainsType(ScopeTypeCache.TableCell, ScopeTypeCache.TableHeader)) {
//close table cell
var currentScope = context.Scopes.PeekOrDefault();
if (currentScope == null || (currentScope.GetType() != ScopeTypeCache.TableCell && currentScope.GetType() != ScopeTypeCache.TableHeader)) {
throw new ParseException("Cannot close table cell until all containing scopes are closed");
}
CloseCurrentScope(context);
} else if (!context.Scopes.ContainsType(ScopeTypeCache.TableRow, ScopeTypeCache.TableRowLine)) {
OpenScope(rowScope, context);
}
//figure out if we need to open a new cell or not
//criteria:
// - not EOL
// - we're in a row terminated by a line break and the next char is not a new line (signifying a new row)
// - OR we're in a row not terminated by a line break
if (
context.Input.Peek() != ButterflyStringReader.NoValue && (
(context.Scopes.ContainsType(ScopeTypeCache.TableRowLine) && context.Input.Peek() != '\n')
|| context.Scopes.ContainsType(ScopeTypeCache.TableRow)
)
) {
OpenScope(cellType == ScopeTypeCache.TableHeader ? (IScope)new TableHeaderScope() : new TableCellScope(), context);
}
}