feat: abstract I/O and strings for freestanding compilation
Co-authored-by: aider (openrouter/moonshotai/kimi-k2.6) <aider@aider.chat>
This commit is contained in:
+4
-4
@@ -309,7 +309,7 @@ void do_zero_gt(Word* w) {
|
||||
void do_dot(Word* w) {
|
||||
(void)w;
|
||||
if (data_sp < 0) return;
|
||||
forth_printf("%" PRId64 " ", data_pop());
|
||||
forth_printf("%lld ", (long long)data_pop());
|
||||
forth_fflush();
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ void do_emit(Word* w) {
|
||||
void do_key(Word* w) {
|
||||
(void)w;
|
||||
int c = forth_getchar();
|
||||
data_push(c == EOF ? -1 : c);
|
||||
data_push(c == FORTH_EOF ? -1 : c);
|
||||
}
|
||||
|
||||
void do_dot_quote(Word* w) {
|
||||
@@ -337,7 +337,7 @@ void do_dot_quote(Word* w) {
|
||||
if (state == 0) {
|
||||
// Interpret mode: print immediately
|
||||
if (input_ptr == NULL) { forth_printf("Missing string\n"); return; }
|
||||
while (*input_ptr && isspace((unsigned char)*input_ptr)) input_ptr++;
|
||||
while (*input_ptr && forth_isspace((unsigned char)*input_ptr)) input_ptr++;
|
||||
if (*input_ptr != '"') { forth_printf("Expected \" to start string\n"); return; }
|
||||
input_ptr++;
|
||||
char* start = input_ptr;
|
||||
@@ -349,7 +349,7 @@ void do_dot_quote(Word* w) {
|
||||
} else {
|
||||
// Compile mode: compile string for runtime
|
||||
if (input_ptr == NULL) { forth_printf("Missing string\n"); return; }
|
||||
while (*input_ptr && isspace((unsigned char)*input_ptr)) input_ptr++;
|
||||
while (*input_ptr && forth_isspace((unsigned char)*input_ptr)) input_ptr++;
|
||||
if (*input_ptr != '"') { forth_printf("Expected \" to start string\n"); return; }
|
||||
input_ptr++;
|
||||
char* start = input_ptr;
|
||||
|
||||
Reference in New Issue
Block a user