diff --git a/tests.c b/tests.c index bc26af6..8425d8f 100644 --- a/tests.c +++ b/tests.c @@ -34,6 +34,10 @@ #include #include "ubasic.h" +static const char program_let[] = +"10 let a = 42\n\ +20 end\n"; + static const char program_loop[] = "10 for i = 0 to 126\n\ 20 for j = 0 to 126\n\ @@ -44,16 +48,13 @@ static const char program_loop[] = 70 next i\n\ 80 end\n"; -static const char program_let[] = -"10 let a = 42\n\ -20 end\n"; - static const char program_fibs[] = "20 let a = 1\n\ 40 let b = 1\n\ 60 for i = 0 to 8\n\ 80 let b = a + b\n\ 100 let a = b - a\n\ +rem 120 print a, b\n\ 140 next i\n\ 160 end\n"; diff --git a/tokenizer.c b/tokenizer.c index 02a5dd5..2c093cd 100644 --- a/tokenizer.c +++ b/tokenizer.c @@ -65,6 +65,7 @@ static const struct keyword_token keywords[] = { {"gosub", TOKENIZER_GOSUB}, {"return", TOKENIZER_RETURN}, {"call", TOKENIZER_CALL}, + {"rem", TOKENIZER_REM}, {"end", TOKENIZER_END}, {NULL, TOKENIZER_ERROR} }; @@ -188,10 +189,22 @@ tokenizer_next(void) DEBUG_PRINTF("tokenizer_next: %p\n", nextptr); ptr = nextptr; + while(*ptr == ' ') { ++ptr; } current_token = get_next_token(); + + if (current_token == TOKENIZER_REM) { + while(!(*nextptr == '\n' || tokenizer_finished())) { + ++nextptr; + } + if (*nextptr == '\n') { + ++nextptr; + } + tokenizer_next(); + } + DEBUG_PRINTF("tokenizer_next: '%s' %d\n", ptr, current_token); return; } diff --git a/tokenizer.h b/tokenizer.h index b038b62..75cfe2e 100644 --- a/tokenizer.h +++ b/tokenizer.h @@ -50,6 +50,7 @@ enum { TOKENIZER_GOSUB, TOKENIZER_RETURN, TOKENIZER_CALL, + TOKENIZER_REM, TOKENIZER_END, TOKENIZER_COMMA, TOKENIZER_SEMICOLON,