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;
}
{
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;
}
{
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;
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;
%token <node> BITRATE
%token <node> FREQUENCY
%token <node> CHANNELS
+%token <node> DURATION
%token <node> FALSE TRUE
/* keywords without semantic value */
| 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);}