diff --git a/alee.cpp b/alee.cpp index 633b8d7..1be7337 100644 --- a/alee.cpp +++ b/alee.cpp @@ -157,6 +157,7 @@ void parseLine(Parser& parser, State& state, const std::string& line) while (state.rsize()) state.popr(); state.dict.write(Dictionary::Compiling, 0); + state.ip = 0; } } diff --git a/compat.txt b/compat.txt index 189cfb7..890871a 100644 --- a/compat.txt +++ b/compat.txt @@ -150,13 +150,13 @@ yes 6.2.0698 ACTION-OF yes 6.2.0700 AGAIN yes 6.2.0825 BUFFER: yes 6.2.0855 C" - 6.2.0873 CASE +yes 6.2.0873 CASE yes 6.2.0945 COMPILE, yes 6.2.1173 DEFER yes 6.2.1175 DEFER! yes 6.2.1177 DEFER@ - 6.2.1342 ENDCASE - 6.2.1343 ENDOF +yes 6.2.1342 ENDCASE +yes 6.2.1343 ENDOF yes 6.2.1350 ERASE yes 6.2.1485 FALSE yes 6.2.1660 HEX @@ -164,7 +164,7 @@ yes 6.2.1660 HEX yes 6.2.1725 IS yes 6.2.1850 MARKER yes 6.2.1930 NIP - 6.2.1950 OF +yes 6.2.1950 OF 6.2.2000 PAD 6.2.2008 PARSE 6.2.2020 PARSE-NAME diff --git a/core.fth b/core.fth index fd073a8..c5b80b6 100644 --- a/core.fth +++ b/core.fth @@ -236,3 +236,9 @@ : evaluate _source @ >r _sourceu @ >r >in @ >r 0 >in ! _sourceu ! _source ! 5 sys r> >in ! r> _sourceu ! r> _source ! ; + +: case ['] _lit , 1 here 0 , ['] drop , ; imm +: of ['] over , ['] = , postpone if ; imm +: endof ['] _jmp , here >r 0 , postpone then + swap 1+ swap r> tuck ! ; imm +: endcase swap 0 do dup @ swap here swap ! loop drop ['] drop , ; imm diff --git a/dictionary.hpp b/dictionary.hpp index 235bd78..4dcae77 100644 --- a/dictionary.hpp +++ b/dictionary.hpp @@ -24,6 +24,17 @@ #include #include +/** + * Dictionary entry format: + * - 1 information byte + * bits 0..4: Length of name (L) + * bit 5: Immediate? + * bits 6..15: Distance to next entry (negative) + * - L bytes of name + * - 0+ bytes for address alignment + * - 0+ bytes of entry's data... + */ + class Dictionary { public: @@ -34,7 +45,7 @@ public: constexpr static Addr Source = sizeof(Cell) * 4; constexpr static Addr SourceLen = sizeof(Cell) * 5; constexpr static Addr Input = sizeof(Cell) * 6; // len data... - constexpr static Addr InputCells = 82; // bytes! + constexpr static Addr InputCells = 80; // bytes! constexpr static Addr Begin = sizeof(Cell) * 7 + InputCells; void initialize();