Commit 4f5d6bf2 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Fixed bug in the way block parameters where handled, also will now handle...

Fixed bug in the way block parameters where handled, also will now handle syntax errors better (will exit non-zero, print a message and not attempt to create a boot image).
parent 046196f2
......@@ -41,7 +41,7 @@ struct Array_String {
namespace C
{
mpz_class mask_64 (UINT64_MAX);
bool error = false; // Was there a syntax error?
std::string primordial_id {"MU_NO_ID"};
std::string primordial_name;
// This is used to annotate the return types of visitor functions
......@@ -383,8 +383,8 @@ namespace C
auto id = accept<MuID>(context->nam);
parent_names.push(last_name); // the global name of the basic block
auto nor_param_ids = accept_list("MuID", context->param_tys);
auto nor_param_types = accept_list("MuTypeNode", context->params);
auto nor_param_ids = accept_list("MuID", context->params);
auto nor_param_types = accept_list("MuTypeNode", context->param_tys);
auto insts = accept_list("MuInstNode", context->inst());
generate_call(irbuilder + "->new_bb"s, irbuilder, id,
......@@ -1163,7 +1163,11 @@ std::vector<std::string> c_compile(std::string ctx, std::string filename, std::o
tokens.fill();
UIRParser parser(&tokens);
C::Visitor visitor (ctx, output, irbuilder);
return visitor.accept<std::vector<MuID>>(parser.ir()).content;
if (lexer.getNumberOfSyntaxErrors() != 0 || parser.getNumberOfSyntaxErrors() != 0) {
C::error = true;
return {};
} else {
C::Visitor visitor (ctx, output, irbuilder);
return visitor.accept<std::vector<MuID>>(parser.ir()).content;
}
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ namespace Runtime
mpz_class mask_64 (UINT64_MAX);
MuID primordial_id {MU_NO_ID};
std::string primordial_name;
bool error = false;
// This is used to annotate the return types of visitor functions
template<typename T = void> using Any = antlrcpp::Any;
......@@ -311,8 +312,8 @@ namespace Runtime
auto id = accept<MuID>(context->nam);
parent_names.push(last_name); // the global name of the basic block
auto nor_param_ids = accept_list<MuID>(context->param_tys);
auto nor_param_types = accept_list<MuTypeNode>(context->params);
auto nor_param_ids = accept_list<MuID>(context->params);
auto nor_param_types = accept_list<MuTypeNode>(context->param_tys);
auto insts = accept_list<MuInstNode>(context->inst());
irbuilder->new_bb(irbuilder, id,
......@@ -1164,6 +1165,11 @@ std::vector<MuID> runtime_compile(MuCtx* ctx, std::string filename) {
tokens.fill();
UIRParser parser(&tokens);
Runtime::Visitor visitor (ctx);
return visitor.accept<std::vector<MuID>>(parser.ir());
if (lexer.getNumberOfSyntaxErrors() != 0 || parser.getNumberOfSyntaxErrors() != 0) {
Runtime::error = true;
return {};
} else {
Runtime::Visitor visitor (ctx);
return visitor.accept<std::vector<MuID>>(parser.ir());
}
}
\ No newline at end of file
......@@ -83,6 +83,12 @@ int main(int argc, char* argv[]) {
std::vector<MuID> idi = runtime_compile(ctx, std::string(input[i]));
ids.insert(std::end(ids), std::begin(idi), std::end(idi));
}
if (Runtime::error) {
std::cerr << "ERROR: input is invalid" << std::endl;
return -1;
}
MuFuncRefValue primordial_exp = has_primordial ?
ctx->handle_from_func(ctx, Runtime::primordial_id) : nullptr;
......@@ -128,6 +134,11 @@ int main(int argc, char* argv[]) {
std::cout << std::endl;;
}
if (C::error) {
std::cerr << "ERROR: input is invalid" << std::endl;
return -1;
}
std::string primordial_exp = has_primordial ?
ctx + "->handle_from_func("s + ctx + ", "s + C::primordial_id + ")"s : "NULL"s;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment