Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bsjs: sequence in call arguments

  • Loading branch information...
commit a8d72d211cfccac2bd3163583fa8436b8d8ed15a 1 parent 2b47374
@indutny indutny authored
View
7 lib/ometajs/grammars/bsjs.js
@@ -1328,15 +1328,15 @@ BSJSTranslator.prototype["func"] = function $func() {
};
BSJSTranslator.prototype["call"] = function $call() {
- var fn, tfn, args;
- return this._skip() && (fn = this._getIntermediate(), true) && this._rule("trans", false, [ fn ], null, this["trans"]) && (tfn = this._getIntermediate(), true) && this._any(function() {
+ var fn, tfn, $l18, $l19, args;
+ return this._skip() && (fn = this._getIntermediate(), true) && this._rule("trans", false, [ fn ], null, this["trans"]) && (tfn = this._getIntermediate(), true) && ($l18 = this, $l19 = $l18.op, $l18.op = "()", true) && (this._any(function() {
return this._atomic(function() {
return this._rule("trans", false, [], null, this["trans"]);
});
}) && (args = this._getIntermediate(), true) && this._exec(function() {
if (fn[1] === null) tfn = "(" + tfn + ")";
return tfn + "(" + args.join(",") + ")";
- }.call(this));
+ }.call(this)) && ($l18.op = $l19, true) || ($l18.op = $l19, false));
};
BSJSTranslator.prototype["send"] = function $send() {
@@ -1443,6 +1443,7 @@ BSJSTranslator.prototype["stmt"] = function $stmt() {
BSJSTranslator.opPriorities = {
".": 0,
"[]": 0,
+ "()": 0,
"u++": 1,
"u--": 1,
"u+": 2,
View
4 lib/ometajs/grammars/bsjs.ometajs
@@ -348,7 +348,7 @@ ometa BSJSTranslator {
)
)*:xs -> ('{' + xs.join('') + '}'),
func :name :args curlyTrans:body -> ('function ' + (name || '') + '(' + args.join(',') + ')' + body),
- call :fn trans(fn):tfn trans*:args -> {
+ call :fn trans(fn):tfn %(this.op = '()') trans*:args -> {
if (fn[1] === null) tfn = '(' + tfn + ')';
return tfn + '(' + args.join(',') + ')';
},
@@ -376,7 +376,7 @@ ometa BSJSTranslator {
}
BSJSTranslator.opPriorities = {
- '.': 0, '[]': 0,
+ '.': 0, '[]': 0, '()': 0,
'u++': 1, 'u--': 1,
'u+': 2, 'u-': 2, 'u!': 2, 'u~': 2, 'utypeof': 2, 'uvoid': 2, 'udelete': 2,
'*': 3, '/': 3, '%': 3,
View
5 test/unit/functional-test.js
@@ -226,6 +226,11 @@ suite('Ometajs module', function() {
['arr', ['binop', ',', ['get', 'a'], ['get', 'b']]],
'[(a , b)]'
);
+ unit(
+ 'call and ,',
+ ['call', ['get', 'a'], ['binop', ',', ['get', 'a'], ['get', 'b']]],
+ 'a((a , b))'
+ );
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.