- 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

19
tests/string_chomp.c Normal file
View File

@@ -0,0 +1,19 @@
#include "string.h"
#include "stdlib.h"
#include <stdio.h>
#define assert_strip(method, str, strip, count, rvalue, ret_strcmp, ret_count) \
memset((char *)&buff, 0x00, 32); \
rc = method(str, (char *)&buff, strip); \
printf("method(%s) => (%d, %s)\n", str, rc, (char *)&buff); \
if ( rc != count) return ret_count; \
if ( strcmp((char *)&buff, rvalue) != 0 ) return ret_strcmp;
int main(void)
{
char buff[32];
int rc = 0;
assert_strip(lstrip, " white space", " ", 3, "white space", 1, 2)
assert_strip(rstrip, "white space ", " ", 3, "white space", 3, 4)
return 0;
}