Skip to content

aboekhoff/jsasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsasm

A Clojure tool for emitting JS

Usage

'jsasm.ast/emit-tokens takes a sequence of tokens and returns
a javascript string.

The syntax of the ast is as follows:

token    = lit | array | object | project | call | function |        
           if | while | enum | throw | try | operator |      
           var | return | break    
tokens   = [token*]    
lit      = [:LIT (symbol | number | string)]     
array    = [:ARRAY tokens]     
entry    = [:ENTRY token token]               ; foo : bar    
entries  = [entry*]    
object   = [:OBJECT entries]                  ; { foo : bar, ... }    
function = [:FUNCTION tokens tokens]          ; function ( ... ) { ... }     
project  = [:PROJECT token token]             ; foo[bar]    
call     = [:CALL tokens]                     ; foo(...) { ... }    
if       = [:IF token tokens tokens?]    
while    = [:WHILE token tokens]                  
enum     = [:ENUM token token tokens]    
    
throw    = [:THROW token]    
catch    = [:CATCH token tokens]             
finally  = [:FINALLY tokens]    
try      = [:TRY tokens catch finally?]    
    
operator = [:OPERATOR symbol [token+]] ; =, +, <, ==    
var      = [:VAR tokens]    
return   = [:RETURN token]    
break    = [:BREAK]    

Some helpers for creating tokens live in jsasm.ast.

The ast is awkward to write by hand, but is a convenient compile target. For an example of a simple compiler with clojure-like syntax
that uses jsasm as a backend see Calliope.

Installation

[jsasm "1.0.0-SNAPSHOT"]

License

Copyright (C) 2010 Andrew Boekhoff

Distributed under the Eclipse Public License, the same as Clojure.

About

small toolkit for emitting javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published