• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Runtime.RecognitionException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Antlr.Runtime.RecognitionException的典型用法代码示例。如果您正苦于以下问题:C# RecognitionException类的具体用法?C# RecognitionException怎么用?C# RecognitionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RecognitionException类属于Antlr.Runtime命名空间,在下文中一共展示了RecognitionException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetErrorMessage

        public override string GetErrorMessage(RecognitionException e, string[] tokenNames)
        {
            System.Collections.IList stack = GetRuleInvocationStack(e, typeof(BlaiseParser).FullName);

            string msg = string.Empty;
            if (e is NoViableAltException)
            {
                NoViableAltException nvae = (NoViableAltException)e;
                msg = "noviablealt;token=" + e.Token.ToString() +
                    "(decision=" + nvae.decisionNumber +
                    "state" + nvae.stateNumber + ")" +
                    "decision=<<" + nvae.grammarDecisionDescription + ">>";
            }
            else
            {
                msg = base.GetErrorMessage(e, tokenNames);
            }

            string stackStr = string.Empty;
            foreach (object obj in stack)
            {
                stackStr += obj.ToString();
            }

            return stackStr + " " + msg;
        }
开发者ID:Colectica,项目名称:MetadataConverters,代码行数:26,代码来源:BParser.cs


示例2: DisplayRecognitionError

        public override void DisplayRecognitionError(string[] tokenNames, RecognitionException e)
        {
            var outputWindow = OutputWindowService.TryGetPane(PredefinedOutputWindowPanes.TvlIntellisense);
            if (outputWindow != null)
            {
                string header = GetErrorHeader(e);
                string message = GetErrorMessage(e, tokenNames);
                Span span = new Span();
                if (e.Token != null)
                    span = Span.FromBounds(e.Token.StartIndex, e.Token.StopIndex + 1);

                if (message.Length > 100)
                    message = message.Substring(0, 100) + " ...";

                ITextDocument document;
                if (TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document) && document != null)
                {
                    string fileName = document.FilePath;
                    var line = Snapshot.GetLineFromPosition(span.Start);
                    message = string.Format("{0}({1},{2}): {3}: {4}", fileName, line.LineNumber + 1, span.Start - line.Start.Position + 1, GetType().Name, message);
                }

                outputWindow.WriteLine(message);
            }

            base.DisplayRecognitionError(tokenNames, e);
        }
开发者ID:sebandraos,项目名称:LangSvcV2,代码行数:27,代码来源:AlloyBaseWalker.g3.cs


