Skip to content

Commit 4b9a2d3

Browse files
committed
forth: add README and add to config.json
1 parent 575a944 commit 4b9a2d3

5 files changed

Lines changed: 64 additions & 0 deletions

File tree

config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,17 @@
834834
"mathematics"
835835
]
836836
},
837+
{
838+
"uuid": "e348a307-078c-5280-65af-a159283d4e79438b755",
839+
"slug": "forth",
840+
"core": false,
841+
"unlocked_by": null,
842+
"difficulty": 10,
843+
"topics": [
844+
"Parsing",
845+
"Stacks"
846+
]
847+
}
837848
{
838849
"uuid": "e7351e8e-d3ff-4621-b818-cd55cf05bffd",
839850
"slug": "accumulate",

exercises/forth/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.

exercises/forth/example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def evaluate(input):
2+
pass

exercises/forth/forth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def evaluate(input):
2+
pass

exercises/forth/forth_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import unittest
2+
3+
from forth import evaluate
4+
5+
class ForthTest(unittest.TestCase):
6+
pass

0 commit comments

Comments
 (0)