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


C# Lexer.ParseMessage方法代码示例

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


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

示例1: ParseMessage_NOK05

        public void ParseMessage_NOK05()
        {
            const string text = "  message SearchResponse x\r\n  required string url = 2;\r\n  optional string title = 3;\r\n  repeated string snippets = 4;";

              var lex = new Lexer(text) { Matches = Helper.SplitText(text) };

              Assert.IsFalse(lex.ParseMessage(false));

              Assert.AreEqual(2, lex.Tokens.Count);
              Assert.AreEqual(1, lex.Errors.Count);
              Assert.AreEqual(2, lex.Index);
        }
开发者ID:TruDan,项目名称:ProtobufLanguageService,代码行数:12,代码来源:ParseMessageTest.cs

示例2: ParseMessage_NOK04

        public void ParseMessage_NOK04()
        {
            const string text = "  message SearchResponse";

              var lex = new Lexer(text) { Matches = Helper.SplitText(text) };

              Assert.IsFalse(lex.ParseMessage(false));

              Assert.AreEqual(2, lex.Tokens.Count);
              Assert.AreEqual(1, lex.Errors.Count);
              Assert.AreEqual(2, lex.Index);
        }
开发者ID:TruDan,项目名称:ProtobufLanguageService,代码行数:12,代码来源:ParseMessageTest.cs

示例3: ParseMessage_OK03

        public void ParseMessage_OK03()
        {
            const string text = "  message SearchResponse {}";

              var lex = new Lexer(text) { Matches = Helper.SplitText(text) };

              Assert.IsTrue(lex.ParseMessage(true));

              Assert.AreEqual(2, lex.Tokens.Count);
              Assert.AreEqual(0, lex.Errors.Count);
              Assert.AreEqual(4, lex.Index);
        }
开发者ID:TruDan,项目名称:ProtobufLanguageService,代码行数:12,代码来源:ParseMessageTest.cs

示例4: ParseMessage_OK09

        public void ParseMessage_OK09()
        {
            const string text = "  message SearchResponse {\r\n message msg {  optional int32 t1 = 1;} \r\n required string url = 2;\r\n  optional string title = 3;\r\n  repeated string snippets = 4;\r\n};";

            var lex = new Lexer(text) { Matches = Helper.SplitText(text) };

            Assert.IsTrue(lex.ParseMessage(true));

            Assert.AreEqual(20, lex.Tokens.Count);
            Assert.AreEqual(0, lex.Errors.Count);
            Assert.AreEqual(38, lex.Index);
        }
开发者ID:TruDan,项目名称:ProtobufLanguageService,代码行数:12,代码来源:ParseMessageTest.cs

示例5: ParseMessage_OK02

        public void ParseMessage_OK02()
        {
            const string text = "  message SearchResponse {\r\n  required string url = 2;\r\n \r\n  optional string title = 3;\r\n  repeated string snippets = 4;\r\n}";

              var lex = new Lexer(text) { Matches = Helper.SplitText(text) };

              Assert.IsTrue(lex.ParseMessage(true));

              Assert.AreEqual(14, lex.Tokens.Count);
              Assert.AreEqual(0, lex.Errors.Count);
              Assert.AreEqual(27, lex.Index);

              Assert.AreEqual(2, lex.Tokens[0].Position);
              Assert.AreEqual(10, lex.Tokens[1].Position);
              Assert.AreEqual(30, lex.Tokens[2].Position);
              Assert.AreEqual(39, lex.Tokens[3].Position);
              Assert.AreEqual(46, lex.Tokens[4].Position);
              Assert.AreEqual(52, lex.Tokens[5].Position);
              Assert.AreEqual(61, lex.Tokens[6].Position);
              Assert.AreEqual(70, lex.Tokens[7].Position);
              Assert.AreEqual(77, lex.Tokens[8].Position);
              Assert.AreEqual(85, lex.Tokens[9].Position);
              Assert.AreEqual(91, lex.Tokens[10].Position);
              Assert.AreEqual(100, lex.Tokens[11].Position);
              Assert.AreEqual(107, lex.Tokens[12].Position);
              Assert.AreEqual(118, lex.Tokens[13].Position);

              Assert.AreEqual(7, lex.Tokens[0].Length);
              Assert.AreEqual(14, lex.Tokens[1].Length);
              Assert.AreEqual(8, lex.Tokens[2].Length);
              Assert.AreEqual(6, lex.Tokens[3].Length);
              Assert.AreEqual(3, lex.Tokens[4].Length);
              Assert.AreEqual(1, lex.Tokens[5].Length);
              Assert.AreEqual(8, lex.Tokens[6].Length);
              Assert.AreEqual(6, lex.Tokens[7].Length);
              Assert.AreEqual(5, lex.Tokens[8].Length);
              Assert.AreEqual(1, lex.Tokens[9].Length);
              Assert.AreEqual(8, lex.Tokens[10].Length);
              Assert.AreEqual(6, lex.Tokens[11].Length);
              Assert.AreEqual(8, lex.Tokens[12].Length);
              Assert.AreEqual(1, lex.Tokens[13].Length);

              Assert.AreEqual(CodeType.TopLevelCmd, lex.Tokens[0].CodeType);
              Assert.AreEqual(CodeType.SymDef, lex.Tokens[1].CodeType);
              Assert.AreEqual(CodeType.FieldRule, lex.Tokens[2].CodeType);
              Assert.AreEqual(CodeType.Keyword, lex.Tokens[3].CodeType);
              Assert.AreEqual(CodeType.SymDef, lex.Tokens[4].CodeType);
              Assert.AreEqual(CodeType.Number, lex.Tokens[5].CodeType);
              Assert.AreEqual(CodeType.FieldRule, lex.Tokens[6].CodeType);
              Assert.AreEqual(CodeType.Keyword, lex.Tokens[7].CodeType);
              Assert.AreEqual(CodeType.SymDef, lex.Tokens[8].CodeType);
              Assert.AreEqual(CodeType.Number, lex.Tokens[9].CodeType);
              Assert.AreEqual(CodeType.FieldRule, lex.Tokens[10].CodeType);
              Assert.AreEqual(CodeType.Keyword, lex.Tokens[11].CodeType);
              Assert.AreEqual(CodeType.SymDef, lex.Tokens[12].CodeType);
              Assert.AreEqual(CodeType.Number, lex.Tokens[13].CodeType);
        }
开发者ID:TruDan,项目名称:ProtobufLanguageService,代码行数:57,代码来源:ParseMessageTest.cs


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