aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--src/README.md4
-rw-r--r--src/compile/README.md35
-rw-r--r--src/environment.c2
-rw-r--r--src/parse/parse.c (renamed from src/parse.c)14
-rw-r--r--src/parse/parse.h (renamed from src/parse.h)2
-rw-r--r--src/tomo.c2
-rw-r--r--src/typecheck.c2
8 files changed, 50 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index d7fc4663..95f07128 100644
--- a/Makefile
+++ b/Makefile
@@ -95,7 +95,7 @@ else
endif
EXE_FILE=tomo_$(TOMO_VERSION)
-COMPILER_OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c src/compile/*.c))
+COMPILER_OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c src/compile/*.c src/parse/*.c))
STDLIB_OBJS=$(patsubst %.c,%.o,$(wildcard src/stdlib/*.c))
TESTS=$(patsubst test/%.tm,test/results/%.tm.testresult,$(wildcard test/*.tm))
API_YAML=$(wildcard api/*.yaml)
@@ -129,7 +129,7 @@ build/lib/$(AR_FILE): $(STDLIB_OBJS)
ar -rcs $@ $^
tags:
- ctags src/*.{c,h} src/stdlib/*.{c,h} src/compile/*.{c,h}
+ ctags src/*.{c,h} src/stdlib/*.{c,h} src/compile/*.{c,h} src/parse/*.{c,h}
config.mk: configure.sh
bash ./configure.sh
diff --git a/src/README.md b/src/README.md
index fa89ccdd..f91aec10 100644
--- a/src/README.md
+++ b/src/README.md
@@ -3,10 +3,10 @@
This directory contains the source files for the Tomo compiler:
- Abstract syntax trees: [ast.c](ast.c)/[ast.h](ast.h)
-- Compilation: [compile.c](compile.c)/[compile.h](compile.h)
+- Compilation: [compile/](compile)
- Compilation logic for enums: [enums.c](enums.c)/[enums.h](enums.h)
- Compilation environments: [environment.c](environment.c)/[environment.h](environment.h)
-- Parsing: [parse.c](parse.c)/[parse.h](parse.h)
+- Parsing: [parse/](parse)
- Compilation logic for structs: [structs.c](structs.c)/[structs.h](structs.h)
- The compiler executable: [tomo.c](tomo.c)/[tomo.h](tomo.h)
- Typechecking logic: [typecheck.c](typecheck.c)/[typecheck.h](typecheck.h)
diff --git a/src/compile/README.md b/src/compile/README.md
new file mode 100644
index 00000000..2d26249d
--- /dev/null
+++ b/src/compile/README.md
@@ -0,0 +1,35 @@
+# Source Files
+
+This directory contains the source files for actual cross-compilation
+(transpilation) from AST to C code:
+
+- Assert statements (`assert x > 1`): [assertions.c](assertions.c)
+- Variable assignment (`x = val`): [assignments.c](assignments.c)
+- Binary operations (`1 + 2`, etc.): [binops.c](binops.c)
+- Code blocks: [blocks.c](blocks.c)
+- Command line interface parsing: [cli.c](cli.c)
+- Comparisons (`a == b`, `a > b`, etc): [comparisons.c](comparisons.c)
+- Conditionals (`if` statements): [conditionals.c](conditionals.c)
+- Variable declarations: [declarations.c](declarations.c)
+- Doctests (`>> test`): [doctests.c](doctests.c)
+- Enums (`enum`): [enums.c](enums.c)
+- General logic for compiling expressions: [expressions.c](expressions.c)
+- Field accesses (`foo.baz`) [fieldaccess.c](fieldaccess.c)
+- Compilation of entire files: [files.c](files.c)
+- Functions, lambdas, and function calls (`func`): [functions.c](functions.c)
+- Compilation of C headers: [headers.c](headers.c)
+- Indexing (`foo[x]` and `ptr[]`): [indexing.c](indexing.c)
+- Integers: [integers.c](integers.c)
+- Lists (`[1, 2, 3]`): [lists.c](lists.c)
+- Loops (`for`, `repeat`, `while`, `skip`, `stop`): [loops.c](loops.c)
+- Optional values and `none`: [optionals.c](optionals.c)
+- Pointers (`@` and `&`): [pointers.c](pointers.c)
+- Type promotions of values: [promotions.c](promotions.c)
+- Reductions (`(+: nums)`): [reductions.c](reductions.c)
+- Sets (`|1, 2, 3|`): [sets.c](sets.c)
+- General logic for compiling statements: [statements.c](statements.c)
+- Structs (`struct`): [structs.c](structs.c)
+- Tables (`{1=10, 2=20}`): [tables.c](tables.c)
+- Text: [text.c](text.c)
+- Types and type metadata: [types.c](types.c)
+- Pattern matching (`when x is ...`): [whens.c](whens.c)
diff --git a/src/environment.c b/src/environment.c
index a32f1a28..620d93c4 100644
--- a/src/environment.c
+++ b/src/environment.c
@@ -5,7 +5,7 @@
#include "environment.h"
#include "naming.h"
-#include "parse.h"
+#include "parse/parse.h"
#include "stdlib/datatypes.h"
#include "stdlib/tables.h"
#include "stdlib/text.h"
diff --git a/src/parse.c b/src/parse/parse.c
index 2e0413b4..6a6d78a4 100644
--- a/src/parse.c
+++ b/src/parse/parse.c
@@ -18,13 +18,13 @@
#include <unictype.h>
#include <uniname.h>
-#include "ast.h"
-#include "stdlib/print.h"
-#include "stdlib/stacktrace.h"
-#include "stdlib/stdlib.h"
-#include "stdlib/tables.h"
-#include "stdlib/text.h"
-#include "stdlib/util.h"
+#include "../ast.h"
+#include "../stdlib/print.h"
+#include "../stdlib/stacktrace.h"
+#include "../stdlib/stdlib.h"
+#include "../stdlib/tables.h"
+#include "../stdlib/text.h"
+#include "../stdlib/util.h"
// The cache of {filename -> parsed AST} will hold at most this many entries:
#ifndef PARSE_CACHE_SIZE
diff --git a/src/parse.h b/src/parse/parse.h
index 7d16b995..c3e9455a 100644
--- a/src/parse.h
+++ b/src/parse/parse.h
@@ -4,7 +4,7 @@
#include <setjmp.h>
-#include "ast.h"
+#include "../ast.h"
type_ast_t *parse_type_str(const char *str);
ast_t *parse_file(const char *path, jmp_buf *on_err);
diff --git a/src/tomo.c b/src/tomo.c
index 6f08f1ff..01c1ebab 100644
--- a/src/tomo.c
+++ b/src/tomo.c
@@ -20,7 +20,7 @@
#include "config.h"
#include "modules.h"
#include "naming.h"
-#include "parse.h"
+#include "parse/parse.h"
#include "stdlib/bools.h"
#include "stdlib/bytes.h"
#include "stdlib/datatypes.h"
diff --git a/src/typecheck.c b/src/typecheck.c
index bedc4121..09c5fc62 100644
--- a/src/typecheck.c
+++ b/src/typecheck.c
@@ -12,7 +12,7 @@
#include "environment.h"
#include "modules.h"
#include "naming.h"
-#include "parse.h"
+#include "parse/parse.h"
#include "stdlib/paths.h"
#include "stdlib/tables.h"
#include "stdlib/text.h"