diff options
| Commit | 00fedcbc8839be26b6738613d88b9d6883eaa7a0 (patch) | |
|---|---|---|
| Author | 2018-09-05 09:30:12 +0300 | |
| Committer | 2018-09-05 09:30:12 +0300 | |
| Files | 51c0df374475edbc620be2a60fc7f16951cf9432 /JSImpl/src/main.cpp | |
| IPL-00fedcbc8839be26b6738613d88b9d6883eaa7a0.tar IPL-00fedcbc8839be26b6738613d88b9d6883eaa7a0.tar.gz IPL-00fedcbc8839be26b6738613d88b9d6883eaa7a0.zip | ||
| Parent | 4e9b86ab9b8d2f780e2e966d5f99b0dd8ba16fa1 (diff) | |
Create solution for sample vm implementation.
Implement basic Lexer.
1 files changed, 63 insertions, 0 deletions
| -rw-r--r-- | JSImpl/src/main.cpp | 63 |
diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp new file mode 100644 index 0000000..8452e72 --- /dev/null +++ b/JSImpl/src/main.cpp @@ -0,0 +1,63 @@ +#include "Lexer.h" +#include <iostream> +#define LOG(msg) std::cout << msg << std::endl +void TestLess() +{ + auto tokens = Tokenize("<"); + if (tokens.size() == 2 && tokens[0].Type == TokenType::Less) + { + LOG("PASS"); + } + else + { + LOG("FAIL"); + } +} + +void TestNumber() +{ + auto tokens = Tokenize("213434.24"); + if (tokens.size() == 2 && tokens[0].Type == TokenType::Number && tokens[0].Number == 213434.24) + { + LOG("PASS"); + } + else + { + LOG("FAIL"); + } +} + +void TestString() +{ + auto tokens = Tokenize("\"alabala\""); + if (tokens.size() == 2 && tokens[0].Type == TokenType::String && tokens[0].Lexeme == "\"alabala\"") + { + LOG("PASS"); + } + else + { + LOG("FAIL"); + } +} + +void TestKeyWord() +{ + auto tokens = Tokenize("for"); + if (tokens.size() == 2 && tokens[0].Type == TokenType::For) + { + LOG("PASS"); + } + else + { + LOG("FAIL"); + } +} + +int main() +{ + TestLess(); + TestNumber(); + TestString(); + TestKeyWord(); + return 0; +}
\ No newline at end of file |
