struct tree* tr;
}
-%right <n> '!'
%token <str> CONST
%token <n> NUM
%token <str> VAR
%left <n> '|'
%left <n> '^'
%left <n> '&'
+%right <n> '!'
+%left <n> NEG
+%type <tr> input_init
%type <tr> input
%type <tr> command
-%type <tr> next
%type <tr> ass
%type <tr> ass_right
%type <tr> ass_right_p
%type <tr> leaves
%%
-input: /* empty */ { $$ = input_tree = tree_malloc(ST_EMPTY); }
+input_init: input {input_tree = $$}
+
+;
+input: /* empty */ { $$ = tree_malloc(ST_EMPTY); }
| command input { $$ = tree_malloc(ST_BLOCK);
$$->pt.block.head = $1;
$$->pt.block.tail = $2;
-
- input_tree = $$;
}
;
command: ';' { $$ = tree_malloc(ST_EMPTY); }
- | '{' command next '}' {
+ | '{' command input '}' {
$$ = tree_malloc(ST_BLOCK);
$$->pt.block.head = $2;
$$->pt.block.tail = $3;
| arrow ';' { $$ = $1; }
-;
-
-next: /* empty */ {$$ = tree_malloc(ST_EMPTY); }
- | command
-
-
;
cif: KW_IF cond command KW_ELSE command {
$$->pt.op.left = $1;
$$->pt.op.right = $3;
}
+ | '-' ass_right %prec NEG {
+ $$ = tree_malloc(ST_OP);
+ $$->pt.op.op = $1;
+ $$->pt.op.left = tree_malloc(ST_LEAF);
+ $$->pt.op.left->pt.leaf.type = L_CONST;
+ $$->pt.op.left->pt.leaf.value = "0";
+ $$->pt.op.left->pt.leaf.n =
+ store_const("0");
+ $$->pt.op.right = $2;
+ }
;
%%