mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
got coffeescript compiling in the browser
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
process.mixin require './nodes'
|
||||
lexer: new (require('./lexer').Lexer)()
|
||||
parser: require('./parser').parser
|
||||
if process?
|
||||
process.mixin require './nodes'
|
||||
path: require('path')
|
||||
lexer: new (require('./lexer').Lexer)()
|
||||
parser: require('./parser').parser
|
||||
else
|
||||
this.exports: this
|
||||
lexer: new Lexer()
|
||||
parser: exports.parser
|
||||
|
||||
# Thin wrapper for Jison compatibility around the real lexer.
|
||||
parser.lexer: {
|
||||
@@ -34,16 +40,14 @@ exports.tree: (code) ->
|
||||
|
||||
#---------- Below this line is obsolete, for the Ruby compiler. ----------------
|
||||
|
||||
# Executes the `coffee` Ruby program to convert from CoffeeScript to JavaScript.
|
||||
path: require('path')
|
||||
|
||||
# The path to the CoffeeScript executable.
|
||||
compiler: path.normalize(path.dirname(__filename) + '/../../bin/coffee')
|
||||
compiler: ->
|
||||
path.normalize(path.dirname(__filename) + '/../../bin/coffee')
|
||||
|
||||
# Compile a string over stdin, with global variables, for the REPL.
|
||||
exports.ruby_compile: (code, callback) ->
|
||||
js: ''
|
||||
coffee: process.createChildProcess compiler, ['--eval', '--no-wrap', '--globals']
|
||||
coffee: process.createChildProcess compiler(), ['--eval', '--no-wrap', '--globals']
|
||||
|
||||
coffee.addListener 'output', (results) ->
|
||||
js += results if results?
|
||||
@@ -58,7 +62,7 @@ exports.ruby_compile: (code, callback) ->
|
||||
# Compile a list of CoffeeScript files on disk.
|
||||
exports.ruby_compile_files: (paths, callback) ->
|
||||
js: ''
|
||||
coffee: process.createChildProcess compiler, ['--print'].concat(paths)
|
||||
coffee: process.createChildProcess compiler(), ['--print'].concat(paths)
|
||||
|
||||
coffee.addListener 'output', (results) ->
|
||||
js += results if results?
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
Rewriter: require('./rewriter').Rewriter
|
||||
if process?
|
||||
Rewriter: require('./rewriter').Rewriter
|
||||
else
|
||||
this.exports: this
|
||||
Rewriter: this.Rewriter
|
||||
|
||||
# The lexer reads a stream of CoffeeScript and divvys it up into tagged
|
||||
# tokens. A minor bit of the ambiguity in the grammar has been avoided by
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
process.mixin require './scope'
|
||||
_: require('./underscore')._
|
||||
if process?
|
||||
process.mixin require './scope'
|
||||
_: require('./underscore')._
|
||||
else
|
||||
this.exports: this
|
||||
_: this._
|
||||
|
||||
# Some helper functions
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
this.exports: this unless process?
|
||||
|
||||
# In order to keep the grammar simple, the stream of tokens that the Lexer
|
||||
# emits is rewritten by the Rewriter, smoothing out ambiguities, mis-nested
|
||||
# indentation, and single-line flavors of expressions.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
this.exports: this unless process?
|
||||
|
||||
# Scope objects form a tree corresponding to the shape of the function
|
||||
# definitions present in the script. They provide lexical scope, to determine
|
||||
# whether a variable has been seen before or if it needs to be declared.
|
||||
|
||||
Reference in New Issue
Block a user