This is the final project of Haskell@Tsinghua.
In this project, we are asked to implement a code parser with specific given grammar using Haskell language.
This project is managed with Stack, a cross-platform program for developing Haskell projects.
To build the project, go to src directory and run:
$ stack build
Usage:
-
sh $ stack exec haskell-parser -- -i <file> -o <file>
parse and execute the code from input file and output the results to another file
-
sh $ stack exec haskell-parser -- -i <file>
parse and execute the code from input file and output the results to stdout
-
sh $ stack exec haskell-parser -- -t <file> -o <file>
parse and the code from input file and output the abstract syntax tree (AST) to another file
-
sh $ stack exec haskell-parser -- -t <file>
parse and the code from input file and output the AST to stdout
Usage:
To enter REPL mode, run:
$ stack exec haskell-parser -- -repl
In REPL mode, there are three commands:
sh > :q
quitsh > :i <file-name>
load and parse the program in the file and output the resultssh > :t
print the AST of the last program
Otherwise, any string input with 'Enter' will be regarded as a part of code (expression, statement, whatever) and executed.
For now, it supports some data type (Boolean
, Floating-point Number
, Char
, String
, List
) and some control logics from imperative programming (like assignment
, if-else
, while-skip
, begin
)