diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-25 00:01:56 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-25 00:01:56 -0400 |
| commit | b1d2120d5d20c0122cc0a61f2ca09f0bc754d14d (patch) | |
| tree | a9e978b3bf6aa371a8591317ff2fd2450e9c1e21 /src | |
| parent | f5b2281084d31700690916c6dd250e2da927e566 (diff) | |
More docs and moving parsing into a subfolder.
Diffstat (limited to 'src')
| -rw-r--r-- | src/README.md | 4 | ||||
| -rw-r--r-- | src/compile/README.md | 35 | ||||
| -rw-r--r-- | src/environment.c | 2 | ||||
| -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.c | 2 | ||||
| -rw-r--r-- | src/typecheck.c | 2 |
7 files changed, 48 insertions, 13 deletions
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); @@ -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" |
