98 FVM_COLON(3, BACKWARD_RESOLVE, "<resolve")
116 #define THEN_CODE FORWARD_RESOLVE_CODE 131 #define BEGIN_CODE BACKWARD_MARK_CODE 152 #define WHILE_CODE IF_CODE 204 const
FVM::code_P
FVM::fntab[] PROGMEM = {
206 FORWARD_RESOLVE_CODE,
208 BACKWARD_RESOLVE_CODE,
223 (
str_P) FORWARD_MARK_PSTR,
224 (
str_P) FORWARD_RESOLVE_PSTR,
225 (
str_P) BACKWARD_MARK_PSTR,
226 (
str_P) BACKWARD_RESOLVE_PSTR,
238 (
str_P) LEFT_BRACKET_PSTR,
239 (
str_P) COMMENT_PSTR,
241 (
str_P) LITERAL_PSTR,
242 (
str_P) SEMICOLON_PSTR,
243 (
str_P) RIGHT_BRACKET_PSTR,
246 (
str_P) VARIABLE_PSTR,
247 (
str_P) CONSTANT_PSTR,
255 #if defined(ARDUINO_ARCH_AVR) 256 const int DATA_MAX = (RAMEND - RAMSTART - 1024);
257 const int DICT_MAX = (RAMEND - RAMSTART) / 64;
259 const int DATA_MAX = 32 * 1024;
260 const int DICT_MAX = 128;
265 FVM fvm(data, DATA_MAX, DICT_MAX);
275 Serial.println(F(
"FVM/Forth V1.1.0: started [Newline]"));
291 val = strtol(buffer, &endptr,
task.m_base == 10 ? 0 :
task.m_base);
292 if (*endptr != 0)
goto error;
310 else if (op == COMMENT) {
311 while (Serial.read() !=
')');
315 else if (!compiling) {
341 Stream& ios =
task.m_ios;
346 while ((s =
fvm.
name(nr)) != 0) {
347 int len = ios.print(s);
351 for (;len < 16; len++) ios.print(
' ');
354 if (nr % 5 != 0) ios.println();
365 if (op >= LEFT_BRACKET && op <= TICK)
goto error;
383 while (!Serial.available());
385 if (c ==
'\"')
break;
398 if (op < SEMICOLON) {
406 if (c ==
'\n' && !compiling) {
408 Serial.println(F(
" ok"));
415 Serial.print(buffer);
416 Serial.println(F(
" ??"));
static const char WORDS_PSTR[]
static const char DOT_QUOTE_PSTR[]
FVM_SYMBOL(15, LEFT_BRACKET,"[")
bool create(const char *name)
static const char LOOP_PSTR[]
FVM::Task< 64, 32 > task(Serial)
bool constant(const char *name, int val)
const char * name(int op)
bool variable(const char *name)
static const char PLUS_LOOP_PSTR[]
static const str_P fnstr[]
int execute(int op, task_t &task)
int lookup(const char *name)
Handle variable reference.
static const char DO_PSTR[]
#define FVM_COLON(id, var, name)
FVM fvm(data, DATA_MAX, DICT_MAX)
Print contents of parameter stack.
int scan(char *bp, task_t &task)
Print program memory string.