Fixed some things.
This commit is contained in:
parent
8b01407374
commit
27e61471a8
@ -27,6 +27,8 @@
|
|||||||
%token RGROUP
|
%token RGROUP
|
||||||
%token SEP
|
%token SEP
|
||||||
|
|
||||||
|
%token EXPSEP
|
||||||
|
|
||||||
%token<strval> WORD
|
%token<strval> WORD
|
||||||
%token<fval> NUM
|
%token<fval> NUM
|
||||||
|
|
||||||
@ -50,6 +52,7 @@
|
|||||||
input:
|
input:
|
||||||
%empty
|
%empty
|
||||||
| exp { root = $1; }
|
| exp { root = $1; }
|
||||||
|
| input EXPSEP exp { root = $3; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ int yylex() {
|
|||||||
case '(': return LGROUP;
|
case '(': return LGROUP;
|
||||||
case ')': return RGROUP;
|
case ')': return RGROUP;
|
||||||
case ',': return SEP;
|
case ',': return SEP;
|
||||||
|
case ';': return EXPSEP;
|
||||||
default: fprintf(stderr, "Unexpected character: %c\n", c);
|
default: fprintf(stderr, "Unexpected character: %c\n", c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,3 +82,16 @@ bin() { ./scl.out $1 | tail -n1; }
|
|||||||
run bin "-(-(1+2)*3)"
|
run bin "-(-(1+2)*3)"
|
||||||
[ "$output" = "= 9.000000" ]
|
[ "$output" = "= 9.000000" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "multiple expressions per line" {
|
||||||
|
run bin "1+1;2"
|
||||||
|
[ "$output" = "= 2.000000" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "variable definition" {
|
||||||
|
run bin "x = 1"
|
||||||
|
[ "$output" = "= 1.000000" ]
|
||||||
|
|
||||||
|
run bin "x = 1; x + 1"
|
||||||
|
[ "$output" = "= 2.000000" ]
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user