mochiscript 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -451,7 +451,7 @@ var TOKENS = [
451
451
  [ "FOREACH", "foreach\\b", 'ForeachParser' ],
452
452
 
453
453
  [ "SHORTHAND_MAPPER", "#[\\w\\$]+\\s*(?:{|\\()", 'ShorthandMapperParser' ],
454
- [ "SHORTHAND_FUNCTION", "#(?:{|\\()", 'ShorthandFunctionParser' ],
454
+ [ "SHORTHAND_FUNCTION", "##?(?:{|\\()", 'ShorthandFunctionParser' ],
455
455
  [ "ISTRING_START", "%{", 'IStringParser' ],
456
456
  [ "HEREDOC", "<<[A-Z][0-9A-Z]*", 'HereDocParser' ],
457
457
 
@@ -1013,7 +1013,13 @@ RootParser.extend("ShorthandFunctionParser", function(KLASS, OO){
1013
1013
 
1014
1014
 
1015
1015
  OO.addMember("parse", function(tokens){var self=this;
1016
- tokens.consume(1);
1016
+ var m = tokens.match(/^##?/);
1017
+ if (!m) return false;
1018
+
1019
+ var nhashes = m[0].length;
1020
+ var exec = nhashes == 2;
1021
+
1022
+ tokens.consume(nhashes);
1017
1023
  var argsMatch = tokens.match(ARGS_REGEX);
1018
1024
  var args = null;
1019
1025
 
@@ -1027,8 +1033,16 @@ RootParser.extend("ShorthandFunctionParser", function(KLASS, OO){
1027
1033
  var body = new $c.CurlyParser();
1028
1034
  body.parse(tokens);
1029
1035
  var semi = tokens.match(/^\s*[,;\)\}\]]/) ? '' : ';';
1036
+ var out = [ 'function', args, body ];
1037
+
1038
+ if (exec) {
1039
+ out.unshift('(');
1040
+ out.push(')()');
1041
+ }
1042
+
1043
+ out.push(semi);
1030
1044
 
1031
- this.out = [ 'function', args, body, semi ];
1045
+ this.out = out;
1032
1046
  });
1033
1047
  });
1034
1048
 
@@ -1,3 +1,3 @@
1
1
  module Mochiscript
2
- VERSION = "0.6.8"
2
+ VERSION = "0.6.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mochiscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.6.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
12
+ date: 2012-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: therubyracer