]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - yy/mp.y
paraslash 0.7.3
[paraslash.git] / yy / mp.y
diff --git a/yy/mp.y b/yy/mp.y
index 82ef51402fd5da80b523a8d395cea709fb8ffbd8..8df4f20ea04ebd2ea23b77ad77451e23e0022dbc 100644 (file)
--- a/yy/mp.y
+++ b/yy/mp.y
@@ -1,8 +1,4 @@
-/*
- * Copyright (C) 2017 Andre Noll <maan@tuebingen.mpg.de>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2017 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
 
 /*
  * Provide more verbose and specific error messages instead of just "syntax
@@ -63,7 +59,7 @@ enum semantic_types {
 
 static struct mp_ast_node *ast_node_raw(int id)
 {
-       struct mp_ast_node *node = para_malloc(sizeof(struct mp_ast_node));
+       struct mp_ast_node *node = alloc(sizeof(struct mp_ast_node));
        node->id = id;
        return node;
 }
@@ -80,7 +76,7 @@ static struct mp_ast_node *ast_node_new_unary(int id, struct mp_ast_node *child)
 {
        struct mp_ast_node *node = ast_node_raw(id);
        node->num_children = 1;
-       node->children = para_malloc(sizeof(struct mp_ast_node *));
+       node->children = alloc(sizeof(struct mp_ast_node *));
        node->children[0] = child;
        return node;
 }
@@ -90,7 +86,7 @@ static struct mp_ast_node *ast_node_new_binary(int id, struct mp_ast_node *left,
 {
        struct mp_ast_node *node = ast_node_raw(id);
        node->num_children = 2;
-       node->children = para_malloc(2 * sizeof(struct mp_ast_node *));
+       node->children = arr_alloc(2, sizeof(struct mp_ast_node *));
        node->children[0] = left;
        node->children[1] = right;
        return node;
@@ -214,6 +210,9 @@ static int eval_node(struct mp_ast_node *node, struct mp_context *ctx,
        case CHANNELS:
                result->intval= mp_channels(ctx);
                return ST_INTVAL;
+       case DURATION:
+               result->intval= mp_duration(ctx);
+               return ST_INTVAL;
        /* bools */
        case IS_SET:
                arg = node->children[0]->sv.strval;
@@ -331,6 +330,7 @@ bool mp_eval_ast(struct mp_ast_node *root, struct mp_context *ctx)
 %token <node> BITRATE
 %token <node> FREQUENCY
 %token <node> CHANNELS
+%token <node> DURATION
 %token <node> FALSE TRUE
 
 /* keywords without semantic value */
@@ -381,6 +381,7 @@ exp: NUM {$$ = $1;}
        | BITRATE {$$ = mp_new_ast_leaf_node(BITRATE);}
        | FREQUENCY {$$ = mp_new_ast_leaf_node(FREQUENCY);}
        | CHANNELS {$$ = mp_new_ast_leaf_node(CHANNELS);}
+       | DURATION {$$ = mp_new_ast_leaf_node(DURATION);}
 ;
 
 boolexp: IS_SET '(' STRING_LITERAL ')' {$$ = ast_node_new_unary(IS_SET, $3);}