Permalink
Browse files

initial import from dude dir

  • Loading branch information...
1 parent 70f6974 commit b27c902450ea2c10bc678c79a1da0280ecd41b2a @malgorithms committed Jun 20, 2012
Showing with 1,512 additions and 0 deletions.
  1. +50 −0 Cakefile
  2. +653 −0 dude.js
  3. 0 index.iced
  4. +6 −0 index.js
  5. +76 −0 lang/dude.jison
  6. 0 lib/README.md
  7. +405 −0 lib/dude_lang.js
  8. +192 −0 lib/engine.js
  9. +6 −0 lib/foo.js
  10. 0 package.iced
  11. +124 −0 src/engine.iced
  12. 0 src/foo.iced
View
@@ -0,0 +1,50 @@
+{spawn, exec} = require 'child_process'
+fs = require 'fs'
+jison = require 'jison'
+stitch = require 'stitch'
+
+task 'build', 'build the whole jam', (cb) ->
+ console.log "Building"
+ files = fs.readdirSync 'src'
+ files = ('src/' + file for file in files when file.match(/\.iced$/))
+ clearLibJs ->
+ buildParser ->
+ runIced ['-I', 'inline', '-c', '-o', 'lib/'].concat(files), ->
+ runIced ['-I', 'none', '-c', 'index.iced'], ->
+ runIced ['package.iced'], ->
+ stitchIt ->
+ console.log "Done building."
+ cb() if typeof cb is 'function'
+
+runIced = (args, cb) ->
+ proc = spawn 'iced', args
+ console.log args
+ proc.stderr.on 'data', (buffer) -> console.log buffer.toString()
+ proc.on 'exit', (status) ->
+ process.exit(1) if status != 0
+ cb() if typeof cb is 'function'
+
+stitchIt = (cb) ->
+ s = stitch.createPackage { paths: ['lib'] }
+ s.compile (err, source) ->
+ fs.writeFile 'dude.js', source, (err) ->
+ if err then throw err
+ console.log "Stitched."
+ cb()
+
+clearLibJs = (cb) ->
+ files = fs.readdirSync 'lib'
+ files = ("lib/#{file}" for file in files when file.match(/\.js$/))
+ fs.unlinkSync f for f in files
+ cb()
+
+buildParser = (cb) ->
+ grammar = fs.readFileSync './lang/dude.jison', 'utf8'
+ generator = new jison.Generator grammar
+ file_name = "dude_lang.js"
+ source = generator.generate {
+ moduleType: 'commonjs'
+ moduleName: 'dude_lang'
+ }
+ fs.writeFileSync "./lib/#{file_name}", source
+ cb()
Oops, something went wrong.

0 comments on commit b27c902

Please sign in to comment.