Mercurial > lbo > hg > ylisp
view src/preprocess.c @ 120:6dfb1988cc70
preprocess: Add declaration of "defn" translator
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sun, 01 Sep 2019 14:00:52 +0200 |
parents | af8d59c76155 |
children | 63650268d006 |
line wrap: on
line source
#include "preprocess.h" #include <src/built-ins.h> #include <src/value.h> void ypreprocess(yexpr_t* expr) { assert(false /* not yet implemented */); } void ypreprocess_resolve_builtins(yexpr_t* expr) { switch (expr->typ) { case YEXPR_NUMBER: case YEXPR_STRING: case YEXPR_ATOM: case YEXPR_EXCEPTION: case YEXPR_UNDEF: break; case YEXPR_BUILTIN: assert(expr->typ != YEXPR_BUILTIN /* We shouldn't traverse the same expression twice */); case YEXPR_REF: if (yref_type(&expr->value.ref) == YREF_SYM) ybuiltin_translate(expr); break; case YEXPR_LIST: if (expr->value.list.len == 0) break; yvec_t* list = &expr->value.list; for (size_t i = 0; i < list->len; i++) { ypreprocess_resolve_builtins(YVEC_AT(list, i, yexpr_t)); } break; default: assert(false /* unexpected expression type! */); } } void ypreprocess_defn(yexpr_t* expr) { // `defn`s are already translated to built-in exprs. }