clementi / back

A toy Forth-like language and interpreter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Back

Back is a very basic evaluator for a Forth-like language.

The evaluator supports the following built-in words:

  • +, -, *, / (integer arithmetic)
  • DUP, DROP, SWAP, OVER, CLEAR, . (stack manipulation)
  • >, =, < (integer comparisons)
  • AND, OR, NOT (boolean operators)
  • PRINT, PRINTLN (console output)

The evaluator supports defining new words using the customary syntax: : word-name definition ;.

The only data type that is currently supported is 32-bit signed integers. The integer comparison words evaluate to integers (1 for true, 0 for false).

Words are case-insensitive.

Running the tests

You can run all the tests for an exercise by entering the following in your terminal:

$ gradle test

Use gradlew.bat if you're on Windows.

Running the evaluator

$ gradle jar && java -jar ./build/libs/back.jar

Or you can use the provided script:

$ # *nix Shell
$ ./back
> # PowerShell
> .\back

Origin

Back originated as a solution to the "Forth" exercise at exercism.

About

A toy Forth-like language and interpreter

License:Apache License 2.0


Languages

Language:Java 99.7%Language:Shell 0.2%Language:PowerShell 0.1%