- Added the ability to force immediate mode processing (calculator mode) by beginning a line with = - Expanded parser testing - Expression execution seems to be broken now, everything is returning error code 0 and not returning results
29 lines
879 B
C
29 lines
879 B
C
#include "types.h"
|
|
#include "basic.h"
|
|
|
|
|
|
int main(void)
|
|
{
|
|
struct basic_expr *expr;
|
|
struct basic_line *line;
|
|
/* Store a line */
|
|
expr = basic_parse_expr("10 =1 + 1");
|
|
if ( expr == NULL ) return 1;
|
|
if ( expr->lval_type != BASIC_LVAL_CONST ) 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 */
|
|
line = (basic_line *)expr->rval.ptr;
|
|
expr = basic_parse_expr(line->content);
|
|
if ( expr == NULL ) return 1;
|
|
if ( expr->lval_type != BASIC_LVAL_CONST ) return 2;
|
|
if ( expr->rval_type != BASIC_RVAL_CONST ) return 3;
|
|
if ( expr->lval.i != 1 ) return 4;
|
|
if ( expr->rval.i != 1 ) return 5;
|
|
if ( expr->type != BASIC_OPTP_ADD ) return 6;
|
|
|
|
return 0;
|
|
} |