From a7575e08c67ab6e4f3c5a48b302c42a17d2500c2 Mon Sep 17 00:00:00 2001 From: martin dobrev Date: Mon, 12 Oct 2020 22:56:16 +0300 Subject: Add support for new lines and tabs in tokenizer. Improve tests verbosity. Replace white spaces with tabs. --- JSImpl/src/main.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'JSImpl/src/main.cpp') diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp index 90f6023..ef5ac1b 100644 --- a/JSImpl/src/main.cpp +++ b/JSImpl/src/main.cpp @@ -15,9 +15,8 @@ void RunParseCalc() { - IPLVector tokens; //Tokenize("var a = 0; var b = a + 123;a+b;", tokens); - Tokenize("var a = 5; if(a == 5){a++;}", tokens); + auto tokens = Tokenize("var a = 5; if(a == 5){a++;}").tokens; // TODO make actual test :D auto expr = Parse(tokens); @@ -60,8 +59,7 @@ void InteractiveInterpreter() i.Print(p); continue; } - IPLVector tokens; - Tokenize(command, tokens); + auto tokens = Tokenize(command).tokens; auto result = i.Run(Parse(tokens).get()); while (!result.empty()) { std::cout << result.back() << std::endl; @@ -72,7 +70,6 @@ void InteractiveInterpreter() void Generate() { - IPLVector tokens; //Tokenize("var a = 0; var b = a + 123;a+b;", tokens); /*Tokenize("var a; if(a < 4) { a = 8; if(a < 7) {var b = 4;}} else { a = 2} ", tokens);*/ IPLString source = "var i = 0; \n" @@ -80,7 +77,7 @@ void Generate() "{\n" " i = i + j;\n" "}"; - Tokenize(source.c_str(), tokens); + auto tokens = Tokenize(source.c_str()).tokens; auto asmb = GenerateByteCode(Parse(tokens), source, ByteCodeGeneratorOptions(ByteCodeGeneratorOptions::OptimizationsType::None, true)); -- cgit v1.3.1-23-gd82d