This 400+ lines lisp interpreter heavily utilizes STL and C++/17 trait to implement. You can access the original Python implementation here. Aside from pure C++ implementation, the tokenize and parser implemented by Lex and Bison(yacc) is included in this branch.
No. | Name | Description | Complete |
---|---|---|---|
1. | Syntax Validation | Print “syntax error” when parsing invalid syntax | ✅ |
2. | Implement print-num statement | ✅ | |
3. | Numerical Operations | Implement all numerical operations | ✅ |
4. | Logical Operations | Implement all logical operations | ✅ |
5. | if Expression |
Implement if expression |
✅ |
6. | Variable Definition | Able to define a variable | ✅ |
7. | Function | Able to declare and call an anonymous function | ✅ |
8. | Named Function | Able to declare and call a named function | ✅ |
9. | Recursion | Support recursive function call | ✅ |
10. | Type Checking | Print error messages for type errors | ✅ |
11. | Nested Function | Nested function (static scope) | ✅ |
12. | First-class Function | Able to pass functions, support closure | ✅ |
make && ./mini_lisp -r
- OS: macOS 11.5.2 (Darwin Kernel Version 20.6.0)
- Device: MacBookPro14,1
- Compiler: clang 13.0.0
- Compile flags:
-Wno-register -O0 -g -Wall -std=c++20