diff options
| author | eunhhu <[email protected]> | 2026-09-27 13:45:45 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-27 13:45:45 +0100 |
| commit | 56b8202a23eb08167f27fea4782152959f8ea9ef (patch) | |
| tree | b9a52400f440b98cd0ba805fee633899093eb530 /compiler/aup.h | |
| parent | 04bc25fdf06247f3db781f581195ee7a16165a72 (diff) | |
| download | aup-56b8202a23eb08167f27fea4782152959f8ea9ef.tar.gz aup-56b8202a23eb08167f27fea4782152959f8ea9ef.zip | |
Name aup's one part: compiler/
As in Pure and Vega, the top level directories are the parts; aup has one,
the compiler, checked end to end by tests/check.py.
Diffstat (limited to 'compiler/aup.h')
| -rw-r--r-- | compiler/aup.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler/aup.h b/compiler/aup.h new file mode 100644 index 0000000..98b59b0 --- /dev/null +++ b/compiler/aup.h @@ -0,0 +1,25 @@ +#ifndef AUP_H +#define AUP_H +#include <stdbool.h> +#include <stddef.h> + +/* aup: source text to a Pure module (Pure docs/design/008-module-format.md). */ +enum { AUP_SOURCE_LIMIT = 32768, AUP_MESSAGE = 256, AUP_PATH = 256 }; + +typedef struct { + char path[AUP_PATH]; /* the library the error is in, or "" for the main source */ + int line, column; + char message[AUP_MESSAGE]; +} AupDiagnostic; + +/* Finds the library that `use name` names: its source, alive until + * aup_compile returns, and a path that diagnostics show. */ +typedef bool (*AupLoad)(void *context, const char *name, const char **source, size_t *length, + char path[AUP_PATH]); + +/* Compile source into a newly allocated module (free with free()). The same + * sources always produce the same bytes. On failure *module is NULL and the + * diagnostic names the first error. load may be NULL when nothing is used. */ +bool aup_compile(const char *source, size_t length, AupLoad load, void *context, + unsigned char **module, size_t *size, AupDiagnostic *error); +#endif |
