- All tests passing
- Updated README and image - Added itoa to stdlib - Implemented modulus math for bcc which has none in the stdlib - Updated the build scripts to work on Ubuntu 22 - Added bochsrc with some useful overrides (new bochs bios in ubuntu is broken, use the legacy) - Made most of stdlib compile and run under GNU C for testing - Improved the tokenizer so it will return tokens of more than one character - Moved the basic parser from using void pointers to store values to using basic_value unions to represent possible types - Added tests for the basic tokenizer
This commit is contained in:
29
tests/basic_tokenizer.c
Normal file
29
tests/basic_tokenizer.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "basic.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include <stdio.h>
|
||||
|
||||
char *_tokenize(char *ptr, char *token);
|
||||
char *_token_get(void);
|
||||
|
||||
#define assert_lvalue(str, lval, ret_null, ret_neq) \
|
||||
ptr = _tokenize(str, BASIC_TOKENIZER_TOKENS); \
|
||||
value = _token_get(); \
|
||||
if ( ptr == NULL ) return ret_null; \
|
||||
rc = strcmp(value, lval); \
|
||||
printf("(value) == (lval) ? : (%s) == (%s) %d\n", value, lval, rc); \
|
||||
if ( rc != 0 ) return ret_neq;
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
char *value = NULL;
|
||||
int rc = 0;
|
||||
|
||||
assert_lvalue("1+1", "1", 1, 2);
|
||||
assert_lvalue("1 + 1", "1", 2, 3);
|
||||
assert_lvalue("10 + 10", "10", 4, 5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user