当前位置: 首页>>代码示例>>C#>>正文


C# ParsingContext.AddParserError方法代码示例

本文整理汇总了C#中Irony.Parsing.ParsingContext.AddParserError方法的典型用法代码示例。如果您正苦于以下问题:C# ParsingContext.AddParserError方法的具体用法?C# ParsingContext.AddParserError怎么用?C# ParsingContext.AddParserError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Irony.Parsing.ParsingContext的用法示例。


在下文中一共展示了ParsingContext.AddParserError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryMatch

 public override Token TryMatch(ParsingContext context, ISourceStream source) {
   string tokenText = string.Empty;
   while (true) {
     //Find next position
     var newPos = source.Text.IndexOfAny(_stopChars, source.PreviewPosition);
     if(newPos == -1) {
       if(IsSet(FreeTextOptions.AllowEof)) {
         source.PreviewPosition = source.Text.Length;
         return source.CreateToken(this.OutputTerminal);
       }  else
         return null;
     }
     if (newPos == source.PreviewPosition)   // DC
     {
         context.AddParserError("(DC) in TryMatch, newPos == source.PreviewPosition", new object[] {});
         break;                              // DC
     }
     tokenText += source.Text.Substring(source.PreviewPosition, newPos - source.PreviewPosition);
     source.PreviewPosition = newPos;
     //if it is escape, add escaped text and continue search
     if (CheckEscape(source, ref tokenText)) 
       continue;
     //check terminators
     if (CheckTerminators(source, ref tokenText))
       break; //from while (true)        
   }
   return source.CreateToken(this.OutputTerminal, tokenText);
 }
开发者ID:pusp,项目名称:o2platform,代码行数:28,代码来源:FreeTextLiteral.cs

示例2: Execute

 public override void Execute(ParsingContext context)
 {
     if (context.TracingEnabled)
         context.AddTrace(Resources.MsgTraceExecCustomAction);
     //States with DefaultAction do NOT read input, so we read it here
     if (context.CurrentParserInput == null)
         context.Parser.ReadInput();
     // Remember old state and input; if they don't change after custom action - it is error, we may fall into an endless loop
     var oldState = context.CurrentParserState;
     var oldInput = context.CurrentParserInput;
     ExecuteRef(context, this);
     //Prevent from falling into an infinite loop 
     if (context.CurrentParserState == oldState && context.CurrentParserInput == oldInput)
     {
         context.AddParserError(Resources.MsgErrorCustomActionDidNotAdvance);
         context.Parser.RecoverFromError();
     }
 } //method
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:18,代码来源:CustomActionHintAction.cs

示例3: ReportParseError

 // Override this method to perform custom error processing
 public virtual void ReportParseError(ParsingContext context)
 {
     string error = null;
     if (context.CurrentParserInput.Term == this.SyntaxError)
     error = context.CurrentParserInput.Token.Value as string; //scanner error
     else if (context.CurrentParserInput.Term == this.Indent)
     error = Resources.ErrUnexpIndent;
     else if (context.CurrentParserInput.Term == this.Eof && context.OpenBraces.Count > 0) {
       if (context.OpenBraces.Count > 0) {
     //report unclosed braces/parenthesis
     var openBrace = context.OpenBraces.Peek();
     error = string.Format(Resources.ErrNoClosingBrace, openBrace.Text);
       } else
       error = Resources.ErrUnexpEof;
     }else {
     var expectedTerms = context.GetExpectedTermSet();
     error = ConstructParserErrorMessage(context, expectedTerms);
     }
     context.AddParserError(error);
 }
开发者ID:adrobyazko-softheme,项目名称:PQL,代码行数:21,代码来源:Grammar.cs


注:本文中的Irony.Parsing.ParsingContext.AddParserError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。