Add Position struct to track text positions
This commit is contained in:
1 parent
80ac6c17f0
commit
1c50d37a3e
2 files changed
+38
-28
No files matched your search
+9
-9
@@ -47,23 +47,23 @@ unittest
|
||||
string input = "5 + 4 * \n677 + 567";
|
||||
Testparser.Lexer lexer = new Testparser.Lexer(input);
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(0, 0, 1, Testparser.TOKEN_int));
|
||||
assert(token_info == TokenInfo(Testparser.Position(0, 0), 1, Testparser.TOKEN_int));
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(0, 2, 1, Testparser.TOKEN_plus));
|
||||
assert(token_info == TokenInfo(Testparser.Position(0, 2), 1, Testparser.TOKEN_plus));
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(0, 4, 1, Testparser.TOKEN_int));
|
||||
assert(token_info == TokenInfo(Testparser.Position(0, 4), 1, Testparser.TOKEN_int));
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(0, 6, 1, Testparser.TOKEN_times));
|
||||
assert(token_info == TokenInfo(Testparser.Position(0, 6), 1, Testparser.TOKEN_times));
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(1, 0, 3, Testparser.TOKEN_int));
|
||||
assert(token_info == TokenInfo(Testparser.Position(1, 0), 3, Testparser.TOKEN_int));
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(1, 4, 1, Testparser.TOKEN_plus));
|
||||
assert(token_info == TokenInfo(Testparser.Position(1, 4), 1, Testparser.TOKEN_plus));
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(1, 6, 3, Testparser.TOKEN_int));
|
||||
assert(token_info == TokenInfo(Testparser.Position(1, 6), 3, Testparser.TOKEN_int));
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(1, 9, 0, Testparser.TOKEN___EOF));
|
||||
assert(token_info == TokenInfo(Testparser.Position(1, 9), 0, Testparser.TOKEN___EOF));
|
||||
|
||||
lexer = new Testparser.Lexer("");
|
||||
assert(lexer.lex_token(&token_info) == Testparser.P_TOKEN);
|
||||
assert(token_info == TokenInfo(0, 0, 0, Testparser.TOKEN___EOF));
|
||||
assert(token_info == TokenInfo(Testparser.Position(0, 0), 0, Testparser.TOKEN___EOF));
|
||||
}
|
||||
Reference in new issue
Block a user