Skip to content

legokichi/pebble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pebble

  • Pebble is a dialect of Lisp, and translated to CoffeeScript.

Demo

def/fn

;(def name val)
;(fn param body)

(def square (fn [x] (* x x)))

(square 4)

((fn [x] (* x x)) 4)

(.map [0 1 2] #(- _0 1))
(.map [0 1 2] (fn [_0 _1 _2 _3 _4 _5] (- _0 1)))

do

;(do & bodys)

(def i 
  (do
    (console.log i)
    (+ i 1)))

if

;(if & clauses)

(if true  "alway"
    false "never"
    false "and more"
    "default")

loop/recur

;(loop name? bindings body)

(loop [i 0]
  (if (> i 10) i
    (recur
      (do
        (console.log i)
        (+ i 1)))))

;nested loop
(loop recur1 [m m]
  ...
  (loop recur2 [n n]
    ...
    (recur1 ...) ...) ...)

throw/try/catch/finally

(try
  (throw "hoge")
  ..
  (catch e ..)
  (finally ..))

Object/Array/PropertyAccess

(def obj {:a 0 :b 1 :c 2 :fn #(_0)})
(def a "a")

(. obj a)
(. obj "a")
(. obj "fn" "hello")

(.fn obj)
(.fn obj "hello")

(:a obj)

(def ary [1 9 8 4])

(. ary 0)
(:1 ary)

(. console log :helloPebble)
(.log console :helloPebble)

Macro

(defmacro when
  ([test] `(alert :Error))
  ([test & more] `(if ,test (do ,@more))))

(when a b c d)

Operators

:
.
new
== !=
> >= < <=
+ - * / %
& | ^ ~ << >> >>>
and or not ?
of typeof instanceof delete

Embedded CoffeeScript/JavaScript

(.log console
  ((coffee "
    do ->
      title = document.title
      `function(script){
        return [title, 'Hello ' + script].join(': ');
      }`
   ") 
   "CoffeeScript/JavaScript"))

Dependence

License

Creative Commons CC BY-SA 3.0

Copyright © 2013 Legokichi Duckscallion

Author

Legokichi Duckscallion

About

Pebble is a dialect of the Lisp programming language, as the interpreter written in CoffeeScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published