Skip to content

Commit

Permalink
closes #64; f! as f()
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Aug 13, 2011
1 parent 2cb9073 commit dc290f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,20 @@ exports.doLiteral = function(code, index){
: this.token('LITERAL', 'arguments'));
return val.length;
case '!':
if (!this.last.spaced && this.last[1] === 'typeof') {
return this.last[1] = 'classof', 1;
if (!this.last.spaced) {
if (able(this.tokens, null, true)) {
if (this.last[0] === '?') {
_ref = this.last;
_ref[0] = 'CALL(';
_ref[1] = '?(';
} else {
this.token('CALL(', '!');
}
return this.token(')CALL', ')'), 1;
}
if (this.last[1] === 'typeof') {
return this.last[1] = 'classof', 1;
}
}
tag = 'UNARY';
break;
Expand Down
8 changes: 7 additions & 1 deletion src/lexer.co
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,13 @@ exports import
else @token \LITERAL \arguments
return val.length
case \!
return (@last.1 = \classof; 1) if not @last.spaced and @last.1 is \typeof
unless @last.spaced
if able @tokens, null true
if @last.0 is \?
then @last <<< [\CALL( \?(]
else @token \CALL( \!
return (@token \)CALL \); 1)
return (@last.1 = \classof; 1) if @last.1 is \typeof
tag = \UNARY
case \~
return 1 if @dotcat val
Expand Down
10 changes: 10 additions & 0 deletions test/chaining.co
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,13 @@ o?.@a?.@@b?@e?@@f.4 = 5
eq '0,1' ''+o.a.b
eq '2,3' ''+o.a.c.d
eq 5 o.a.b.e.f.4


# Bang Call
eq '' String!
(-> ok true)!

f = -> null
eq null f?!
f = void
eq void f?!

0 comments on commit dc290f5

Please sign in to comment.