本文整理汇总了C#中ParseContext.UpdateCurrentChar方法的典型用法代码示例。如果您正苦于以下问题:C# ParseContext.UpdateCurrentChar方法的具体用法?C# ParseContext.UpdateCurrentChar怎么用?C# ParseContext.UpdateCurrentChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseContext
的用法示例。
在下文中一共展示了ParseContext.UpdateCurrentChar方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoExecute
protected override void DoExecute(ParseContext context)
{
context.Input.Read(3);
context.UpdateCurrentChar();
OpenScope(new HorizontalRulerScope(), context);
CloseCurrentScope(context);
}
示例2: DoExecute
protected override void DoExecute(ParseContext context)
{
var depth = 1;
while (context.Input.Peek() == '!') {
depth++;
context.Input.Read();
}
context.Input.SeekToNonWhitespace(); //ignore spaces/tabs
context.UpdateCurrentChar();
OpenScope(new HeaderScope(depth), context);
}
示例3: DoExecute
protected override sealed void DoExecute(ParseContext context)
{
var peek = context.Input.Peek();
var functionNameBuilder = new StringBuilder();
while (peek != ButterflyStringReader.NoValue && peek != '|' && peek != ']') {
functionNameBuilder.Append((char)context.Input.Read());
peek = context.Input.Peek();
}
var closer = context.Input.Read(); //| or ]
var name = functionNameBuilder.ToString();
var data = new Dictionary<string, string>();
if (closer != ']') {
//read module options
peek = context.Input.Peek();
var optionStringBuilder = new StringBuilder();
while (peek != ButterflyStringReader.NoValue) {
if (peek == ']') {
context.Input.Read();
if (context.Input.Peek() != ']') {
//module closer
break;
}
//fallthrough: output a literal "]"
} else if (peek == '|') {
context.Input.Read();
if (context.Input.Peek() != '|') {
ParseOptions(optionStringBuilder.ToString(), data);
optionStringBuilder.Clear();
}
//fallthrough: output a literal "|"
}
optionStringBuilder.Append((char)context.Input.Read());
peek = context.Input.Peek();
}
//handle the last option
if (optionStringBuilder.Length > 0) {
ParseOptions(optionStringBuilder.ToString(), data);
}
}
context.UpdateCurrentChar();
OpenAndCloseScope(CreateScope(name, data, context), context);
}
示例4: DoExecute
protected override void DoExecute(ParseContext context)
{
OpenScope(new UnparsedScope(), context);
var match = unparsedRegex.Match(context.Input.PeekSubstring);
if (!match.Success) {
throw new ParseException("Unparsed scope never closes");
}
var text = match.Groups[1].Value.Replace("]]", "]");
context.Input.Read(match.Value.Length);
context.UpdateCurrentChar();
context.Analyzer.WriteAndEscape(text);
CloseCurrentScope(context);
}
示例5: DoExecute
protected override void DoExecute(ParseContext context)
{
var peek = context.Input.Peek();
var listText = new StringBuilder(((char)context.CurrentChar).ToString(), 3);
while (peek == '*' || peek == '#') {
listText.Append((char)context.Input.Read());
peek = context.Input.Peek();
}
//ignore whitespace after * or #
context.Input.SeekToNonWhitespace();
context.UpdateCurrentChar();
HandleList(listText.ToString(), context);
}
示例6: 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);
}
}
示例7: DoExecute
protected override void DoExecute(ParseContext context)
{
OpenScope(new PreformattedScope(GetLanguage(context)), context);
//this strategy ignores any formatting
//read until }}}}
var match = codeRegex.Match(context.Input.PeekSubstring);
if (!match.Success) {
throw new ParseException("Preformatted scope never closes");
}
var text = match.Groups[1].Value;
context.Input.Read(match.Value.Length);
context.UpdateCurrentChar();
context.Analyzer.WriteAndEscape(text);
CloseCurrentScope(context);
}