Resolved conflicts, you no longer need to wrap constants in const()

This commit is contained in:
Pavel Machek 1999-03-09 14:45:27 +00:00
parent 1aa5cf1c61
commit 2575593e0f

View file

@ -22,6 +22,7 @@ CF_DECLS
CF_KEYWORDS(FUNCTION, FILTER, PRINTDEBUG, INT, PRINT, CONST, VAR, PUTS, DIE, IF) CF_KEYWORDS(FUNCTION, FILTER, PRINTDEBUG, INT, PRINT, CONST, VAR, PUTS, DIE, IF)
%type <x> term %type <x> term
%type <x> block
%type <x> cmds %type <x> cmds
CF_GRAMMAR CF_GRAMMAR
@ -65,6 +66,15 @@ cmds:
} }
; ;
block:
term ';' {
$$=$1;
}
| '{' cmds '}' {
$$=$2;
}
;
term: term:
/* EMPTY */ { /* EMPTY */ {
$$ = NULL; $$ = NULL;
@ -75,13 +85,7 @@ term:
$$->arg1 = $1; $$->arg1 = $1;
$$->arg2 = $3; $$->arg2 = $3;
} }
| IF '(' term ')' '{' cmds '}' { | IF '(' term ')' block {
$$ = f_new_inst();
$$->code = '?';
$$->arg1 = $3;
$$->arg2 = $6;
}
| IF '(' term ')' term {
$$ = f_new_inst(); $$ = f_new_inst();
$$->code = '?'; $$->code = '?';
$$->arg1 = $3; $$->arg1 = $3;
@ -93,6 +97,17 @@ term:
printf( "New variable\n" ); printf( "New variable\n" );
$$ = NULL; $$ = NULL;
} }
| SYM {
$$ = f_new_inst();
switch ($1->class) {
case SYM_VARIABLE_INT:
$$->code = 'i';
$$->arg1 = &($1->aux);
break;
default:
cf_error("Can not use this class of symbol as variable" );
}
}
| VAR '(' SYM ')' { | VAR '(' SYM ')' {
$$ = f_new_inst(); $$ = f_new_inst();
switch ($3->class) { switch ($3->class) {
@ -104,6 +119,11 @@ term:
cf_error("Can not use this class of symbol as variable" ); cf_error("Can not use this class of symbol as variable" );
} }
} }
| NUM {
$$ = f_new_inst();
$$->code = 'c';
$$->arg1 = $1
}
| CONST '(' expr ')' { | CONST '(' expr ')' {
$$ = f_new_inst(); $$ = f_new_inst();
$$->code = 'c'; $$->code = 'c';