Get the files
The goal of this part is to get the files and run the executable.
1 Clone the repo
There is nothing to turn in for this lab, so we don’t need to go through GitHub Classroom.
Clone this public repo to your own machine.
2 Run the executable
Try running the main program, which will print the results of evaluating an expression.
The first time you run this command, it may take awhile because stack needs to build the program.
stack run -- "1 + 2"You can write a different arithmetic expression between the quotation marks. Try evaluating a few other expressions! Note that the program supports only addition and multiplication of integers at the moment.
You can also run
The -- after stack run allows us to pass arguments to the main program.
stack run -- --helpto see other options available for the program. Try passing the different flags! For example:
stack run -- -t "1 + 2"3 Look over the files
Some parts of this application will look familiar to you (e.g., the AST and evaluator). Some parts will familiar but still new (e.g., the lexer and parser). Some parts may look new and strange (e.g., the main program and command-line arguments).
Our goal for today is to understand the lexer and parser well enough to modify it. Take a look at those files and make sure you understand them, possibly by referring to the class slides.