Skip to content

Modern Lisp Interpreter: Utilizes C++17 features and is implemented in 400 lines of code

License

Notifications You must be signed in to change notification settings

cliffxzx/mini-lisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini Lisp

Introduction

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.

The Spec file, Grammar

No. Name Description Complete
1. Syntax Validation Print “syntax error” when parsing invalid syntax
2. Print 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

Getting Start

make && ./mini_lisp -r

Testing Environment

  • 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

Problems Encountered

What is the best way of preventing memory leaks in a yacc-based parser?

Are GCC and Clang parsers really handwritten?

C++ using declaration recursive

variant

Bison variant

About

Modern Lisp Interpreter: Utilizes C++17 features and is implemented in 400 lines of code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published