removing special rule from rewriter for naked functions in arrays
This commit is contained in:
parent
cd6dd5abfd
commit
c219adffd5
|
@ -85,7 +85,7 @@
|
||||||
// The remainder of the source code.
|
// The remainder of the source code.
|
||||||
this.i = 0;
|
this.i = 0;
|
||||||
// Current character position we're parsing.
|
// Current character position we're parsing.
|
||||||
this.line = 1;
|
this.line = 0;
|
||||||
// The current line.
|
// The current line.
|
||||||
this.indent = 0;
|
this.indent = 0;
|
||||||
// The current indent level.
|
// The current indent level.
|
||||||
|
|
|
@ -252,7 +252,7 @@
|
||||||
idx += 1;
|
idx += 1;
|
||||||
tok = this.tokens[idx];
|
tok = this.tokens[idx];
|
||||||
pre = this.tokens[idx - 1];
|
pre = this.tokens[idx - 1];
|
||||||
if ((!tok || (SINGLE_CLOSERS.indexOf(tok[0]) >= 0 && tok[1] !== ';') || (pre[0] === ',' && tok[0] === 'PARAM_START') || (tok[0] === ')' && parens === 0)) && !(starter === 'ELSE' && tok[0] === 'ELSE')) {
|
if ((!tok || (SINGLE_CLOSERS.indexOf(tok[0]) >= 0 && tok[1] !== ';') || (tok[0] === ')' && parens === 0)) && !(starter === 'ELSE' && tok[0] === 'ELSE')) {
|
||||||
insertion = pre[0] === "," ? idx - 1 : idx;
|
insertion = pre[0] === "," ? idx - 1 : idx;
|
||||||
this.tokens.splice(insertion, 0, ['OUTDENT', 2, token[2]]);
|
this.tokens.splice(insertion, 0, ['OUTDENT', 2, token[2]]);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -115,7 +115,7 @@ exports.Lexer: class Lexer
|
||||||
tokenize: (code) ->
|
tokenize: (code) ->
|
||||||
@code : code # The remainder of the source code.
|
@code : code # The remainder of the source code.
|
||||||
@i : 0 # Current character position we're parsing.
|
@i : 0 # Current character position we're parsing.
|
||||||
@line : 1 # The current line.
|
@line : 0 # The current line.
|
||||||
@indent : 0 # The current indent level.
|
@indent : 0 # The current indent level.
|
||||||
@indents : [] # The stack of all indent levels we are currently within.
|
@indents : [] # The stack of all indent levels we are currently within.
|
||||||
@tokens : [] # Collection of all parsed tokens in the form ['TOKEN_TYPE', value, line]
|
@tokens : [] # Collection of all parsed tokens in the form ['TOKEN_TYPE', value, line]
|
||||||
|
|
|
@ -180,7 +180,6 @@ exports.Rewriter: class Rewriter
|
||||||
pre: @tokens[idx - 1]
|
pre: @tokens[idx - 1]
|
||||||
if (not tok or
|
if (not tok or
|
||||||
(SINGLE_CLOSERS.indexOf(tok[0]) >= 0 and tok[1] isnt ';') or
|
(SINGLE_CLOSERS.indexOf(tok[0]) >= 0 and tok[1] isnt ';') or
|
||||||
(pre[0] is ',' and tok[0] is 'PARAM_START') or
|
|
||||||
(tok[0] is ')' && parens is 0)) and
|
(tok[0] is ')' && parens is 0)) and
|
||||||
not (starter is 'ELSE' and tok[0] is 'ELSE')
|
not (starter is 'ELSE' and tok[0] is 'ELSE')
|
||||||
insertion: if pre[0] is "," then idx - 1 else idx
|
insertion: if pre[0] is "," then idx - 1 else idx
|
||||||
|
|
|
@ -14,6 +14,11 @@ ok y.x.name is 'x'
|
||||||
() ->
|
() ->
|
||||||
|
|
||||||
|
|
||||||
|
# Multiple nested function declarations mixed with implicit calls should not
|
||||||
|
# cause a syntax error.
|
||||||
|
(one) -> (two) -> three four, (five) -> six seven, eight, (nine) ->
|
||||||
|
|
||||||
|
|
||||||
obj: {
|
obj: {
|
||||||
name: "Fred"
|
name: "Fred"
|
||||||
|
|
||||||
|
@ -70,7 +75,7 @@ ok result is 10
|
||||||
|
|
||||||
# And even with strange things like this:
|
# And even with strange things like this:
|
||||||
|
|
||||||
funcs: [(x) -> x, (x) -> x * x]
|
funcs: [((x) -> x), ((x) -> x * x)]
|
||||||
result: funcs[1] 5
|
result: funcs[1] 5
|
||||||
|
|
||||||
ok result is 25
|
ok result is 25
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
a: [(x) -> x, (x) -> x * x]
|
a: [((x) -> x), ((x) -> x * x)]
|
||||||
|
|
||||||
ok a.length is 2
|
ok a.length is 2
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue