|
| 1 | +# Forth |
| 2 | + |
| 3 | +Implement an evaluator for a very simple subset of Forth. |
| 4 | + |
| 5 | +[Forth](https://en.wikipedia.org/wiki/Forth_%28programming_language%29) |
| 6 | +is a stack-based programming language. Implement a very basic evaluator |
| 7 | +for a small subset of Forth. |
| 8 | + |
| 9 | +Your evaluator has to support the following words: |
| 10 | + |
| 11 | +- `+`, `-`, `*`, `/` (integer arithmetic) |
| 12 | +- `DUP`, `DROP`, `SWAP`, `OVER` (stack manipulation) |
| 13 | + |
| 14 | +Your evaluator also has to support defining new words using the |
| 15 | +customary syntax: `: word-name definition ;`. |
| 16 | + |
| 17 | +To keep things simple the only data type you need to support is signed |
| 18 | +integers of at least 16 bits size. |
| 19 | + |
| 20 | +You should use the following rules for the syntax: a number is a |
| 21 | +sequence of one or more (ASCII) digits, a word is a sequence of one or |
| 22 | +more letters, digits, symbols or punctuation that is not a number. |
| 23 | +(Forth probably uses slightly different rules, but this is close |
| 24 | +enough.) |
| 25 | + |
| 26 | +Words are case-insensitive. |
| 27 | + |
| 28 | +## Hints |
| 29 | +- To parse the text, you could try to use the [Sprache](https://github.com/sprache/Sprache/blob/develop/README.md) library. You can also find a good tutorial [here](https://www.thomaslevesque.com/2017/02/23/easy-text-parsing-in-c-with-sprache/). |
| 30 | + |
| 31 | + |
| 32 | +### Submitting Exercises |
| 33 | + |
| 34 | +Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory. |
| 35 | + |
| 36 | +For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`. |
| 37 | + |
| 38 | + |
| 39 | +For more detailed information about running tests, code style and linting, |
| 40 | +please see the [help page](http://exercism.io/languages/python). |
| 41 | + |
| 42 | +## Submitting Incomplete Solutions |
| 43 | +It's possible to submit an incomplete solution so you can see how others have completed the exercise. |
0 commit comments