Break and continue weren't all the way implemented

This commit is contained in:
Nathan Braswell
2018-10-02 00:07:02 -04:00
parent 7993d1d980
commit 3d8be84472
2 changed files with 4 additions and 7 deletions

5
k.krak
View File

@@ -825,6 +825,10 @@ fun syntax_to_ast(file_name: str, syntax: *tree<symbol>, import_paths: ref vec<s
return _return(syntax->children.map(syntax_to_ast_helper)) return _return(syntax->children.map(syntax_to_ast_helper))
else if (syntax->data.name == "defer_statement") else if (syntax->data.name == "defer_statement")
return _defer(syntax->children.map(syntax_to_ast_helper)) return _defer(syntax->children.map(syntax_to_ast_helper))
else if (syntax->data.name == "break_statement")
return _break()
else if (syntax->data.name == "continue_statement")
return _continue()
else if (syntax->data.name == "match_statement") { else if (syntax->data.name == "match_statement") {
return _match(vec(syntax_to_ast_helper(get_node("boolean_expression", syntax))) + return _match(vec(syntax_to_ast_helper(get_node("boolean_expression", syntax))) +
get_nodes("case_statement", syntax).map(fun(s: *tree<symbol>): *tree<ast> { get_nodes("case_statement", syntax).map(fun(s: *tree<symbol>): *tree<ast> {
@@ -890,7 +894,6 @@ fun syntax_to_ast(file_name: str, syntax: *tree<symbol>, import_paths: ref vec<s
return make_ast_binding(concat(syntax)) return make_ast_binding(concat(syntax))
else { else {
error(syntax, "Cannot transform") error(syntax, "Cannot transform")
return null<tree<ast>>()
} }
} }
var result = _translation_unit(file_name, syntax->children.map(syntax_to_ast_helper)) var result = _translation_unit(file_name, syntax->children.map(syntax_to_ast_helper))

View File

@@ -187,12 +187,6 @@ fun _for(c: ref vec<*tree<ast>>): *tree<ast> {
fun _return(c: ref vec<*tree<ast>>): *tree<ast> { fun _return(c: ref vec<*tree<ast>>): *tree<ast> {
return new<tree<ast>>()->construct(ast::_return(), c) return new<tree<ast>>()->construct(ast::_return(), c)
} }
fun _break(c: ref vec<*tree<ast>>): *tree<ast> {
return new<tree<ast>>()->construct(ast::_break(), c)
}
fun _continue(c: ref vec<*tree<ast>>): *tree<ast> {
return new<tree<ast>>()->construct(ast::_continue(), c)
}
fun _defer(c: ref vec<*tree<ast>>): *tree<ast> { fun _defer(c: ref vec<*tree<ast>>): *tree<ast> {
return new<tree<ast>>()->construct(ast::_defer(), c) return new<tree<ast>>()->construct(ast::_defer(), c)
} }