本文整理汇总了C#中Lexer.Lexer.Scan方法的典型用法代码示例。如果您正苦于以下问题:C# Lexer.Scan方法的具体用法?C# Lexer.Scan怎么用?C# Lexer.Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer.Lexer
的用法示例。
在下文中一共展示了Lexer.Scan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestScanComment
public void TestScanComment()
{
var lex = new Lexer.Lexer();
var reader = new StringReader( "// Comment\n" );
var t = lex.Scan( reader );
Assert.AreEqual( typeof (Comment), t.GetType() );
Assert.AreEqual( " Comment", ( (Comment) t ).Value );
}
示例2: TestScanFloatNum
public void TestScanFloatNum()
{
var lex = new Lexer.Lexer();
var reader = new StringReader( "2. 3.14 .5" );
var t = lex.Scan( reader );
Assert.AreEqual( typeof (Float), t.GetType() );
Assert.AreEqual( 2.0, ( (Float) t ).Value );
t = lex.Scan( reader );
Assert.AreEqual( typeof (Float), t.GetType() );
Assert.AreEqual( 3.14, ( (Float) t ).Value );
t = lex.Scan( reader );
Assert.AreEqual( typeof (Float), t.GetType() );
Assert.AreEqual( 0.5, ( (Float) t ).Value );
}
示例3: TestScanCompare
public void TestScanCompare()
{
var lex = new Lexer.Lexer();
var reader = new StringReader( " < <= == != >= >" );
var t = lex.Scan( reader );
Assert.AreEqual( typeof( Word), t.GetType() );
Assert.AreEqual( Tag.Less, t.Tag );
t = lex.Scan( reader );
Assert.AreEqual( typeof( Word ), t.GetType() );
Assert.AreEqual( Tag.LessOrEqual, t.Tag );
t = lex.Scan( reader );
Assert.AreEqual( typeof( Word ), t.GetType() );
Assert.AreEqual( Tag.Equal, t.Tag );
t = lex.Scan( reader );
Assert.AreEqual( typeof( Word ), t.GetType() );
Assert.AreEqual( Tag.NotEqual, t.Tag );
t = lex.Scan( reader );
Assert.AreEqual( typeof( Word ), t.GetType() );
Assert.AreEqual( Tag.BetterOrEqual, t.Tag );
t = lex.Scan( reader );
Assert.AreEqual( typeof( Word ), t.GetType() );
Assert.AreEqual( Tag.Better, t.Tag );
}
示例4: TestScanMultilineComment
public void TestScanMultilineComment()
{
const string textComment = "Comment line 1\n" +
"Comment line 2\n" +
"Comment line *";
var lex = new Lexer.Lexer();
var reader = new StringReader( "/*" + textComment + "*/" );
var t = lex.Scan( reader );
Assert.AreEqual( typeof( Comment ), t.GetType() );
Assert.AreEqual( textComment, ( (Comment)t ).Value );
}
示例5: TestScanWord
public void TestScanWord()
{
var lex = new Lexer.Lexer();
var reader = new StringReader( "abc2" );
var t = lex.Scan( reader );
Assert.AreEqual( typeof( Word ), t.GetType() );
Assert.AreEqual( "abc2", ( (Word)t ).Lexeme );
}
示例6: TestScanNum
public void TestScanNum()
{
var lex = new Lexer.Lexer();
var reader = new StringReader( "1234567890" );
var t = lex.Scan( reader );
Assert.AreEqual( typeof (Num), t.GetType() );
Assert.AreEqual( 1234567890, ( (Num) t ).Value );
}