public void LexemeList() { Lexer lexer = Standard.GetLexer(); LexemeList expected = Standard.GetLexemes(lexer); var lexemes = lexer.Lex(Standard.Text) .ToList(); Assert.IsTrue(expected.Equals(lexemes)); }
public void LexemeListComparison() { LexemeList a = Standard.GetLexemes(); var b = a .Select(l => new Lexeme(l, l.Token, l.MatchedText, l.StartIndex)) .ToList(); Assert.IsTrue(a.Equals(b)); }
public static LexemeList GetLexemes(Lexer lexer = null) { lexer = lexer ?? GetLexer(); Token ident = lexer.GetToken("ident"); Token singleString = lexer.GetToken("singleString"); Token ws = lexer.GetToken("ws"); Token dot = lexer.GetToken("dot"); Token leftParen = lexer.GetToken("leftParen"); Token rightParen = lexer.GetToken("rightParen"); Token equals = lexer.GetToken("equals"); var results = new LexemeList(lexer) { { ws, @" ", 0 }, { ident, "document", 2 }, { dot, ".", 10 }, { ident, "getElementById", 11 }, { leftParen, "(", 25 }, { singleString, "'demo'", 26 }, { rightParen, ")", 32 }, { dot, ".", 33 }, { ident, "innerHTML", 34 }, { ws, " ", 43 }, { equals, "=", 44 }, { ws, " ", 45 }, { ident, "Date", 46 }, { leftParen, "(", 50 }, { rightParen, ")", 51 }, { ws, @" ", 52 }, }; return(results); }