word flags, add immediate flag and remove special case for ;
This commit is contained in:
parent
e111afb040
commit
7028ee4369
1 changed files with 7 additions and 3 deletions
10
pila.c
10
pila.c
|
@ -12,6 +12,7 @@
|
|||
#define BOX_STR(n) (Value){.kind = VAL_STR, .str = n}
|
||||
#define PILA_TRUE ((u64)1)
|
||||
#define PILA_FALSE ((u64)0)
|
||||
#define WRDF_IMMEDIATE (1 << 2)
|
||||
|
||||
typedef struct UserWord UserWord;
|
||||
typedef struct Word Word;
|
||||
|
@ -50,6 +51,7 @@ struct UserWord {
|
|||
|
||||
struct Word {
|
||||
Str name;
|
||||
u8 flags;
|
||||
WordKind kind;
|
||||
union {
|
||||
NativeWord nat;
|
||||
|
@ -644,8 +646,8 @@ eval(RpnState *st, Str src)
|
|||
if (!st->compiling)
|
||||
eval_word(st, w);
|
||||
else {
|
||||
if (w->kind == WORD_NATIVE && w->nat == compile_end_nat) {
|
||||
w->nat(st);
|
||||
if (w->flags & WRDF_IMMEDIATE) {
|
||||
eval_word(st, w);
|
||||
} else {
|
||||
st->cur_compw->uword.words[st->cur_compw->uword.len++] = w;
|
||||
}
|
||||
|
@ -689,7 +691,9 @@ main(int argc, char **argv)
|
|||
{.name = Sl("!"), .kind = WORD_NATIVE, .nat = not_nat },
|
||||
{.name = Sl(":"), .kind = WORD_NATIVE, .nat = compile_start_nat },
|
||||
{.name = Sl(":?"), .kind = WORD_NATIVE, .nat = compile_anon_start_nat },
|
||||
{.name = Sl(";"), .kind = WORD_NATIVE, .nat = compile_end_nat },
|
||||
{ .name = Sl(";"), .flags = WRDF_IMMEDIATE,
|
||||
.kind = WORD_NATIVE, .nat = compile_end_nat
|
||||
},
|
||||
{.name = Sl("'"), .kind = WORD_NATIVE, .nat = tick_nat },
|
||||
{.name = Sl(">#"), .kind = WORD_NATIVE, .nat = to_number_nat },
|
||||
{.name = Sl("parse-word"), .kind = WORD_NATIVE, .nat = parse_word_nat },
|
||||
|
|
Loading…
Add table
Reference in a new issue