nitron

commit d12590d0f6f37270e2198ab68e6a894097dd0fa8

Author: mesyeti <mesyeti@mesyeti.uk>

fix subroutine definitions

 basic/source/compiler.c | 7 ++++---
 basic/source/frontend/c89.c | 4 ++--
 basic/source/parser.c | 1 +


diff --git a/basic/source/compiler.c b/basic/source/compiler.c
index 6ac6c1818c1a418820ccbb9af6385a2f98a33589..14f961a18c1d900f442908e119a41f5e2b0761ee 100644
--- a/basic/source/compiler.c
+++ b/basic/source/compiler.c
@@ -40,14 +40,14 @@ 	compiler.nodes = nodes;
 	compiler.len   = len;
 }
 
-void Compiler_Compile(Node* node, bool inMain) {
-	if (inMain) {
+void Compiler_Compile(Node* node, bool inFunc) {
+	if (inFunc) {
 		switch (node->i.type) {
 			case NODE_FUNC_DEF:  break;
 			case NODE_DIM:       break;
+			case NODE_EXTERN:    break;
 			case NODE_FUNC_CALL: Frontend_CompileFuncCall(&node->funcCall); break;
 			case NODE_ASSIGN:    Frontend_CompileAssign(&node->assign); break;
-			case NODE_EXTERN:    Frontend_CompileExtern(&node->external); break;
 			default: {
 				PrintError(node->i.err, "Unexpected '%s'", Parser_TypeStr(node->i.type));
 			}
@@ -57,6 +57,7 @@ 	else {
 		switch (node->i.type) {
 			case NODE_FUNC_DEF: Frontend_CompileFuncDef(&node->funcDef); break;
 			case NODE_DIM:      Frontend_CompileDim(&node->dim); break;
+			case NODE_EXTERN:   Frontend_CompileExtern(&node->external); break;
 			default:            break;
 		}
 	}




diff --git a/basic/source/frontend/c89.c b/basic/source/frontend/c89.c
index 1cc83b5e05127cc86b81e72940325702638838c1..870cfea38a9d6c858c427349ec368ee25b560d6a 100644
--- a/basic/source/frontend/c89.c
+++ b/basic/source/frontend/c89.c
@@ -11,7 +11,7 @@ static void Finish(void) {
 	fprintf(out, "}\n");
 	fflush(out);
 
-	const char* cmd = "gcc out.c -o out";
+	const char* cmd = "gcc out.c -o out -fno-builtin";
 	puts(cmd);
 	system(cmd);
 }
@@ -69,7 +69,7 @@ 	CompileDec(node->dec);
 	fprintf(out, " {\n");
 
 	for (size_t i = 0; i < node->bodyLen; ++ i) {
-		Compiler_Compile(&node->body[i], false);
+		Compiler_Compile(&node->body[i], true);
 	}
 
 	fprintf(out, "}\n");




diff --git a/basic/source/parser.c b/basic/source/parser.c
index d8fe1957fdb7a916fb3bef3758776721086b4de5..1212e859a6a468c68afb69a25fd51f243e79d937 100644
--- a/basic/source/parser.c
+++ b/basic/source/parser.c
@@ -306,6 +306,7 @@
 	Advance(p);
 	if (sub) {
 		Expect(p, TOKEN_LINE);
+		ret.ret = NULL;
 	}
 	else {
 		ret.ret  = SafeMalloc(sizeof(Node));