From 532a594a0efac2e7624e1c9ddce8fb6d81dace4f Mon Sep 17 00:00:00 2001 From: martin dobrev Date: Wed, 14 Nov 2018 09:33:50 +0200 Subject: Implement if --- JSImpl/src/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'JSImpl/src/main.cpp') diff --git a/JSImpl/src/main.cpp b/JSImpl/src/main.cpp index a10e4d1..b2fb83d 100644 --- a/JSImpl/src/main.cpp +++ b/JSImpl/src/main.cpp @@ -2,6 +2,7 @@ #include "Parser.h" #include "ASTPrinter.h" #include "ASTInterpreter.h" +#include "ByteCodeGenerator.h" #include #include @@ -62,11 +63,20 @@ void InteractiveInterpreter() } while (true); } +void Generate() +{ + IPLVector tokens; + //Tokenize("var a = 0; var b = a + 123;a+b;", tokens); + Tokenize("var a; if(a < 4) { a = 8;} else { a = 2} ", tokens); + + std::cout << GenerateByteCode(Parse(tokens)); +} + int main() { //RunParseCalc(); - InteractiveInterpreter(); - + //InteractiveInterpreter(); + Generate(); #if defined(_WIN32) std::system("pause"); #endif -- cgit v1.3.1-23-gd82d