From 549da681566383f3eb1661fd2f0e60cf28a17323 Mon Sep 17 00:00:00 2001 From: dvtate Date: Mon, 20 Jun 2022 17:14:34 -0500 Subject: [PATCH] minifier fix --- compile/tree_to_source.cpp | 10 +++++++--- examples/conway.s | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/compile/tree_to_source.cpp b/compile/tree_to_source.cpp index c7a4074..e8bcd7a 100644 --- a/compile/tree_to_source.cpp +++ b/compile/tree_to_source.cpp @@ -44,7 +44,7 @@ static inline std::string src_operator(AST& tree) { static inline std::string src_statements(AST& tree) { std::string ret; for (auto& m : tree.members) - ret += tree_to_source(*m) + ";"; + ret += tree_to_source(*m) + " "; return ret; } @@ -86,8 +86,12 @@ std::string tree_to_source(AST& tree) { case AST::NodeType::KV_PAIR: return tree_to_source(*tree.members[0]) + ":" + tree_to_source(*tree.members[1]); - case AST::NodeType::DECLARATION: - return "let " + tree_to_source(*tree.members[0]); + case AST::NodeType::DECLARATION: { + std::string ret = "let " + tree_to_source(*tree.members[0]); + for (size_t i = 1; i < tree.members.size(); i++) + ret += "," + tree_to_source(*tree.members[i]); + return ret; + } case AST::NodeType::STATEMENTS: return src_statements(tree); case AST::NodeType::INVOKE: diff --git a/examples/conway.s b/examples/conway.s index 660b922..4dd2065 100644 --- a/examples/conway.s +++ b/examples/conway.s @@ -1,4 +1,4 @@ -let time = import('libtime.so'); +let time = import('libtime.so') // Useful stuff let while = (: @@ -89,8 +89,8 @@ let update_world = (: // main loop while ((: true ), (: - print_world() - update_world() - time.delay(0.04) + print_world() + update_world() + time.delay(0.04) ))