diff --git a/examples/brainfuck/generator.cpp b/examples/brainfuck/generator.cpp index acbaf45..82d3200 100644 --- a/examples/brainfuck/generator.cpp +++ b/examples/brainfuck/generator.cpp @@ -35,7 +35,7 @@ void Generator::run() { while (!lbrackets.empty()) lbrackets.pop(); - for(int instruct = 0; instruct < program.size(); instruct++) { + for (std::size_t instruct = 0; instruct < program.size(); instruct++) { switch(program[instruct]) { case Instruction::EMPTY: break; diff --git a/examples/brainfuck/parser.cpp b/examples/brainfuck/parser.cpp index 15ed2fd..1d4f243 100644 --- a/examples/brainfuck/parser.cpp +++ b/examples/brainfuck/parser.cpp @@ -79,6 +79,8 @@ Parser::Token Parser::lex() { //std::cout << "PARSING: found RBRACKET" << (int)Instruction::RBRACKET << std::endl; return Token{ bfParser_Symbol::T_RBRACKET, std::move(p) }; } + default: + return Token { bfParser_Symbol::T_EOF, nullptr }; } } catch(BfLexer::NoMoreTokens) { return Token{ bfParser_Symbol::T_EOF, nullptr }; @@ -87,15 +89,13 @@ Parser::Token Parser::lex() { std::unique_ptr> Parser::reduce_PROGRAM(std::deque subparts) { // ::= - if (subparts[1].value == nullptr) - return std::move(subparts[0].value); for(auto& instr : *(subparts[1].value)) subparts[0].value->push_back(instr); return std::move(subparts[0].value); } -std::unique_ptr> Parser::reduce_EMPTY(std::deque subparts) { +std::unique_ptr> Parser::reduce_EMPTY(std::deque) { // ::= - return nullptr; + return std::make_unique>(); } std::unique_ptr> Parser::reduce_OPERATION(std::deque subparts) { // ::= "PLUS" | "MINUS" | ... | "COMMA" diff --git a/test_data/bf004.exp b/test_data/bf004.exp index c57eff5..980a0d5 100644 --- a/test_data/bf004.exp +++ b/test_data/bf004.exp @@ -1 +1 @@ -Hello World! \ No newline at end of file +Hello World!