- Added string strip methods lstrip and rstrip

- Fixed the tokenizer to chomp whitespace from left and right of tokens
- Fixed the tokenizer so it returns reserved symbols not just constants and expressions
- Added some tests for the basic tokenizer and parser
- Started working on structures to allow the basic interpreter to store lines in memory
This commit is contained in:
2024-05-04 22:08:20 -04:00
parent 0d1ecd9bd3
commit 921a9dd8bd
11 changed files with 159 additions and 36 deletions

16
tests/basic_parser.c Normal file
View File

@@ -0,0 +1,16 @@
#include "types.h"
#include "basic.h"
int main(void)
{
struct basic_expr *expr;
expr = basic_parse_expr("1 + 1");
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;
}