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


C# Lexer.ParseExtend方法代码示例

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


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

示例1: ParseExtend_NOK05

        public void ParseExtend_NOK05()
        {
            const string text = "  extend Foo {";

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

            Assert.IsFalse(lex.ParseExtend());

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

示例2: ParseExtend_NOK04

        public void ParseExtend_NOK04()
        {
            const string text = "  extend Foo x\r\n optional int32 bar = 126;\r\n }";

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

            Assert.IsFalse(lex.ParseExtend());

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

示例3: ParseExtend_OK02

        public void ParseExtend_OK02()
        {
            const string Text = "extend Package1.Foo { \r\n    optional string bar = 100;\r\n }";

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

            Assert.IsTrue(lex.ParseExtend());

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

            Assert.AreEqual(0, lex.Tokens[0].Position);
            Assert.AreEqual(7, lex.Tokens[1].Position);
            Assert.AreEqual(16, lex.Tokens[2].Position);
            Assert.AreEqual(28, lex.Tokens[3].Position);
            Assert.AreEqual(37, lex.Tokens[4].Position);
            Assert.AreEqual(44, lex.Tokens[5].Position);
            Assert.AreEqual(50, lex.Tokens[6].Position);

            Assert.AreEqual(6, lex.Tokens[0].Length);
            Assert.AreEqual(8, lex.Tokens[1].Length);
            Assert.AreEqual(3, lex.Tokens[2].Length);
            Assert.AreEqual(8, lex.Tokens[3].Length);
            Assert.AreEqual(6, lex.Tokens[4].Length);
            Assert.AreEqual(3, lex.Tokens[5].Length);
            Assert.AreEqual(3, lex.Tokens[6].Length);

            Assert.AreEqual(CodeType.TopLevelCmd, lex.Tokens[0].CodeType);
            Assert.AreEqual(CodeType.SymRef, lex.Tokens[1].CodeType);
            Assert.AreEqual(CodeType.SymRef, lex.Tokens[2].CodeType);
            Assert.AreEqual(CodeType.FieldRule, lex.Tokens[3].CodeType);
            Assert.AreEqual(CodeType.Keyword, lex.Tokens[4].CodeType);
            Assert.AreEqual(CodeType.SymDef, lex.Tokens[5].CodeType);
            Assert.AreEqual(CodeType.Number, lex.Tokens[6].CodeType);
        }
开发者ID:mreu,项目名称:ProtobufLanguageService,代码行数:36,代码来源:ParseExtendTests.cs

示例4: ParseExtend_OK01

        public void ParseExtend_OK01()
        {
            const string Text = "  extend Foo {\r\n optional int32 bar = 126;\r\n }";

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

            Assert.IsTrue(lex.ParseExtend());

            Assert.AreEqual(6, lex.Tokens.Count);
            Assert.AreEqual(0, lex.Errors.Count);
            Assert.AreEqual(12, lex.Index);

            Assert.AreEqual(2, lex.Tokens[0].Position);
            Assert.AreEqual(9, lex.Tokens[1].Position);
            Assert.AreEqual(17, lex.Tokens[2].Position);
            Assert.AreEqual(26, lex.Tokens[3].Position);
            Assert.AreEqual(32, lex.Tokens[4].Position);
            Assert.AreEqual(38, lex.Tokens[5].Position);

            Assert.AreEqual(6, lex.Tokens[0].Length);
            Assert.AreEqual(3, lex.Tokens[1].Length);
            Assert.AreEqual(8, lex.Tokens[2].Length);
            Assert.AreEqual(5, lex.Tokens[3].Length);
            Assert.AreEqual(3, lex.Tokens[4].Length);
            Assert.AreEqual(3, lex.Tokens[5].Length);

            Assert.AreEqual(CodeType.TopLevelCmd, lex.Tokens[0].CodeType);
            Assert.AreEqual(CodeType.SymRef, 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);
        }
开发者ID:mreu,项目名称:ProtobufLanguageService,代码行数:33,代码来源:ParseExtendTests.cs


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