本文整理汇总了C#中ISourceStream.CreateErrorToken方法的典型用法代码示例。如果您正苦于以下问题:C# ISourceStream.CreateErrorToken方法的具体用法?C# ISourceStream.CreateErrorToken怎么用?C# ISourceStream.CreateErrorToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISourceStream
的用法示例。
在下文中一共展示了ISourceStream.CreateErrorToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryMatch
public override Token TryMatch(ParsingContext context, ISourceStream source)
{
Token result;
if (context.VsLineScanState.Value != 0)
{
byte commentLevel = context.VsLineScanState.TokenSubType;
result = CompleteMatch(context, source, commentLevel);
}
else
{
//we are starting from scratch
byte commentLevel = 0;
if (!BeginMatch(context, source, ref commentLevel))
return null;
result = CompleteMatch(context, source, commentLevel);
}
if (result != null)
return result;
if (context.Mode == ParseMode.VsLineScan)
return CreateIncompleteToken(context, source);
return source.CreateErrorToken("Unclosed comment block");
}
示例2: TryMatch
public override Token TryMatch(ParsingContext context, ISourceStream source) {
try {
var textValue = ReadBody(context, source);
if (textValue == null) return null;
var value = ConvertValue(context, textValue);
return source.CreateToken(this.OutputTerminal, value);
} catch(Exception ex) {
//we throw exception in DsvLiteral when we cannot find a closing quote for quoted value
return source.CreateErrorToken(ex.Message);
}
}//method
示例3: TryMatch
public override Token TryMatch(ParsingContext context, ISourceStream source) {
Token result;
if (context.VsLineScanState.Value != 0) {
// we are continuing in line mode - restore internal env (none in this case)
context.VsLineScanState.Value = 0;
} else {
//we are starting from scratch
if (!BeginMatch(context, source)) return null;
}
result = CompleteMatch(context, source);
if (result != null) return result;
//if it is LineComment, it is ok to hit EOF without final line-break; just return all until end.
if (_isLineComment)
return source.CreateToken(this.OutputTerminal);
if (context.Mode == ParseMode.VsLineScan)
return CreateIncompleteToken(context, source);
return source.CreateErrorToken(O2_Misc_Microsoft_MPL_Libs.Irony_Parser.Resources.ErrUnclosedComment);
}
示例4: TryMatch
public override Token TryMatch(ParsingContext context, ISourceStream source) {
// Quick check
var lookAhead = source.PreviewChar;
var startIndex = _startSymbolsFirsts.IndexOf(lookAhead);
if (startIndex < 0)
return null;
// Match start symbols
if (!BeginMatch(source, startIndex, lookAhead))
return null;
// Match NewLine
var result = CompleteMatch(source);
if (result != null)
return result;
// Report an error
return source.CreateErrorToken(Resources.ErrNewLineExpected);
}
示例5: TryMatchContentSimple
private Token TryMatchContentSimple(ParsingContext context, ISourceStream source)
{
var startPos = source.PreviewPosition;
int p = source.Text.IndexOf(_singleTerminator, startPos, Grammar.StringComparisonMode);
if (p < 0 && IsSet(FreeTextOptions.AllowEof))
p = source.Text.Length;
if (p < 0)
return source.CreateErrorToken(Resources.ErrFreeTextNoEndTag, _singleTerminator);
var tokenText = source.Text.Substring(startPos, p - startPos);
return source.CreateToken(this.OutputTerminal, tokenText);
}