added mkApp to the Haskell binding

This commit is contained in:
kr.angelov
2014-12-19 08:47:00 +00:00
parent 4f7d731d40
commit fdc6c9a3cd
4 changed files with 45 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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);