This portion of the project is a relatively small enhancement of the previous portion, where you add functionality for the special form quote. You should build this assignment as an extension of the work that you did for the previous one.
For this phase of the project, you must additionally support the correct evaluation of the following Scheme expression:
(quote expr)
This is equivalent to 'expr, but you only need to be able to handle the version with quote. Feel free to add the 'expr as an optional extra feature if you wish. If you go in this optional direction, you will likely find that this is easier to do by first going back and modifying the parser.
Note that when DrRacket prints a quoted symbol or list, it puts a single quote sign at the beginning of the quote, but not on any symbols inside a quoted list. DrRacket also transforms internal nested quote calls into a single quote sign. You don't need to do any of this capability if you don't wish to, but you can if you like:
$ cat test1 (quote a) (quote (a b c)) (quote (a b (quote (c d e)))) (let ((foo "hello") (bar (quote (foo 5 "hi"))) (baz #f)) (if baz foo bar)) $ ./interpreter < test1 'a '(a b c) '(a b '(c d e)) '(foo 5 "hi")
$ cat test1 (quote a) (quote (a b c)) (quote (a b (quote (c d e)))) $ ./interpreter < test1 a (a b c) (a b (quote (c d e))) (foo 5 "hi")
Do not implement this by trying to somehow wrap up the quoted expression in some sort of enclosure indicating that it is quoted. For example, don't do this by creating a QUOTE_TYPE for a Value or some such. It might help you get this part of the assignment to work, but you'll get into hot water later. This reflects a common and interesting point of confusion: quote does not tell the interpreter to do something to its arguments; rather, it tells the interpreter to not do something.
If you are feeling a strong urge to add something to the parse tree indicating that something is quoted, don't do it. If you are experiencing such compulsions because your tree is not printing properly, past experience has been that the problem is likely in your code for printing your parse tree, not structuring it in the first place.
Your code should have no memory leaks or memory errors when run on any input (correct or incorrect) using valgrind. We will be checking this during grading.
Submit via git as usual, and tag your submission as quote. If you need to resubmit, create another tag with a dot extension, such as quote.1, quote.2, and so on. Make sure that you both push your tags and your code itself, as in:
git tag quote git commit -am "We are done!" git push git push --tags
Add at least two more tests to your test files that test the functionality of quote. Indicate in a readme.txt file which tests are designed to be testing this assignment in particular.
Each pair of files should be named interpreter-test.input.XX and interpreter-test.output.XX, where XX is a test number. It should be the case that if I run the following command then I get no output:./interpreter < interpreter-test.input.XX | diff interpreter-test.output.XX -
When we test your code for grading purposes, we will use our own set of test files which we will run using exactly the same command as described above. Test carefully.
Your code should have no memory leaks or memory errors when run on any input (correct or incorrect) using valgrind. We will be checking this as well during grading.
Remember, you can test your code in valgrind this way:
./valgrind.sh < interpreter-test.input.XX
Have fun interpreting!
This assignment was originally created by David Liben-Nowell and has since been updated by Dave Musicant and Laura Effinger-Dean.