scrubbing all carriage returns from CoffeeScript source before compiling for the benefit of Windows users.

This commit is contained in:
Jeremy Ashkenas 2010-03-08 23:07:26 -05:00
parent dcb00b4fe8
commit 1b4edd0e37
4 changed files with 8 additions and 2 deletions

View File

@ -74,6 +74,7 @@ task 'test', 'run the CoffeeScript language test suite', ->
process.mixin {
ok: (args...) -> test_count += 1; original_ok(args...)
throws: (args...) -> test_count += 1; original_throws(args...)
CoffeeScript: CoffeeScript
}
process.addListener 'exit', ->
time: ((new Date() - start_time) / 1000).toFixed(2)

View File

@ -33,7 +33,8 @@
Lexer.prototype.tokenize = function tokenize(code, options) {
var o;
o = options || {};
this.code = code || '';
code = code.replace(/\r/g, '');
this.code = code;
// The remainder of the source code.
this.i = 0;
// Current character position we're parsing.

View File

@ -35,8 +35,9 @@ exports.Lexer: class Lexer
# Before returning the token stream, run it through the [Rewriter](rewriter.html)
# unless explicitly asked not to.
tokenize: (code, options) ->
code : code.replace(/\r/g, '')
o : options or {}
@code : code or '' # The remainder of the source code.
@code : code # The remainder of the source code.
@i : 0 # Current character position we're parsing.
@line : o.line or 0 # The current line.
@indent : 0 # The current indentation level.

View File

@ -0,0 +1,3 @@
js: CoffeeScript.compile("one\r\ntwo", {no_wrap: on})
ok js is "one;\ntwo;"