summaryrefslogtreecommitdiff
path: root/src/runtime/c/pgf/expr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/c/pgf/expr.c')
-rw-r--r--src/runtime/c/pgf/expr.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/runtime/c/pgf/expr.c b/src/runtime/c/pgf/expr.c
index af849817c..3482e0b11 100644
--- a/src/runtime/c/pgf/expr.c
+++ b/src/runtime/c/pgf/expr.c
@@ -607,7 +607,8 @@ pgf_expr_parser_expr(PgfExprParser* parser)
parser->token_tag != PGF_TOKEN_RPAR &&
parser->token_tag != PGF_TOKEN_RCURLY &&
parser->token_tag != PGF_TOKEN_RTRIANGLE &&
- parser->token_tag != PGF_TOKEN_COLON) {
+ parser->token_tag != PGF_TOKEN_COLON &&
+ parser->token_tag != PGF_TOKEN_COMMA) {
PgfExpr arg = pgf_expr_parser_arg(parser);
if (gu_variant_is_null(arg))
return gu_null_variant;
@@ -798,7 +799,7 @@ PgfExpr
pgf_read_expr(GuIn* in, GuPool* pool, GuExn* err)
{
GuPool* tmp_pool = gu_new_pool();
- PgfExprParser* parser =
+ PgfExprParser* parser =
pgf_new_parser(in, pool, tmp_pool, err);
PgfExpr expr = pgf_expr_parser_expr(parser);
if (parser->token_tag != PGF_TOKEN_EOF)
@@ -807,6 +808,38 @@ pgf_read_expr(GuIn* in, GuPool* pool, GuExn* err)
return expr;
}
+int
+pgf_read_expr_tuple(GuIn* in,
+ int n_exprs, PgfExpr exprs[],
+ GuPool* pool, GuExn* err)
+{
+ GuPool* tmp_pool = gu_new_pool();
+ PgfExprParser* parser =
+ pgf_new_parser(in, pool, tmp_pool, err);
+ if (parser->token_tag != PGF_TOKEN_LTRIANGLE)
+ return 0;
+ pgf_expr_parser_token(parser);
+ for (size_t i = 0; i < n_exprs; i++) {
+ if (i > 0) {
+ if (parser->token_tag != PGF_TOKEN_COMMA)
+ return 0;
+ pgf_expr_parser_token(parser);
+ }
+
+ exprs[i] = pgf_expr_parser_expr(parser);
+ if (gu_variant_is_null(exprs[i]))
+ return 0;
+ }
+ if (parser->token_tag != PGF_TOKEN_RTRIANGLE)
+ return 0;
+ pgf_expr_parser_token(parser);
+ if (parser->token_tag != PGF_TOKEN_EOF)
+ return 0;
+ gu_pool_free(tmp_pool);
+
+ return 1;
+}
+
PgfType*
pgf_read_type(GuIn* in, GuPool* pool, GuExn* err)
{