diff --git a/src/ast/statements.hpp b/src/ast/statements.hpp index 1197760..eccaff6 100644 --- a/src/ast/statements.hpp +++ b/src/ast/statements.hpp @@ -49,10 +49,11 @@ struct Return : Stmt std::string dump(int indent = 0) const override { std::ostringstream oss; - oss << indent_str(indent) << "Return\n"; + oss << indent_str(indent) << "Return"; if (value) { - oss << value->dump(indent + 1); + oss << "\n" + << value->dump(indent + 1); } return oss.str(); } diff --git a/src/parser.y b/src/parser.y index df091f1..8ff40ec 100644 --- a/src/parser.y +++ b/src/parser.y @@ -94,9 +94,18 @@ stmt: | KW_RETURN expr NEWLINE { $$ = std::make_unique(std::move($2)); } + | KW_RETURN NEWLINE { + $$ = std::make_unique(nullptr); + } + | KW_PASS NEWLINE { + $$ = std::make_unique(); + } | KW_WHILE expr COLON NEWLINE INDENT stmt_list DEDENT { $$ = std::make_unique(std::move($2), std::move($6)); } + | KW_CLASS IDENTIFIER COLON NEWLINE INDENT stmt_list DEDENT { + $$ = std::make_unique(std::move($2), std::move($6)); + } ; expr: diff --git a/test/parser/26.out b/test/parser/26.out index 2a419c2..5879f05 100644 --- a/test/parser/26.out +++ b/test/parser/26.out @@ -5,5 +5,4 @@ Module Identifier(x) Return Identifier(x) - Return - + Return \ No newline at end of file diff --git a/test/parser/27.out b/test/parser/27.out index 9c97d9b..b984a41 100644 --- a/test/parser/27.out +++ b/test/parser/27.out @@ -1,4 +1,3 @@ Module ClassDef(A) - Pass - + Pass \ No newline at end of file