forked from exercism/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forth: Two tests which have definitions not as the first word in an `…
…eval` (exercism#962) * Two tests which have definitions not as the first word in an `eval` I've seen solutions to this exercise which test if the first character or lexeme in an `eval` call is `:`, handle a definition if it is, and then process the rest of the input as normal operations. I feel like that shouldn't be allowed; a Forth interpreter should be able to handle definitions interleaved with operations and sequences of multiple definitions. * Fix a bug in `forth` where user-defined words were deferred This commit fixes a bug in the definition of `Forth::step_word` where, to evaluate a user-defined word, it appended that word's definition to the end of the current code list, which caused that word's definition to be evaluated only after any remaining code. This commit makes `step_word` corecursive with `step_term`; to evaluate a user-defined word, it repeatedly invokes `step_term` on each of the terms in the definition of that word. This commit also adds calls to `eprintln` on several error cases, so that failing tests will log to standard error when and where they fail.
- Loading branch information
Showing
2 changed files
with
55 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters