From abf68e0ad6c9f6d6cd14693894c609faca925e22 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 27 May 2023 10:07:24 +0200 Subject: Moved term logic --- inc/parse.h | 22 +--------------------- inc/term.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 inc/term.h (limited to 'inc') diff --git a/inc/parse.h b/inc/parse.h index e79fb26..9dfa388 100644 --- a/inc/parse.h +++ b/inc/parse.h @@ -5,27 +5,7 @@ #define CALM_PARSE_H #include - -typedef enum { INV, ABS, APP, VAR } term_type_t; - -struct term { - term_type_t type; - hash_t hash; - size_t refs; - size_t depth; - union { - struct { - struct term *term; - } abs; - struct { - struct term *lhs; - struct term *rhs; - } app; - struct { - int index; - } var; - } u; -}; +#include struct term_handle { struct term *term; diff --git a/inc/term.h b/inc/term.h new file mode 100644 index 0000000..b64b106 --- /dev/null +++ b/inc/term.h @@ -0,0 +1,33 @@ +// Copyright (c) 2023, Marvin Borner +// SPDX-License-Identifier: MIT + +#ifndef CALM_TERM_H +#define CALM_TERM_H + +#include + +typedef enum { INV, ABS, APP, VAR } term_type_t; + +struct term { + term_type_t type; + hash_t hash; + size_t refs; + size_t depth; + union { + struct { + struct term *term; + } abs; + struct { + struct term *lhs; + struct term *rhs; + } app; + struct { + int index; + } var; + } u; +}; + +struct term *term_new(term_type_t type, hash_t hash, size_t depth); +void term_refer(struct term *term, size_t depth); + +#endif -- cgit v1.2.3