Forth in Rust
Implement an evaluator for a very simple subset of Forth
exercism fetch rust forth
Implement an evaluator for a very simple subset of Forth.
Forth is a stack-based programming language. Implement a very basic evaluator for a small subset of Forth.
Your evaluator has to support the following words:
Your evaluator also has to support defining new words using the
: word-name definition ;.
To keep things simple the only data type you need to support is signed integers of at least 16 bits size.
You should use the following rules for the syntax: a number is a sequence of one or more (ASCII) digits, a word is a sequence of one or more letters, digits, symbols or punctuation that is not a number. (Forth probably uses slightly different rules, but this is close enough.)
Words are case-insensitive.
Refer to the exercism help page for Rust installation and learning resources.
Writing the Code
Execute the tests with:
$ cargo test
All but the first test have been ignored. After you get the first test to
pass, open the tests source file wich is located in the
and remove the
#[ignore] flag from the next test and get the tests to pass
again. Each separate test is a function with
#[test] flag above it.
Continue, until you pass every test.
If you wish to run all tests without editing the tests source file, use:
$ cargo test -- --ignored
To run a specific test, for example
some_test, you can use:
$ cargo test some_test
If the specfic test is ignored use:
$ cargo test some_test -- --ignored
To learn more about Rust tests refer to the online test documentation
Make sure to read the Modules chapter if you haven't already, it will help you with organizing your files.
Feedback, Issues, Pull Requests
The exercism/rust repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
If you want to know more about Exercism, take a look at the contribution guide.
Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.