Added basic PRINT and REM commands. Added solver tests which had been around for a while and not committed. All execution is still immediate mode.
29 lines
770 B
C
29 lines
770 B
C
#include "basic.h"
|
|
#include "stdlib.h"
|
|
#include "string.h"
|
|
#include <stdio.h>
|
|
|
|
char *_tokenize(char *ptr, char *token);
|
|
|
|
#define assert_token_value(str, val, ret_null, ret_neq) \
|
|
ptr = _tokenize(str, BASIC_TOKENIZER_TOKENS); \
|
|
value = tokenizer_token(); \
|
|
if ( ptr == NULL ) return ret_null; \
|
|
rc = strcmp(value, val); \
|
|
printf("(%s) => (value) == (val) ? : (%s) == (%s) %d\n", str, value, val, rc); \
|
|
if ( rc != 0 ) return ret_neq;
|
|
|
|
|
|
int main(void)
|
|
{
|
|
char *ptr = NULL;
|
|
char *value = NULL;
|
|
int rc = 0;
|
|
|
|
assert_token_value("1+1", "1", 1, 2);
|
|
assert_token_value("1 + 1", "1", 2, 3);
|
|
assert_token_value("10 + 10", "10", 4, 5);
|
|
assert_token_value("1+ 2", "1", 6, 7)
|
|
assert_token_value("+ 2", "+", 8, 9)
|
|
return 0;
|
|
} |