Skip to content

embeddable lisp with dynamic typing, expression-level evaluation & direct JVM bytecode serialization

License

Notifications You must be signed in to change notification settings

elricmann/flisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flisp

An embeddable Lisp with dynamic typing and a basic expression-level interpreter.

The alternative backend is a WIP emitter that enables direct JVM bytecode serialization. In this case, forms may either be opcodes or predefined constructs like labels. The bytecode is aligned with class file directives/attributes and validated with javap. Refer to emit.cc.

OpenJDK uses the ASM Java package for working with class files, which is ideal.

Quick overview

Forms represent both structural and semantic constructs, which is what makes lisps more unique than mainstream PL design.

  • def for defining variables (uses std::unordered_map)
  • set as the default assignment form (mutable-by-default)
  • debug is an alias for printing values to std::cout
  • +, -, *, / expressions with left-reduce accumulators
  • if conditional expression (optional else clause)
  • fun declarations for named functions with local context

In the evaluation loop, non-terminals are forward definitions and terminals are recursively evaluated (e.g. forms for binary operations), implying that a def may not be assigned to a def since terminals do not return an expr_value.

Installation & usage

Clone this repository, run make and link with build/libflisp.a. All sources and headers are in src.

A more-detailed overview of flisp's forms can be found at main.lsp.

Missing features

  • Embed callable C++ expressions into the interpreter
  • Skip expression parse tree when serializing to JVM bytecode
  • Introduce static typing (Hindley-Milner) & FP constructs
  • Replace expression-level interpreter with register-based VM
  • Basic macros with recursion & templating/metaprogramming

On a sidenote, flisp is a WIP and not ready for usage at this point.

Resources

About

embeddable lisp with dynamic typing, expression-level evaluation & direct JVM bytecode serialization

Topics

Resources

License

Stars

Watchers

Forks