diff --git a/cpp/src/build.cpp b/cpp/src/build.cpp index a7529a1..d0702d3 100644 --- a/cpp/src/build.cpp +++ b/cpp/src/build.cpp @@ -28,10 +28,16 @@ void set_build_type(std::int64_t build_type_value) cur_build_info->config = static_cast(build_type_value); } +void set_output_name(const char* name) +{ + cur_build_info->link_name = name; +} + void install_functions(llvm::ExecutionEngine& exe) { exe.addGlobalMapping("set_linkage_type", reinterpret_cast(&set_linkage_type)); exe.addGlobalMapping("set_build_type", reinterpret_cast(&set_build_type)); + exe.addGlobalMapping("set_output_name", reinterpret_cast(&set_output_name)); } @@ -205,6 +211,24 @@ namespace build .is_extern = true } }); + ret.root.children.push_back(ast::node + { + .payload = ast::function_definition + { + .func_name = "set_output_name", + .params = + { + ast::variable_declaration + { + .var_name = "outname", + .type_name = "i8&", + .initialiser = ast::expression{.expr = ast::null_literal{}} + }, + }, + .ret_type = "u0", + .is_extern = true + } + }); // same with some globals. for(int i = 0; i < (int)build::linkage_type::_count; i++) diff --git a/cpp/src/parse.cpp b/cpp/src/parse.cpp index 493c2ec..bf49739 100644 --- a/cpp/src/parse.cpp +++ b/cpp/src/parse.cpp @@ -251,6 +251,22 @@ namespace parse maybe_expr = ast::expression{.expr = maybe_decimal_literal.value()}; return maybe_expr; } + this->undo(); + // char literal + auto maybe_char_literal = this->retrieve(); + if(maybe_char_literal.has_value()) + { + maybe_expr = ast::expression{.expr = maybe_char_literal.value()}; + return maybe_expr; + } + this->undo(); + // string literal + auto maybe_string_literal = this->retrieve(); + if(maybe_string_literal.has_value()) + { + maybe_expr = ast::expression{.expr = maybe_string_literal.value()}; + return maybe_expr; + } } return maybe_expr; } diff --git a/samples/scratchpad.psy b/samples/scratchpad.psy index ca599a3..c87c0e0 100644 --- a/samples/scratchpad.psy +++ b/samples/scratchpad.psy @@ -94,4 +94,5 @@ main :: () -> i64 { set_build_type(debug); set_linkage_type(executable); + set_output_name("scratchpad.exe"); } \ No newline at end of file