本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}