From 7c60c27302a1fc023984c15052cc3a4212d3714e Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 12 Aug 2016 00:19:51 +0200 Subject: [PATCH] The Basic compiler works now. --- build.lua | 1 + lang/basic/src/basic.g | 4 +-- lang/basic/src/basic.lex | 2 -- lang/basic/src/build.lua | 47 +++++++++++++++++++++++++++ lang/basic/src/{llmess.c => llmess.h} | 0 lang/basic/src/maketokentab | 4 +-- lang/basic/src/{yylexp.c => yylexp.h} | 0 plat/build.lua | 1 + 8 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 lang/basic/src/build.lua rename lang/basic/src/{llmess.c => llmess.h} (100%) rename lang/basic/src/{yylexp.c => yylexp.h} (100%) diff --git a/build.lua b/build.lua index 373f195e3..0b1637f63 100644 --- a/build.lua +++ b/build.lua @@ -12,6 +12,7 @@ installable { name = "ack", map = { "lang/cem/cemcom.ansi+pkg", + "lang/basic/src+pkg", "plat/pc86+pkg", "util/ack+pkg", "util/amisc+pkg", diff --git a/lang/basic/src/basic.g b/lang/basic/src/basic.g index 8f74a69f7..5c4f6978a 100644 --- a/lang/basic/src/basic.g +++ b/lang/basic/src/basic.g @@ -90,7 +90,7 @@ #include #include #include "bem.h" -#include "llmess.c" +#include "llmess.h" typedef union { int integer ; @@ -112,7 +112,7 @@ int in_data = 0; /* set if processing DATA statement */ char *formatstring; /* formatstring used for printing */ Symbol *s; /* Symbol dummy */ -#include "yylexp.c" +#include "yylexp.h" #include "basic.lex" } diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index 0f514c97d..4eb9e1659 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -235,8 +235,6 @@ File *stream; } } -extern char *strchr(); - getinputline() { /* get next input line */ diff --git a/lang/basic/src/build.lua b/lang/basic/src/build.lua new file mode 100644 index 000000000..001ca037a --- /dev/null +++ b/lang/basic/src/build.lua @@ -0,0 +1,47 @@ +include("util/LLgen/build.lua") + +llgen { + name = "llgen", + srcs = { "./*.g" } +} + +normalrule { + name = "tokentab_h", + ins = { + "./maketokentab", + matching(filenamesof("+llgen"), "/Lpars.h$"), + }, + outleaves = { "tokentab.h" }, + commands = { + "%{ins} %{outs}" + } +} + +cprogram { + name = "em_bem", + srcs = { + "./*.c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+llgen", + "+tokentab_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/em_mes+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "util/data+em_data", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_bem"] = "+em_bem" + } +} + diff --git a/lang/basic/src/llmess.c b/lang/basic/src/llmess.h similarity index 100% rename from lang/basic/src/llmess.c rename to lang/basic/src/llmess.h diff --git a/lang/basic/src/maketokentab b/lang/basic/src/maketokentab index 6ceee720d..777eb1402 100755 --- a/lang/basic/src/maketokentab +++ b/lang/basic/src/maketokentab @@ -1,6 +1,6 @@ #!/bin/sh -ed -s "${1:-Lpars.h}" <<'+' +ed -s "${1:-Lpars.h}" > $2 <<'+' 1d 1,$s/# *define // 1,$s/ ...$// @@ -13,6 +13,6 @@ char *tokentab[] = { $a }; . -w tokentab.h +1,$p q + diff --git a/lang/basic/src/yylexp.c b/lang/basic/src/yylexp.h similarity index 100% rename from lang/basic/src/yylexp.c rename to lang/basic/src/yylexp.h diff --git a/plat/build.lua b/plat/build.lua index 472e9ec3f..52c45fdd4 100644 --- a/plat/build.lua +++ b/plat/build.lua @@ -13,6 +13,7 @@ definerule("ackfile", name = e.name, srcs = e.srcs, deps = { + "lang/cem/cemcom.ansi+pkg", "lang/cem/cpp.ansi+pkg", "plat/"..plat.."+tools", "util/ack+pkg",