unoidl2

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/unoidl2.git/
Log | Files | Refs

commit cca52fc4be133e49a416895616875b164ba6cd0a
parent b2bb9f0e0b62d1527964f53ba9beb1272fc1a222
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 18 Mar 2012 23:25:34 +0100

simplify build2_fn and walk2_fn

Diffstat:
Munoidl2.c | 6+++---
Munoidl2.h | 4++--
Munoidl2ast.c | 3+--
Munoidl2java.c | 4+---
4 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/unoidl2.c b/unoidl2.c @@ -330,7 +330,7 @@ Any subst2_rel_abs(Any v) { return v; } -Any (*build2_fn)(Any x) = id; +Fn1 build2_fn = id; Any build2(Any x) { Any p, s; @@ -367,7 +367,7 @@ Any build2(Any x) { return x; } -void (*walk2_fn)(Any x, Any c, Any k, Any p, Any v); +Fn1 walk2_fn; Any walk2(Any x) { Any c = cdr(x); @@ -380,7 +380,7 @@ Any walk2(Any x) { } else if(MODULE == kind(v)) { mapc(walk2, c); } else if(NIL == c) { - walk2_fn(x, c, k, p, v); + walk2_fn(v); } else { printf("@@@ walk2 error: unexpected children\n"); print(x); diff --git a/unoidl2.h b/unoidl2.h @@ -72,8 +72,8 @@ Any sym2p(Any x); Any sym2k(Any x); extern Any subst2_x; Any subst2_rel_abs(Any v); -extern Any (*build2_fn)(Any v); +extern Fn1 build2_fn; Any build2(Any x); -extern void (*walk2_fn)(Any x, Any c, Any k, Any p, Any v); +extern Fn1 walk2_fn; Any walk2(Any x); void init(); diff --git a/unoidl2ast.c b/unoidl2ast.c @@ -28,7 +28,6 @@ extern const Any ast; extern const Any root2; static Any pr1(Any x) {print(x); printf("\n\n");} -static void cell2ast(Any x, Any c, Any k, Any p, Any v) {pr1(v);} int main() { init(); @@ -36,7 +35,7 @@ int main() { //mapc(pr1, ast); build2_fn = subst2_rel_abs; mapc(build2, ast); - walk2_fn = cell2ast; + walk2_fn = pr1; walk2(root2); return 0; } diff --git a/unoidl2java.c b/unoidl2java.c @@ -775,8 +775,6 @@ static void pp(Any x) { printf("NIL"); } -static void walk2java(Any x, Any c, Any k, Any p, Any v) {pp(v);} - static Any subst2java(Any v) { v = subst2_rel_abs(v); switch(kind(car(v))) { @@ -808,7 +806,7 @@ int main() { //print(enums); //print(structs); - walk2_fn = walk2java; + walk2_fn = pp; walk2(root2); return 0; }