mirror of
https://github.com/adamdunkels/ubasic.git
synced 2026-11-20 11:39:43 +00:00
Implemented comments with REM.
This commit is contained in:
parent
ea7a52e61f
commit
9c45ed4588
3 changed files with 19 additions and 4 deletions
9
tests.c
9
tests.c
|
|
@ -34,6 +34,10 @@
|
|||
#include <assert.h>
|
||||
#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";
|
||||
|
||||
|
|
|
|||
13
tokenizer.c
13
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ enum {
|
|||
TOKENIZER_GOSUB,
|
||||
TOKENIZER_RETURN,
|
||||
TOKENIZER_CALL,
|
||||
TOKENIZER_REM,
|
||||
TOKENIZER_END,
|
||||
TOKENIZER_COMMA,
|
||||
TOKENIZER_SEMICOLON,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue