All Projects → daynin → Tiny Lisp

daynin / Tiny Lisp

Licence: mit
A tiny lisp compiler written in JS

Programming Languages

javascript
184084 projects - #8 most used programming language
language
365 projects
lisp
113 projects

Projects that are alternatives of or similar to Tiny Lisp

Enso
Hybrid visual and textual functional programming.
Stars: ✭ 5,238 (+8931.03%)
Mutual labels:  compiler, interpreter
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+875.86%)
Mutual labels:  compiler, interpreter
Ph7
An Embedded Implementation of PHP (C Library)
Stars: ✭ 422 (+627.59%)
Mutual labels:  compiler, interpreter
Mir
A light-weight JIT compiler based on MIR (Medium Internal Representation)
Stars: ✭ 1,075 (+1753.45%)
Mutual labels:  compiler, interpreter
Rascal
A simple Pascal interpreter written in rust.
Stars: ✭ 38 (-34.48%)
Mutual labels:  compiler, interpreter
V8
The official mirror of the V8 Git repository
Stars: ✭ 18,808 (+32327.59%)
Mutual labels:  compiler, interpreter
Red
Red is a next-generation programming language strongly inspired by Rebol, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting and cross-platform reactive GUI, while providing modern support for concurrency, all in a zero-install, zero-config, single 1MB file!
Stars: ✭ 4,725 (+8046.55%)
Mutual labels:  compiler, interpreter
Lbforth
Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
Stars: ✭ 293 (+405.17%)
Mutual labels:  compiler, interpreter
Cfl
a Compileable statically typed Functional programming Language
Stars: ✭ 7 (-87.93%)
Mutual labels:  compiler, interpreter
Bic
A C interpreter and API explorer.
Stars: ✭ 719 (+1139.66%)
Mutual labels:  compiler, interpreter
Craftinginterpreters
Repository for the book "Crafting Interpreters"
Stars: ✭ 4,298 (+7310.34%)
Mutual labels:  compiler, interpreter
U6a
Implementation of Unlambda, an esoteric programming language.
Stars: ✭ 46 (-20.69%)
Mutual labels:  compiler, interpreter
Umka Lang
Umka: a statically typed embeddable scripting language
Stars: ✭ 308 (+431.03%)
Mutual labels:  compiler, interpreter
Passerine
A small extensible programming language designed for concise expression with little code.
Stars: ✭ 341 (+487.93%)
Mutual labels:  compiler, interpreter
Enso Archive
Looking for Enso, the visual programming language? ➡️ https://github.com/enso-org/enso
Stars: ✭ 305 (+425.86%)
Mutual labels:  compiler, interpreter
Renjin
JVM-based interpreter for the R language for the statistical analysis.
Stars: ✭ 466 (+703.45%)
Mutual labels:  compiler, interpreter
Openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,802 (+4731.03%)
Mutual labels:  compiler, interpreter
Rascal
The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
Stars: ✭ 284 (+389.66%)
Mutual labels:  compiler, interpreter
Tiny Compiler
A tiny evaluator and compiler of arithmetic expressions.
Stars: ✭ 680 (+1072.41%)
Mutual labels:  compiler, interpreter
Antlr4 Calculator
Simple antlr4 calculator.
Stars: ✭ 40 (-31.03%)
Mutual labels:  compiler, interpreter

npm npm npm Build Status

Tiny Lisp

This is a small and simple but very powerful lisp written in JavaScript and Jison. Of course, it's not a serious language for solving production problems, but if you want to understand how to write your own programming language (or another formal language), you're always welcome to use or contribute to this language.

What this language can do?

See a video and examples below to understand how much features already developed in this language.

asciicast

Simple operations
(+ 1 2) 
; 3

(* 2 2 2) 
; 8

(/ 4 2) 
; 2

(- 5 3) 
; 2

(+ (* 2 2) (/ 30 5)) 
; 10

(+ "Hello, " "world" "!") 
; Hello, world!
Definitions
(def a 10)
(a) 
; 10

(def (sum a b) (+ a b))
(sum 10 20) 
; 30
"set!" function for mutating variables
(def a 10)
(set! a 20)

(a) 
; 20
"do" function for sequential expressions execution. It always returns a result of the last expression
(do (+ 1 2)
    (* 2 2)
    (/ 15 5)) 
; 3
Conditions
(if (< 10 20)
    true
    false) 
; true
Loops
(def n 0)

; it'll print each state of the "n" variable
(while (< n 10)
  (do (set! n (+ n 1))
      (print (+ "N is " n " now"))))
Lists
(def l1 (list 1 2 3 4))

; and shor version of a list definition
(def l2 `(1 2 3 4))

; of course, lists can contain any type of a value
(def (sum a b) (+ a b))

(def l3 `(1, "hello", sum))
Lambdas
; returns a function
(fn (x) (* x x)) 

(def sqrt (fn (x) (* x x)))
(sqrt 4)
; 16
Functions for working with lists
(def l `(1 2 3 4))

(map (fn (x) (* x x)) l) 
; [1, 4, 9, 16]

(filter (fn (x) (> x 2)) l) 
; [3, 4]

(reduce (fn (a b) (+ a b)) l) 
; 10

(conj l 5) 
; [1, 2, 3, 4, 5]

(nth l 2) 
; 3
let
(let ((a 1) (b 1))
  (let ((c (* a b)))
    c))
; 1
Fibonacci example
(def (fib n)
    (if (<= n 1)
        n
        (+ (fib (- n 1))
           (fib (- n 2)))))

(def n 0)

(while (< n 15)
       (do (set! n (+ n 1))
           (print (+ n " Fibonacci number is " (fib n)))))

Installation

npm i -g tiny-lisp

Usage

Repl mode:

tiny-lisp

Execute file:

tiny-lisp prog.tl

Goals

  • Develop modules system;
  • Extend standard library;
  • Improve performance;
  • Develop interoperability with JS;

I need your help :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].