Skip to content

Instantly share code, notes, and snippets.

View StanAngeloff's full-sized avatar

Stan Angeloff StanAngeloff

View GitHub Profile
diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee
index fe6f54a..93d990a 100644
--- a/src/coffee-script.coffee
+++ b/src/coffee-script.coffee
@@ -10,7 +10,7 @@
if process?
process.mixin require 'nodes'
path: require 'path'
- Lexer: require('lexer').Lexer
+ LexerClass: require('lexer').Lexer
__slice = function __slice(source, start, end, step) {
var length, result, stringify;
if (!(typeof source !== "undefined" && source !== null)) {
throw "'source' cannot be empty when calling __slice(>> " + source + " <<, " + start + ", " + end + ", " + step + ")";
} else if (step === 0) {
throw "'step' cannot be zero when calling __slice(..., " + start + ", " + end + ", >> " + step + " <<)";
}
if (Object.prototype.toString.call(source) !== "[object Array]") {
source = source.toString().split("");
stringify = true;
diff --git a/src/grammar.coffee b/src/grammar.coffee
index 0c98198..d77293f 100644
--- a/src/grammar.coffee
+++ b/src/grammar.coffee
@@ -306,6 +306,7 @@ grammar: {
Slice: [
o "INDEX_START Expression . . Expression INDEX_END", -> new RangeNode $2, $5
o "INDEX_START Expression . . . Expression INDEX_END", -> new RangeNode $2, $6, true
+ o "[ Expression : Expression : Expression ]", -> new SteppingRangeNode $2, $4, $6
]
[stan@psp-stan-arch coffee-script]$ bin/coffee -t sandbox/slice_test.coffee
[IDENTIFIER a] [ASSIGN :] [[ [] [NUMBER 0] [, ,] [NUMBER 1] [, ,] [NUMBER 2] [, ,] [NUMBER 3] [, ,] [NUMBER 4] [, ,] [NUMBER 5] [, ,] [NUMBER 6] [, ,] [NUMBER 7] [, ,] [NUMBER 8] [, ,] [NUMBER 9] [] ]] [TERMINATOR \n] [IDENTIFIER a] [INDEX_START [] [NUMBER 1] [ASSIGN :] [NUMBER 1] [, ,] [NUMBER 1] [INDEX_END ]] [TERMINATOR \n]
Array.prototype.slice.call(
(Object.prototype.toString.call(source) !== "[object Array]") ? (_a = source.toString().split("")) : (_a = source),
(typeof from !== "undefined" && from !== null) ? from < 0 ? (from = from + _a.length) < 0 ? 0 : from : from : 0,
(typeof to !== "undefined" && to !== null) ? (to = to < 0 ? to + _a.length : to) < 0 ? (to = from) : to > _a.length ? (to = _a.length) : to : _a.length
);
response:{size:0}
size: (chunk) ->
alert "r.size: " + response.size
alert "c.length: " + chunk.length
alert "r.size + c.length: " + (response.size + chunk.length)
size 'Hello'
fn: ->
var1: arguments[0] if arguments.length
[stan@psp-stan-arch coffee-script]$ bin/cake build:full
sys.exec has moved to the "child_process" module. Please update your source code.
Error: childProcess API has changed. See doc/api.txt.
at EventEmitter.createChildProcess (node.js:11:11)
at run (eval at <anonymous> (/home/stan/public/coffee-script/lib/coffee-script.js:57:55))
at Object.action (eval at <anonymous> (/home/stan/public/coffee-script/lib/coffee-script.js:57:55))
at invoke (/home/stan/public/coffee-script/lib/cake.js:49:26)
at /home/stan/public/coffee-script/lib/cake.js:73:17
at node.js:394:21
at node.js:813:9
[left[0...1], right[0..1]]: [right[0..1], left[0...1]]
[stan@psp-stan-arch coffee-script]$ bin/coffee -ce 'a[-1]'
var _a;
(_a = a)[-1 + _a.length];
[stan@psp-stan-arch coffee-script]$ bin/coffee -ce 'a?[-1]'
var _a, _b, _c;
(_a = a) == undefined ? undefined : ((_c = _a)[-1 + _c.length]);
[stan@psp-stan-arch coffee-script]$ bin/coffee -ce 'a?[-1]?[-1]'
var _a, _b, _c, _d, _e, _f;