示例3: GetErrorMessage

 public override string GetErrorMessage(RecognitionException e, string[] tokenNames)
 {
     if (e is MismatchedTokenException)
     {
         MismatchedTokenException exception = (MismatchedTokenException) e;
         return ("mismatched character " + this.GetCharErrorDisplay(e.Character) + " expecting " + this.GetCharErrorDisplay(exception.Expecting));
     }
     if (e is NoViableAltException)
     {
         NoViableAltException exception1 = (NoViableAltException) e;
         return ("no viable alternative at character " + this.GetCharErrorDisplay(e.Character));
     }
     if (e is EarlyExitException)
     {
         EarlyExitException exception5 = (EarlyExitException) e;
         return ("required (...)+ loop did not match anything at character " + this.GetCharErrorDisplay(e.Character));
     }
     if (e is MismatchedNotSetException)
     {
         MismatchedNotSetException exception2 = (MismatchedNotSetException) e;
         return string.Concat(new object[] { "mismatched character ", this.GetCharErrorDisplay(e.Character), " expecting set ", exception2.Expecting });
     }
     if (e is MismatchedSetException)
     {
         MismatchedSetException exception3 = (MismatchedSetException) e;
         return string.Concat(new object[] { "mismatched character ", this.GetCharErrorDisplay(e.Character), " expecting set ", exception3.Expecting });
     }
     if (e is MismatchedRangeException)
     {
         MismatchedRangeException exception4 = (MismatchedRangeException) e;
         return ("mismatched character " + this.GetCharErrorDisplay(e.Character) + " expecting set " + this.GetCharErrorDisplay(exception4.A) + ".." + this.GetCharErrorDisplay(exception4.B));
     }
     return base.GetErrorMessage(e, tokenNames);
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:34,代码来源:Lexer.cs


示例4: Convert

		public static QuerySyntaxException Convert(RecognitionException e, string hql)
		{
			string positionInfo = e.Line > 0 && e.CharPositionInLine > 0
			                      	? " near line " + e.Line + ", column " + e.CharPositionInLine
			                      	: "";
			return new QuerySyntaxException(e.Message + positionInfo, hql);
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:7,代码来源:QuerySyntaxException.cs


示例5: ReportError

		public void ReportError(RecognitionException e)
		{
			ReportError( e.ToString() );
			_recognitionExceptions.Add( e );
			if ( log.IsDebugEnabled ) {
				log.Debug( e.ToString(), e );
			}
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:8,代码来源:ErrorCounter.cs


示例6: AutomationErrorNode

 public AutomationErrorNode(ITokenStream input, IToken start, IToken stop, RecognitionException ex)
 {
     var handler = new CommonErrorNode(input, start, stop, ex);
     this.isNil = handler.IsNil;
     this.type = handler.Type;
     this.text = handler.Text;
     this.toString = handler.ToString();
 }
开发者ID:FallenGameR,项目名称:AntlrAutomation,代码行数:8,代码来源:AutomationErrorNode.cs


示例7: DebugRecognitionException

 protected virtual void DebugRecognitionException(RecognitionException ex)
 {
     IDebugEventListener debugListener = this.recognizer.DebugListener;
     if (debugListener != null)
     {
         debugListener.RecognitionException(ex);
     }
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:8,代码来源:DFA.cs


示例8: ReportError

 public override void ReportError(RecognitionException e)
 {
     if ( state.errorRecovery ) {
         return;
     }
     state.syntaxErrors++; // don't count spurious
     state.errorRecovery = true;
     throw e;
 }
开发者ID:fronx,项目名称:ioke,代码行数:9,代码来源:Parser.cs


示例9: AST2JSOMCommonErrorNode

 /**
  * Constructor.
  *
  * @param pInput  Will be passed to the constructor of the wrapped object.
  * @param pStart  Will be passed to the constructor of the wrapped object.
  * @param pStop  Will be passed to the constructor of the wrapped object.
  * @param pException  Will be passed to the constructor of the wrapped
  *                    object.
  *
  * __TEST__
  */
 public AST2JSOMCommonErrorNode(
     ITokenStream pInput, IToken pStart, IToken pStop, 
     RecognitionException pException)
     : base()
 {
     //base();
     mCommonErrorNode =
     new CommonErrorNode(pInput, pStart, pStop, pException);
 }
开发者ID:smartmobili,项目名称:parsing,代码行数:20,代码来源:AST2JSOMCommonErrorNode.cs


示例10: DisplayRecognitionError

        public override void DisplayRecognitionError(string[] tokenNames, RecognitionException e)
        {
            string headerError = GetErrorHeader(e);
            string error = GetErrorMessage(e, tokenNames);

            Errors.Add(new ParseException(new LineInfo(e.Line, e.CharPositionInLine), error));

            base.DisplayRecognitionError(tokenNames, e);
        }
开发者ID:bitsummation,项目名称:pickaxe,代码行数:9,代码来源:AntlrParser.cs


示例11: FormatRecognitionException

 private static string FormatRecognitionException(RecognitionException e, string source)
 {
     var res = "Message: " + e.Message + "\n";
     res += "Token: " + e.Token.Text + "\n";
     res += "Source: " + source + "\n";
     res += "Line: " + e.Line + "\n";
     res += "Char position in line: " + e.CharPositionInLine + "\n";
     return res;
 }
开发者ID:BooMWax,项目名称:ifmo,代码行数:9,代码来源:Translator.cs


示例12: DisplayRecognitionError

        public override void DisplayRecognitionError(string[] tokenNames, RecognitionException e)
        {
            var handler = Error;
              if (handler != null)
              {
            handler(string.Format("{0} {1}", GetErrorHeader(e), GetErrorMessage(e, tokenNames)));
              }

              base.DisplayRecognitionError(tokenNames, e);
        }
开发者ID:aloker,项目名称:ExampleParser,代码行数:10,代码来源:SimpleLanguageTree.ErrorHandling.cs


示例13: SyntaxErrorException

        public SyntaxErrorException(string input, String antlrMessage, RecognitionException exception)
            : base(JSToCSharpExceptionType.SyntaxError, exception)
        {
            AntlrMessage = antlrMessage;
            Input = input;

            var span = AntlrException.Token == null ? -1 : AntlrException.Token.Text.Length;
            var prettyInput = input.InjectErrorMarker(LineNumber, CharPositionInLine, span).InjectLineNumbers1();
            SourceCode = prettyInput;
        }
开发者ID:xeno-by,项目名称:relinq,代码行数:10,代码来源:SyntaxErrorException.cs


示例14: Report

        public static SyntaxErrorException Report(BaseRecognizer source, RecognitionException e)
        {
            var input = source.Input.ToString();
            if (source.Input is ANTLRStringStream)
                input = new String((Char[])typeof(ANTLRStringStream).GetField("data", 
                    BindingFlags.NonPublic | BindingFlags.Instance).GetValue(source.Input));

            var antlrMessage = source.GetErrorHeader(e) + " " + source.GetErrorMessage(e, source.TokenNames);
            throw new SyntaxErrorException(input, antlrMessage, e);
        }
开发者ID:xeno-by,项目名称:elf4b,代码行数:10,代码来源:RecognitionExceptionHelper.cs


示例15: DisplayRecognitionError

		/// <summary>
		/// Logs the given error to the <see cref="ErrorTracker"/>.
		/// </summary>
		/// <param name="tokenNames">The names of the tokens in the current language.</param>
		/// <param name="e">The error.</param>
		public override void DisplayRecognitionError(String[] tokenNames, RecognitionException e)
		{
			LanguageError lerError = new LanguageError();
			lerError.Line = e.Line - 1;
			lerError.Column = e.CharPositionInLine;
			lerError.Position = e.Token.StartIndex;
			lerError.End = e.Token.StopIndex;
			lerError.Message = GetErrorMessage(e, tokenNames);
			ErrorTracker.ParserErrors.Add(lerError);
		}
开发者ID:etinquis,项目名称:nexusmodmanager,代码行数:15,代码来源:AntlrParserBase.cs


示例16: CommonErrorNode

 public CommonErrorNode(ITokenStream input, IToken start, IToken stop, RecognitionException e)
 {
     if ((stop == null) || ((stop.TokenIndex < start.TokenIndex) && (stop.Type != -1)))
     {
         stop = start;
     }
     this.input = input;
     this.start = start;
     this.stop = stop;
     this.trappedException = e;
 }
开发者ID:brunolauze,项目名称:mysql-connector-net-6,代码行数:11,代码来源:CommonErrorNode.cs


示例17: DisplayRecognitionError

        public override void DisplayRecognitionError(String[] tokenNames, RecognitionException e)
        {
            base.DisplayRecognitionError(tokenNames, e);

            if (Errors == null)
                Errors = new List<string>();

            var hdr = GetErrorHeader(e);
            var msg = GetErrorMessage(e, tokenNames);
            Errors.Add(msg + " at " + hdr);
        }
开发者ID:pvginkel,项目名称:Jint2,代码行数:11,代码来源:EcmaScriptParser.cs


示例18: ReportError

 public override void ReportError(RecognitionException e)
 {
     if (e is MissingTokenException)
     {
         errors.Add(string.Format("{0}:{1} - Unexpected {2}\n  {3}", e.Line, e.CharPositionInLine, e.Token.Text, e));
     }
     else
     {
         errors.Add(string.Format("{0}:{1} - Error with token {2}\n  {3}", e.Line, e.CharPositionInLine, e.Token.Text, e.ToString()));
     }
     base.ReportError(e);
 }
开发者ID:hgabor,项目名称:boardgame,代码行数:12,代码来源:BoardGameParser_public.cs


示例19: ReportError

 public override void ReportError( RecognitionException e )
 {
     StringTemplateGroup group = self.Group;
     if ( group == StringTemplate.defaultGroup )
     {
         self.Error( "action parse error; template context is " + self.GetEnclosingInstanceStackString(), e );
     }
     else
     {
         self.Error( "action parse error in group " + self.Group.Name + " line " + self.GroupFileLine + "; template context is " + self.GetEnclosingInstanceStackString(), e );
     }
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:12,代码来源:ActionParserHelper.cs


示例20: CompilerError

        /// <summary>
        /// Creates a <see cref="CompilerError"/> instance with a specific <see cref="Exception"/>.
        /// </summary>
        /// <param name="exception">Compiler exception.</param>
        public CompilerError(RecognitionException exception)
        {
            Token = exception.Token;
            var result = new StringBuilder();
            if (!string.IsNullOrEmpty(FileName))
            {
                result.AppendFormat("{0} ({1},{2}) : ", FileName, Token.Line, Token.CharPositionInLine + 1);
            }

            result.AppendFormat("error S0001 : invalid token {0}", Token.Text);
            Details = result.ToString();
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:16,代码来源:CompilerError.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Runtime.RecognizerSharedState类代码示例发布时间:2022-05-24
下一篇:
C# Runtime.NoViableAltException类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap