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


C# ParsingContext.CreateErrorToken方法代码示例

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


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

示例1: MatchQuoted

        private Token MatchQuoted(ParsingContext context, ISourceStream source)
        {
            char quoteChar = source.PreviewChar;
            if ((quoteChar != '\'') && (quoteChar != '"'))
            {
                return null;
            }

            source.PreviewPosition++;
            while (!source.EOF())
            {
                if (source.PreviewChar == quoteChar)
                {
                    source.PreviewPosition++;
                    return source.CreateToken(this.OutputTerminal);
                }

                // Escaped?
                if (source.PreviewChar == '\\')
                {
                    // Consume next
                    ++source.PreviewPosition;
                }

                source.PreviewPosition++;
            }

            return context.CreateErrorToken("Unbalanced quoted string");
        }
开发者ID:tmatz,项目名称:XamlStyler,代码行数:29,代码来源:MemberNameOrStringTerminal.cs

示例2: 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 
            {
                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 context.CreateErrorToken("unclosed comment");
        }
开发者ID:peterdocter,项目名称:BabeLua,代码行数:25,代码来源:LuaBlockCommentTerminal.cs

示例3: TryMatch

        public override Token TryMatch(ParsingContext context, ISourceStream source)
        {
            while (!source.EOF())
            {
                switch (source.PreviewChar)
                {
                    case '\n':
                    case '\r':
                    case ' ':
                    case '}':
                        if (source.PreviewPosition > source.Position)
                            return source.CreateToken(this.OutputTerminal);
                        return context.CreateErrorToken(Name + " was expected");
                }
                source.PreviewPosition++;
            }

            return context.CreateErrorToken("Unbalanced " + Name);
        }
开发者ID:NicoVermeir,项目名称:XamlStyler,代码行数:19,代码来源:TypeNameTerminal.cs

示例4: 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 context.CreateErrorToken(ex.Message);
   }
 }//method
开发者ID:kayateia,项目名称:climoo,代码行数:11,代码来源:DataLiteralBase.cs

示例5: 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 context.CreateErrorToken(Resources.ErrUnclosedComment);
 }
开发者ID:kayateia,项目名称:climoo,代码行数:18,代码来源:CommentTerminal.cs

示例6: 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 context.CreateErrorToken(Resources.ErrNewLineExpected);
    }
开发者ID:ArsenShnurkov,项目名称:Irony-GtkSharpExplorer,代码行数:19,代码来源:LineContinuationTerminal.cs

示例7: TryMatchContentSimple

 private Token TryMatchContentSimple(ParsingContext context, ISourceStream source) {
   var startPos = source.PreviewPosition;
   var termLen = _singleTerminator.Length;
   var stringComp = Grammar.CaseSensitive ? StringComparison.InvariantCulture : StringComparison.InvariantCultureIgnoreCase;
   int termPos = source.Text.IndexOf(_singleTerminator, startPos, stringComp);
   if (termPos < 0 && IsSet(FreeTextOptions.AllowEof))
     termPos = source.Text.Length;
   if (termPos < 0)
     return context.CreateErrorToken(Resources.ErrFreeTextNoEndTag, _singleTerminator);
   var textEnd = termPos;
   if (IsSet(FreeTextOptions.IncludeTerminator))
     textEnd += termLen;
   var tokenText = source.Text.Substring(startPos, textEnd - startPos);
   if (string.IsNullOrEmpty(tokenText) && (this.FreeTextOptions & Parsing.FreeTextOptions.AllowEmpty) == 0)
     return null; 
   // The following line is a fix submitted by user rmcase
   source.PreviewPosition = IsSet(FreeTextOptions.ConsumeTerminator) ? termPos + termLen : termPos; 
   return source.CreateToken(this.OutputTerminal, tokenText); 
 }
开发者ID:androdev4u,项目名称:XLParser,代码行数:19,代码来源:FreeTextLiteral.cs

示例8: MatchUnquoted

        private Token MatchUnquoted(ParsingContext context, ISourceStream source)
        {
            if (source.PreviewChar == '{')
            {
                // Member names can't start with {
                if (this.IsMemberName)
                {
                    return null;
                }

                // Check for special {} at start of token indicating that this is a STRING token.
                if (source.NextPreviewChar != '}')
                {
                    return null;
                }

                source.PreviewPosition += 2;
            }

            var runningBraceTotal = 0;

            // This variable tracks the position of the last non whitespace (or significant whitespace).
            var lastNonWhitespacePosition = source.PreviewPosition;
            while (!source.EOF())
            {
                bool isWhiteSpace = false;
                switch (source.PreviewChar)
                {
                    case '{':
                        runningBraceTotal++;
                        break;

                    case '}':
                        if (--runningBraceTotal < 0)
                        {
                            return this.CreateToken(source, lastNonWhitespacePosition);
                        }

                        break;

                    case ',':
                        if (runningBraceTotal == 0)
                        {
                            return this.CreateToken(source, lastNonWhitespacePosition);
                        }

                        break;

                    case '=':
                        if (runningBraceTotal == 0)
                        {
                            // Equal sign. Only allowed after MemberNames.
                            return this.IsMemberName
                                ? this.CreateToken(source, lastNonWhitespacePosition)
                                : null;
                        }

                        break;

                    case '\\':
                        source.PreviewPosition++;
                        break;

                    default:
                        isWhiteSpace = Char.IsWhiteSpace(source.PreviewChar);
                        break;
                }

                source.PreviewPosition++;

                if (!isWhiteSpace)
                {
                    lastNonWhitespacePosition = source.PreviewPosition;
                }
            }

            return context.CreateErrorToken("Unterminated string terminal");
        }
开发者ID:tmatz,项目名称:XamlStyler,代码行数:78,代码来源:MemberNameOrStringTerminal.cs


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