WIP : Storing line numbers, detecting immediate mode vs storage mode, solver tests are not working
This commit is contained in:
@@ -9,22 +9,8 @@ int main(void)
|
||||
{
|
||||
struct basic_expr *expr;
|
||||
char *line;
|
||||
/*struct basic_line *retline;
|
||||
struct basic_line *arrayline;*/
|
||||
|
||||
/* Store a line */
|
||||
/* expr = basic_parse_expr("10 =1 + 1");
|
||||
if ( expr == NULL ) return 1;
|
||||
if ( expr->lval_type != BASIC_LVAL_CONST_INT ) return 2;
|
||||
if ( expr->rval_type != BASIC_RVAL_PTR ) return 3;
|
||||
if ( expr->lval.i != 10 ) return 4;
|
||||
if ( expr->rval.ptr == NULL ) return 5;
|
||||
if ( expr->type != BASIC_OPTP_STOR ) return 6;
|
||||
*/
|
||||
/* Parse the stored line */
|
||||
/* retline = (basic_line *)expr->rval.ptr;
|
||||
expr = basic_parse_expr(retline->content);*/
|
||||
expr = basic_parse_expr("1 + 1");
|
||||
expr = basic_parse_expr("1 + 1", 0);
|
||||
if ( expr == NULL ) return 7;
|
||||
if ( expr->lval_type != BASIC_LVAL_CONST_INT ) return 8;
|
||||
if ( expr->rval_type != BASIC_RVAL_CONST_INT ) return 9;
|
||||
@@ -33,7 +19,7 @@ int main(void)
|
||||
if ( expr->type != BASIC_OPTP_ADD ) return 12;
|
||||
|
||||
line = "REM This is a comment that gets ignored";
|
||||
expr = basic_parse_expr(line);
|
||||
expr = basic_parse_expr(line, 1);
|
||||
printf("%s\n", line);
|
||||
printf("token = %s\n", tokenizer_token());
|
||||
printf("errno = %d\n", basic_errno);
|
||||
@@ -43,7 +29,7 @@ int main(void)
|
||||
if ( expr->lval.cmd_ptr != &basic_cmd_rem ) return 16;
|
||||
|
||||
line = "PRINT 10";
|
||||
expr = basic_parse_expr(line);
|
||||
expr = basic_parse_expr(line, 1);
|
||||
printf("%s\n", line);
|
||||
printf("token = %s\n", tokenizer_token());
|
||||
printf("errno = %d\n", basic_errno);
|
||||
@@ -57,7 +43,7 @@ int main(void)
|
||||
if ( strcmp((char *)expr->rval.ptr, " 10") != 0 ) return 23;
|
||||
|
||||
line = " 10"; /* ... continuing logic from the previous */
|
||||
expr = basic_parse_expr(line);
|
||||
expr = basic_parse_expr(line, 0);
|
||||
printf("%s\n", line);
|
||||
printf("token = %s\n", tokenizer_token());
|
||||
printf("errno = %d\n", basic_errno);
|
||||
@@ -68,14 +54,25 @@ int main(void)
|
||||
if ( expr->lval_type != BASIC_LVAL_CONST_INT ) return 26;
|
||||
if ( expr->lval.i != 10 ) return 27;
|
||||
|
||||
/* Store a line */
|
||||
expr = basic_parse_expr("10 REM ignore me", 1);
|
||||
if ( expr == NULL ) return 28;
|
||||
if ( expr->lval_type != BASIC_LVAL_CONST_INT ) return 29;
|
||||
if ( expr->rval_type != BASIC_RVAL_PTR ) return 30;
|
||||
if ( expr->lval.i != 10 ) return 31;
|
||||
if ( expr->rval.ptr == NULL ) return 32;
|
||||
if ( strcmp(expr->rval.ptr, " REM ignore me") != 0 ) return 33;
|
||||
if ( expr->type != BASIC_OPTP_STOR ) return 34;
|
||||
|
||||
/* Immediate mode commands should set basic_errno when line numbers are requested */
|
||||
line = "PRINT 10";
|
||||
expr = basic_parse_expr(line, 1);
|
||||
printf("%s\n", line);
|
||||
printf("token = %s\n", tokenizer_token());
|
||||
printf("errno = %d\n", basic_errno);
|
||||
printf("rval.ptr = '%s'\n", (char *)expr->rval.ptr);
|
||||
if ( expr == NULL ) return 34;
|
||||
if ( basic_errno != BASIC_ERR_SYNTAX_NO_LINE_NUMBER ) return 36;
|
||||
|
||||
/*
|
||||
arrayline = &basic_memory_lines[0];
|
||||
if ( retline != arrayline) return 13;
|
||||
printf("Line 10 in memory is %d : %s (%p)\n", arrayline->lineno, (char *)&arrayline->content, (void *)arrayline->nextline);
|
||||
if ( arrayline->lineno != 10 ) return 14;
|
||||
if ( strcmp((char *)&arrayline->content, "=1 + 1") != 0) return 15;
|
||||
if ( arrayline->nextline != NULL ) return 16;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user