summaryrefslogtreecommitdiff
path: root/src/runtime/c
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2014-12-19 08:47:00 +0000
committerkr.angelov <kr.angelov@gmail.com>2014-12-19 08:47:00 +0000
commitbb1c1dd27c8adc007ef64546cae67ac729b05422 (patch)
treed5ab77b7512a5df29bbf13333ddbfa7517a62971 /src/runtime/c
parent6b2ef03af929aaaef3ecb58401a1718a805530a2 (diff)
added mkApp to the Haskell binding
Diffstat (limited to 'src/runtime/c')
-rw-r--r--src/runtime/c/pgf/expr.c23
-rw-r--r--src/runtime/c/pgf/expr.h2
2 files changed, 25 insertions, 0 deletions
diff --git a/src/runtime/c/pgf/expr.c b/src/runtime/c/pgf/expr.c
index 551d2fb09..0192ba816 100644
--- a/src/runtime/c/pgf/expr.c
+++ b/src/runtime/c/pgf/expr.c
@@ -73,6 +73,29 @@ pgf_expr_unapply(PgfExpr expr, GuPool* pool)
return appl;
}
+PgfExpr
+pgf_expr_apply(PgfApplication* app, GuPool* pool)
+{
+ PgfExpr expr;
+
+ size_t len = strlen(app->fun);
+ PgfExprFun *efun =
+ gu_new_flex_variant(PGF_EXPR_FUN,
+ PgfExprFun,
+ fun, len+1,
+ &expr, pool);
+ strcpy(efun->fun, app->fun);
+
+ for (int i = 0; i < app->n_args; i++) {
+ expr = gu_new_variant_i(pool,
+ PGF_EXPR_APP, PgfExprApp,
+ .fun = expr,
+ .arg = app->args[i]);
+ }
+
+ return expr;
+}
+
typedef struct PgfExprParser PgfExprParser;
typedef enum {
diff --git a/src/runtime/c/pgf/expr.h b/src/runtime/c/pgf/expr.h
index a613c9666..07933556b 100644
--- a/src/runtime/c/pgf/expr.h
+++ b/src/runtime/c/pgf/expr.h
@@ -143,6 +143,8 @@ struct PgfApplication {
PgfApplication*
pgf_expr_unapply(PgfExpr expr, GuPool* pool);
+PgfExpr
+pgf_expr_apply(PgfApplication*, GuPool* pool);
PgfExpr
pgf_read_expr(GuIn* in, GuPool* pool, GuExn* err);