update tests
This commit is contained in:
parent
9d84cd0137
commit
4b54877ee9
|
|
@ -159,6 +159,13 @@ void stmt_print(struct stmt *s) {
|
||||||
decl_print(s->decl);
|
decl_print(s->decl);
|
||||||
printf(";\n");
|
printf(";\n");
|
||||||
break;
|
break;
|
||||||
|
case STMT_MOVE:
|
||||||
|
printf("move ");
|
||||||
|
expr_print(s->decl->name);
|
||||||
|
printf(" to ");
|
||||||
|
expr_print(s->decl->value);
|
||||||
|
printf(";\n");
|
||||||
|
break;
|
||||||
case STMT_END_EXECUTION:
|
case STMT_END_EXECUTION:
|
||||||
printf("stop run\n");
|
printf("stop run\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -117,14 +117,10 @@ UTEST_F_TEARDOWN(InterpreterTestFile) {
|
||||||
ASSERT_STREQ(actual_evaluate, expected_evaluate);
|
ASSERT_STREQ(actual_evaluate, expected_evaluate);
|
||||||
}
|
}
|
||||||
|
|
||||||
UTEST_F(InterpreterTestFile, print) {
|
UTEST_F(InterpreterTestFile, helloworld) {
|
||||||
utest_fixture->test_file = "samples/multiple_statements.c";
|
utest_fixture->test_file = "samples/hello-world.cbl";
|
||||||
utest_fixture->print_file = "samples/multiple_statements_print.txt";
|
utest_fixture->print_file = "samples/hello-world_print.txt";
|
||||||
utest_fixture->evaluated_file = "samples/multiple_statements_evaluate.txt";
|
utest_fixture->evaluated_file = "samples/hello-world_evaluate.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
UTEST_F(InterpreterTestFile, program_file) {
|
|
||||||
utest_fixture->test_file = "samples/program.c";
|
|
||||||
utest_fixture->print_file = "samples/program_print.txt";
|
|
||||||
utest_fixture->evaluated_file = "samples/program_evaluate.txt";
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@ extern struct stmt *parser_result = 0;
|
||||||
%token TOKEN_EXPONENTIAL
|
%token TOKEN_EXPONENTIAL
|
||||||
%token TOKEN_DISPLAY
|
%token TOKEN_DISPLAY
|
||||||
|
|
||||||
|
|
||||||
%left TOKEN_ADD TOKEN_SUB
|
%left TOKEN_ADD TOKEN_SUB
|
||||||
%left TOKEN_MULTIPLY TOKEN_DIVIDE
|
%left TOKEN_MULTIPLY TOKEN_DIVIDE
|
||||||
%left TOKEN_EXPONENTIAL
|
%left TOKEN_EXPONENTIAL
|
||||||
|
|
@ -137,9 +136,10 @@ type : TOKEN_KEYWORD_IDENTIFICATION
|
||||||
simple_stmt : cbl_func_stmt
|
simple_stmt : cbl_func_stmt
|
||||||
{$$ = $1;}
|
{$$ = $1;}
|
||||||
| if_branch
|
| if_branch
|
||||||
|
{$$ = $1;}
|
||||||
| perform_stmt
|
| perform_stmt
|
||||||
;
|
;
|
||||||
cbl_func_stmt : cbl_function ident assignment_stmt
|
cbl_func_stmt : cbl_function type_expr assignment_stmt
|
||||||
{ $3->name = $2; $$= stmt_create($1->kind, $3, NULL, NULL, NULL, NULL, NULL, NULL);}
|
{ $3->name = $2; $$= stmt_create($1->kind, $3, NULL, NULL, NULL, NULL, NULL, NULL);}
|
||||||
| cbl_function op_parms
|
| cbl_function op_parms
|
||||||
{$$ = stmt_create($1->kind, NULL, NULL, $2, NULL, NULL, NULL, NULL);}
|
{$$ = stmt_create($1->kind, NULL, NULL, $2, NULL, NULL, NULL, NULL);}
|
||||||
|
|
@ -200,7 +200,6 @@ type_expr : ident
|
||||||
{$$ = expr_create_string_literal(yytext);}
|
{$$ = expr_create_string_literal(yytext);}
|
||||||
| TOKEN_SPACE
|
| TOKEN_SPACE
|
||||||
{$$ = expr_create_integer_literal(0);}
|
{$$ = expr_create_integer_literal(0);}
|
||||||
// TODO: implment negative numbers
|
|
||||||
| TOKEN_SUB ident
|
| TOKEN_SUB ident
|
||||||
{ $2->negative = 1; $$ = $2;}
|
{ $2->negative = 1; $$ = $2;}
|
||||||
| ext_function
|
| ext_function
|
||||||
|
|
@ -271,7 +270,7 @@ category_value : TOKEN_KEYWORD_VALUE TOKEN_INTEGER
|
||||||
category_spec : complete_category
|
category_spec : complete_category
|
||||||
{$$ = decl_create(NULL, $1, NULL, NULL, NULL);}
|
{$$ = decl_create(NULL, $1, NULL, NULL, NULL);}
|
||||||
| complete_category data_clause category_value
|
| complete_category data_clause category_value
|
||||||
{ $$ = decl_create(NULL, $1, $3, NULL, $2);}
|
{ $1->level = $2->level; $$ = decl_create(NULL, $1, $3, NULL, NULL);}
|
||||||
;
|
;
|
||||||
//TODO: implement levels
|
//TODO: implement levels
|
||||||
simple_decl : TOKEN_INTEGER ident TOKEN_DOT
|
simple_decl : TOKEN_INTEGER ident TOKEN_DOT
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Hello World!
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
section
|
||||||
|
section
|
||||||
|
section
|
||||||
|
print Hello World!;
|
||||||
|
stop run
|
||||||
Loading…
Reference in New Issue