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


C# Runtime.RecognitionException类代码示例

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


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


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