本文整理汇总了C#中Lexer.Lexer.ParsePackage方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.ParsePackage方法的具体用法?C# Lexer.ParsePackage怎么用?C# Lexer.ParsePackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer.Lexer
的用法示例。
在下文中一共展示了Lexer.ParsePackage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Package_NOK03
public void Package_NOK03()
{
const string text = " package"; // still not finished line
var lex = new Lexer(text) { Matches = Helper.SplitText(text) };
lex.ParsePackage();
Assert.AreEqual(1, lex.Tokens.Count);
Assert.AreEqual(4, lex.Tokens[0].Position);
Assert.AreEqual(7, lex.Tokens[0].Length);
Assert.AreEqual(CodeType.TopLevelCmd, lex.Tokens[0].CodeType);
Assert.AreEqual(0, lex.Line);
Assert.AreEqual(1, lex.Errors.Count);
Assert.AreEqual(11, lex.Errors[0].Position);
Assert.AreEqual(1, lex.Errors[0].Length);
Assert.AreEqual(0, lex.Line);
}
示例2: Package_NOK02
public void Package_NOK02()
{
const string text = " package Teäst1.kjhkj.jjjj;";
var lex = new Lexer(text) { Matches = Helper.SplitText(text) };
lex.ParsePackage();
Assert.AreEqual(4, lex.Tokens.Count);
Assert.AreEqual(4, lex.Tokens[0].Position);
Assert.AreEqual(7, lex.Tokens[0].Length);
Assert.AreEqual(CodeType.TopLevelCmd, lex.Tokens[0].CodeType);
Assert.AreEqual(0, lex.Line);
Assert.AreEqual(1, lex.Errors.Count);
Assert.AreEqual(12, lex.Errors[0].Position);
Assert.AreEqual(6, lex.Errors[0].Length);
Assert.AreEqual(0, lex.Line);
}
示例3: Package_NOK04
public void Package_NOK04()
{
const string text = " package dfs"; // still not finished line
var lex = new Lexer(text) { Matches = Helper.SplitText(text) };
lex.ParsePackage();
Assert.AreEqual(2, lex.Tokens.Count);
Assert.AreEqual(12, lex.Tokens[1].Position);
Assert.AreEqual(3, lex.Tokens[1].Length);
Assert.AreEqual(CodeType.Namespace, lex.Tokens[1].CodeType);
Assert.AreEqual(0, lex.Line);
Assert.AreEqual(1, lex.Errors.Count);
Assert.AreEqual(15, lex.Errors[0].Position);
Assert.AreEqual(1, lex.Errors[0].Length);
Assert.AreEqual(0, lex.Line);
}
示例4: Package_OK2
public void Package_OK2()
{
const string text = " package Test1.Test2.Test3;";
var lex = new Lexer(text) { Matches = Helper.SplitText(text) };
lex.ParsePackage();
Assert.AreEqual(4, lex.Tokens.Count);
Assert.AreEqual(4, lex.Tokens[0].Position);
Assert.AreEqual(7, lex.Tokens[0].Length);
Assert.AreEqual(CodeType.TopLevelCmd, lex.Tokens[0].CodeType);
Assert.AreEqual(0, lex.Line);
Assert.AreEqual(12, lex.Tokens[1].Position);
Assert.AreEqual(5, lex.Tokens[1].Length);
Assert.AreEqual(CodeType.Namespace, lex.Tokens[1].CodeType);
Assert.AreEqual(0, lex.Line);
Assert.AreEqual(18, lex.Tokens[2].Position);
Assert.AreEqual(5, lex.Tokens[2].Length);
Assert.AreEqual(CodeType.Namespace, lex.Tokens[2].CodeType);
Assert.AreEqual(0, lex.Line);
Assert.AreEqual(24, lex.Tokens[3].Position);
Assert.AreEqual(5, lex.Tokens[3].Length);
Assert.AreEqual(CodeType.Namespace, lex.Tokens[3].CodeType);
Assert.AreEqual(0, lex.Line);
}
示例5: Package_NOK08
public void Package_NOK08()
{
const string text = " package dfs.abc;";
var lex = new Lexer(text) { Matches = Helper.SplitText(text), HasPackage = true };
lex.ParsePackage();
Assert.AreEqual(3, lex.Tokens.Count);
Assert.AreEqual(16, lex.Tokens[2].Position);
Assert.AreEqual(3, lex.Tokens[2].Length);
Assert.AreEqual(CodeType.Namespace, lex.Tokens[2].CodeType);
Assert.AreEqual(0, lex.Line);
Assert.AreEqual(1, lex.Errors.Count);
Assert.AreEqual(4, lex.Errors[0].Position);
Assert.AreEqual(7, lex.Errors[0].Length);
Assert.AreEqual(0, lex.Line);
}