shitshow

A shitty programming language
git clone git://git.bain.cz/shitshow.git
Log | Files | Refs

commit f3db7a7e88f9e2973f93d4879bb3ba3e841638a6
parent db3d5927fbad73975e5ec4e03a8d1a44fa69f61d
Author: bain3 <31798786+bain3@users.noreply.github.com>
Date:   Sat,  1 May 2021 16:34:23 +0200

changes

Diffstat:
Mmain.cpp | 2+-
Mparser/parser.cpp | 9+++++----
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/main.cpp b/main.cpp @@ -42,7 +42,7 @@ void print_statement(const std::unique_ptr<parser::elements::Statement> &stateme switch (e->type) { case parser::BLOCK: { auto *block = (elements::Block *)e.get(); - print_block(block, deep+4); + print_block(block, deep); break; } case parser::DECLARATION: { diff --git a/parser/parser.cpp b/parser/parser.cpp @@ -61,18 +61,17 @@ parser::elements::Block *parser::parse_block(const std::vector<lexer::Token> &to } case lexer::LEFT_BRACKET: { brackets++; - block->children.push_back(std::unique_ptr<elements::Statement>(parse_statement(statement_tokens))); - statement_tokens.clear(); statement_tokens.push_back(token); break; } case lexer::RIGHT_BRACKET: - if (brackets) { + if (brackets == 1) { block->children.push_back(std::unique_ptr<elements::Statement>(parse_statement(statement_tokens))); statement_tokens.clear(); - } else { + } else if (!brackets) { consumed = token_stream.size(); } + brackets--; break; default: statement_tokens.push_back(token); @@ -152,6 +151,8 @@ parser::elements::Statement *parser::parse_statement(const std::vector<lexer::To } std::unique_ptr<elements::Expression> expr(parse_expression(token_stream, consumed + 2, closing_pos)); parser_element = (elements::ParserElement *) new elements::If{.expression = std::move(expr)}; + consumed = closing_pos+1; + stop = false; // we want the block that is following (or command) break; } case lexer::LEFT_BRACKET: {