This repository has been archived on 2026-05-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
piquant/tests/basic_parser.c

43 lines
1.4 KiB
C
Raw Normal View History

#include "types.h"
#include "basic.h"
#include "string.h"
#include <stdio.h>
/* extern basic_line basic_memory_lines[BASIC_MAX_LINES]; */
int main(void)
{
struct basic_expr *expr;
/*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 ) 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");
if ( expr == NULL ) return 7;
if ( expr->lval_type != BASIC_LVAL_CONST ) return 8;
if ( expr->rval_type != BASIC_RVAL_CONST ) return 9;
if ( expr->lval.i != 1 ) return 10;
if ( expr->rval.i != 1 ) return 11;
if ( expr->type != BASIC_OPTP_ADD ) return 12;
/*
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;
}