diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/build.h | 12 | ||||
-rw-r--r-- | inc/free.h | 13 | ||||
-rw-r--r-- | inc/parse.h | 22 | ||||
-rw-r--r-- | inc/print.h | 12 | ||||
-rw-r--r-- | inc/spec.h | 24 | ||||
-rw-r--r-- | inc/term.h | 32 |
6 files changed, 115 insertions, 0 deletions
diff --git a/inc/build.h b/inc/build.h new file mode 100644 index 0000000..fe41e11 --- /dev/null +++ b/inc/build.h @@ -0,0 +1,12 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#ifndef BLOC_BUILD_H +#define BLOC_BUILD_H + +#include <spec.h> +#include <term.h> + +void write_bloc(struct term *term, const char *path); + +#endif diff --git a/inc/free.h b/inc/free.h new file mode 100644 index 0000000..34c82c7 --- /dev/null +++ b/inc/free.h @@ -0,0 +1,13 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#ifndef BLOC_FREE_H +#define BLOC_FREE_H + +#include <parse.h> +#include <term.h> + +void free_term(struct term *term); +void free_bloc(struct bloc_parsed *bloc); + +#endif diff --git a/inc/parse.h b/inc/parse.h new file mode 100644 index 0000000..c8cafed --- /dev/null +++ b/inc/parse.h @@ -0,0 +1,22 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#ifndef BLOC_PARSE_H +#define BLOC_PARSE_H + +#include <stddef.h> + +#include <term.h> +#include <spec.h> + +struct bloc_parsed { + size_t length; + struct term **entries; + struct term *term; +}; + +struct term *parse_blc(const char *term); +struct bloc_parsed *parse_bloc(const void *bloc); +struct term *from_bloc(struct bloc_parsed *bloc); + +#endif diff --git a/inc/print.h b/inc/print.h new file mode 100644 index 0000000..9885f57 --- /dev/null +++ b/inc/print.h @@ -0,0 +1,12 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#ifndef BLOC_PRINT_H +#define BLOC_PRINT_H + +#include <term.h> + +void print_bruijn(struct term *term); +void print_blc(struct term *term); + +#endif diff --git a/inc/spec.h b/inc/spec.h new file mode 100644 index 0000000..8bd8ace --- /dev/null +++ b/inc/spec.h @@ -0,0 +1,24 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#ifndef BLOC_SPEC_H +#define BLOC_SPEC_H + +#define BLOC_IDENTIFIER "BLoC" +#define BLOC_IDENTIFIER_LENGTH 4 + +struct bloc_header { + char identifier[BLOC_IDENTIFIER_LENGTH]; + short length; + void *data; +} __attribute__((packed)); + +struct bloc_entry { + void *expression; +} __attribute__((packed)); + +struct bloc_structure { + void *expression; +} __attribute__((packed)); + +#endif diff --git a/inc/term.h b/inc/term.h new file mode 100644 index 0000000..a90bdd3 --- /dev/null +++ b/inc/term.h @@ -0,0 +1,32 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#ifndef BLOC_TERM_H +#define BLOC_TERM_H + +#include <stddef.h> + +typedef enum { INV, ABS, APP, VAR, REF } term_type; + +struct term { + term_type type; + union { + struct { + struct term *term; + } abs; + struct { + struct term *lhs; + struct term *rhs; + } app; + struct { + int index; + } var; + struct { + size_t index; + } ref; + } u; +}; + +struct term *new_term(term_type type); + +#endif |