Familiarizing with Haskell language using 'cabal' package builder manager
Follwoing features have been added to FORTH interpreter
- The code has been changed in
Main.hsso that, if the stack is not empty at the end of execution, a message gets printed on the screen stating that stack is not empty and the stack content. - Following functionalities have been added to
Eval.hsand corresponding unit tests have been writen underEvalSpec.hs
EMIT: takes a number from the stack and prints the character with the corresponding ASCI codeCR: prints a new line (for nice formating)STR: converts the argument into a string (needs to work for all types)CONCAT2andCONCAT3concatenates 2 or 3 strings from the stack (errors if arguments not strings)
- Fuctional tests have been written in the test folder and the expected output has been written in .out file.
User-defined functions have been implemented, with t11.4th and t12.4th files corresponding to their respective tests.
To build the project, use the following command:
cabal build
After building, you can run the unit tests with:
runhaskell EvalSpec.hs
Finally, to execute individual test cases, use the following command:
path\FORTH.exe tests/t1.4TH
Note that there are 12 test cases covering the main functionalities developed
- GHC Version Compatibility & Cross-Platform Build Issues: Initially, when I tried building the given project on macOS, I couldn't find a compatible GHC version. Therefore, I had to switch to a different operating system that the project supports in order to proceed.
- Lazy Evaluation Complexity: Grasping Haskell's lazy evaluation model was challenging, especially since precise control over execution order and stack operations is essential in a Forth interpreter.