X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=yy%2Fmp.y;h=8df4f20ea04ebd2ea23b77ad77451e23e0022dbc;hb=HEAD;hp=0f2c9cb8b256a82eeb2fac78114f6026902a24f2;hpb=d5e27e2a346da2f18188d317926a60687d082732;p=paraslash.git diff --git a/yy/mp.y b/yy/mp.y index 0f2c9cb8..8df4f20e 100644 --- a/yy/mp.y +++ b/yy/mp.y @@ -59,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; } @@ -76,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; } @@ -86,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; @@ -210,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; @@ -327,6 +330,7 @@ bool mp_eval_ast(struct mp_ast_node *root, struct mp_context *ctx) %token BITRATE %token FREQUENCY %token CHANNELS +%token DURATION %token FALSE TRUE /* keywords without semantic value */ @@ -377,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);}