diff options
Diffstat (limited to 'interpret.e')
| -rw-r--r-- | interpret.e | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/interpret.e b/interpret.e index 5941d15..24ea430 100644 --- a/interpret.e +++ b/interpret.e @@ -402,7 +402,8 @@ latest @ ~ If the ] at the end feels backwards, imagine to yourself that everything ~ that ISN'T defining a word body is part of an implicit [ ... ] sequence. ~ Doing so doesn't really change anything, but may make you happier. -: : word value@ create dropstring docol , make-hidden ] ; +: : word value@ create dropstring docol , make-hidden + [ dup entry-to-execution-token , ] ; ~ The counterpart of : is ;. : ; @@ -417,6 +418,7 @@ latest @ ~ so we do that by hand as well. [ over entry-to-execution-token , ] ; make-immediate make-hidden +latest @ ~ (pointer to [ entry, pointer to ] entry, pointer to ; entry) @@ -446,7 +448,38 @@ latest @ ~ "if". Fortunately flow-control is done with alternates by the log-load ~ transform, so we don't have to worry about it. : ' word value@ find dropstring-with-result - interpreter-flags @ 1 & { literal } if + interpreter-flags @ 0x01 & { literal } if + ; make-immediate + + +~ Let's have strings now. +: s" + consume + interpreter-flags @ 0x01 & { + [ s" litstring" find literal ] + entry-to-execution-token , + } if + here @ key { dup dup 0x22 != && } { pack8 key } while + drop 0 pack8 + interpreter-flags @ 0x01 & + { 8 packalign here ! } + { drop here @ } if-else + ; make-immediate + + +~ Finicky semantics, but also important. +: ." + ' s" entry-to-execution-token execute + interpreter-flags @ 1 & + { [ s" emitstring" find literal ] + entry-to-execution-token , } + { emitstring } if-else + ; make-immediate + + +~ While we're thinking about input, let's also have comments. +: ~ + key { dup dup 10 != && } { drop key } while drop ; make-immediate @@ -514,6 +547,7 @@ latest @ dup entry-flags@ 0x80 invert & entry-flags! dup entry-flags@ 0x80 invert & entry-flags! dup entry-flags@ 0x80 invert & entry-flags! +dup entry-flags@ 0x80 invert & entry-flags! ~ Though we only do it once, this is a bit involved so we provide it as a ~ word. Notionally there are situations in which it could come up again, so |