Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug that arose if you followed a non-braced while by an else.…

… The patch is a rather lame hack that involves looking to see whether we just wrote a block and omitting the semicolon iff that is the case.
  • Loading branch information...
commit 3e4db7090880c506b817cf20829a3e0f72dcb115 1 parent e7774bd
@spencertipping authored
Showing with 18 additions and 18 deletions.
  1. +4 −4 divergence.rebase.js
  2. +8 −8 divergence.rebase.test.js
  3. +6 −6 rebase
View
8 divergence.rebase.js
@@ -72,7 +72,7 @@
// searching. I realize this is more elaborate than necessary given that the lexer is streaming (and thus would never need to recover old line lengths), but having to keep track of each newline
// that occurs while reading the input is probably more expensive than the overhead incurred by O(log n) jumps every so often.
- parse: function (s) {var mark = 0, i = 0, $_, l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
+ parse: function (s) {var mark = 0, i = 0, $_ = '', l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
precedence = r.precedence, ident = r.ident, punct = r.punct,
line_breaks = [0].concat (s.split('\n').map('.length')), lb = 1,
located_token = function () {var jump = lb << 1, l = 0, r = new String (token);
@@ -101,7 +101,7 @@
token in {} && (token = '@' + token);
if (t.is_value() && '[('.indexOf (token) > -1) openers.push (t = t.push_op (token + '!').graft (located_token()));
- else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && token != 'else' && (t = t.push_op(';'));
+ else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && (t = t.push_op(';'));
else if (token === '?') openers.push (t = t.push_op (located_token()).graft ('?:'));
else if (r.openers[token]) openers.push (t = t.graft (located_token()));
else if (precedence[token]) t = t.push_op (located_token());
@@ -133,12 +133,12 @@
toString: function () {var left_in = function (x, ops) {return x.xs && x.xs[0] && (ops[x.xs[0].op] && x.xs[0].op ||
x.xs[0].xs && x.xs[0].xs[1] && ops[x.xs[0].xs[1].op] && x.xs[0].xs[1].op)},
right_in = function (x, ops) {return x.xs && x.xs[1] && ops[x.xs[1].op] && x.xs[1].op},
- right = null;
+ $_ = '';
return '([{'.indexOf(this.op) > -1 ? this.op + s(this.xs[0]) + r.openers[this.op] :
this.op == '?' ? s(this.xs[0]) + ' ? ' + s(this.xs[1].xs[0]) + ' : ' + s(this.xs[2]) :
this.op == '(!' || this.op == '[!' ? s(this.xs[0]) + s(this.xs[1]) :
r.implicit_assignment[this.op] ? '(' + (this.op.charAt(0) === 'u' ? this.op.substring(1) + s(this.xs[0]) : s(this.xs[0]) + this.op) + ')' :
- this.xs[1] && r.connected[this.xs[1].op] ? s(this.xs[0]) + ' ' + s(this.xs[1]) :
+ this.xs[1] && r.connected[this.xs[1].op] ? (($_ = s(this.xs[0])).charAt($_.length - 1) === '}' ? $_ + ' ' : $_ + ';') + s(this.xs[1]) :
r.unary[this.op] ? (r.translations[this.op] || this.op) + ' ' + s(this.xs[0]) :
r.prefix_binary[this.op] ? this.op + ' ' + s(this.xs[0]) + ' ' + s(this.xs[1]) :
s(this.xs[0]) + ' ' + this.op + ' ' + s(this.xs[1])}}),
View
16 divergence.rebase.test.js
@@ -139,7 +139,7 @@ var d = (function () {
// searching. I realize this is more elaborate than necessary given that the lexer is streaming (and thus would never need to recover old line lengths), but having to keep track of each newline
// that occurs while reading the input is probably more expensive than the overhead incurred by O(log n) jumps every so often.
- parse: function (s) {var mark = 0, i = 0, $_, l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
+ parse: function (s) {var mark = 0, i = 0, $_ = '', l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
precedence = r.precedence, ident = r.ident, punct = r.punct,
line_breaks = [0].concat (s.split('\n').map('.length')), lb = 1,
located_token = function () {var jump = lb << 1, l = 0, r = new String (token);
@@ -168,7 +168,7 @@ var d = (function () {
token in {} && (token = '@' + token);
if (t.is_value() && '[('.indexOf (token) > -1) openers.push (t = t.push_op (token + '!').graft (located_token()));
- else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && token != 'else' && (t = t.push_op(';'));
+ else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && (t = t.push_op(';'));
else if (token === '?') openers.push (t = t.push_op (located_token()).graft ('?:'));
else if (r.openers[token]) openers.push (t = t.graft (located_token()));
else if (precedence[token]) t = t.push_op (located_token());
@@ -200,12 +200,12 @@ var d = (function () {
toString: function () {var left_in = function (x, ops) {return x.xs && x.xs[0] && (ops[x.xs[0].op] && x.xs[0].op ||
x.xs[0].xs && x.xs[0].xs[1] && ops[x.xs[0].xs[1].op] && x.xs[0].xs[1].op)},
right_in = function (x, ops) {return x.xs && x.xs[1] && ops[x.xs[1].op] && x.xs[1].op},
- right = null;
+ $_ = '';
return '([{'.indexOf(this.op) > -1 ? this.op + s(this.xs[0]) + r.openers[this.op] :
this.op == '?' ? s(this.xs[0]) + ' ? ' + s(this.xs[1].xs[0]) + ' : ' + s(this.xs[2]) :
this.op == '(!' || this.op == '[!' ? s(this.xs[0]) + s(this.xs[1]) :
r.implicit_assignment[this.op] ? '(' + (this.op.charAt(0) === 'u' ? this.op.substring(1) + s(this.xs[0]) : s(this.xs[0]) + this.op) + ')' :
- this.xs[1] && r.connected[this.xs[1].op] ? s(this.xs[0]) + ' ' + s(this.xs[1]) :
+ this.xs[1] && r.connected[this.xs[1].op] ? (($_ = s(this.xs[0])).charAt($_.length - 1) === '}' ? $_ + ' ' : $_ + ';') + s(this.xs[1]) :
r.unary[this.op] ? (r.translations[this.op] || this.op) + ' ' + s(this.xs[0]) :
r.prefix_binary[this.op] ? this.op + ' ' + s(this.xs[0]) + ' ' + s(this.xs[1]) :
s(this.xs[0]) + ' ' + this.op + ' ' + s(this.xs[1])}}),
@@ -381,7 +381,7 @@ var d = (function () {
// searching. I realize this is more elaborate than necessary given that the lexer is streaming (and thus would never need to recover old line lengths), but having to keep track of each newline
// that occurs while reading the input is probably more expensive than the overhead incurred by O(log n) jumps every so often.
- parse: function (s) {var mark = 0, i = 0, $_, l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
+ parse: function (s) {var mark = 0, i = 0, $_ = '', l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
precedence = r.precedence, ident = r.ident, punct = r.punct,
line_breaks = [0].concat (s.split('\n').map('.length')), lb = 1,
located_token = function () {var jump = lb << 1, l = 0, r = new String (token);
@@ -410,7 +410,7 @@ var d = (function () {
token in {} && (token = '@' + token);
if (t.is_value() && '[('.indexOf (token) > -1) openers.push (t = t.push_op (token + '!').graft (located_token()));
- else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && token != 'else' && (t = t.push_op(';'));
+ else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && (t = t.push_op(';'));
else if (token === '?') openers.push (t = t.push_op (located_token()).graft ('?:'));
else if (r.openers[token]) openers.push (t = t.graft (located_token()));
else if (precedence[token]) t = t.push_op (located_token());
@@ -442,12 +442,12 @@ var d = (function () {
toString: function () {var left_in = function (x, ops) {return x.xs && x.xs[0] && (ops[x.xs[0].op] && x.xs[0].op ||
x.xs[0].xs && x.xs[0].xs[1] && ops[x.xs[0].xs[1].op] && x.xs[0].xs[1].op)},
right_in = function (x, ops) {return x.xs && x.xs[1] && ops[x.xs[1].op] && x.xs[1].op},
- right = null;
+ $_ = '';
return '([{'.indexOf(this.op) > -1 ? this.op + s(this.xs[0]) + r.openers[this.op] :
this.op == '?' ? s(this.xs[0]) + ' ? ' + s(this.xs[1].xs[0]) + ' : ' + s(this.xs[2]) :
this.op == '(!' || this.op == '[!' ? s(this.xs[0]) + s(this.xs[1]) :
r.implicit_assignment[this.op] ? '(' + (this.op.charAt(0) === 'u' ? this.op.substring(1) + s(this.xs[0]) : s(this.xs[0]) + this.op) + ')' :
- this.xs[1] && r.connected[this.xs[1].op] ? s(this.xs[0]) + ' ' + s(this.xs[1]) :
+ this.xs[1] && r.connected[this.xs[1].op] ? (($_ = s(this.xs[0])).charAt($_.length - 1) === '}' ? $_ + ' ' : $_ + ';') + s(this.xs[1]) :
r.unary[this.op] ? (r.translations[this.op] || this.op) + ' ' + s(this.xs[0]) :
r.prefix_binary[this.op] ? this.op + ' ' + s(this.xs[0]) + ' ' + s(this.xs[1]) :
s(this.xs[0]) + ' ' + this.op + ' ' + s(this.xs[1])}}),
View
12 rebase
@@ -282,7 +282,7 @@ var d = (function () {
__mgOL36mfzZ3wiz9iNpNvE5zzifLo0jmpyKjyxwb7B5A
-meta::code('main', <<'__Y9OhLB7+1JzfjXmc9F/PpFxLBakQCv0sXa5yLrKz2vA');
+meta::code('main', <<'__DqIssH8bjKC2SnJ0+1crtCCdML7eim9hw/l1WeeqFa4');
Divergence Rebase module | Spencer Tipping <spencer@spencertipping.com>
Licensed under the terms of the MIT source code license
@@ -357,7 +357,7 @@ as a key there (e.g. 'foo'), then it will be sandwiched between binary operators
searching. I realize this is more elaborate than necessary given that the lexer is streaming (and thus would never need to recover old line lengths), but having to keep track of each newline
that occurs while reading the input is probably more expensive than the overhead incurred by O(log n) jumps every so often.
- parse: function (s) {var mark = 0, i = 0, $_, l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
+ parse: function (s) {var mark = 0, i = 0, $_ = '', l = s.length, token = '', expect_re = true, escaped = false, t = new r.syntax(null, '('), c = s.charAt.bind (s), openers = [],
precedence = r.precedence, ident = r.ident, punct = r.punct,
line_breaks = [0].concat (s.split('\n').map('.length')), lb = 1,
located_token = function () {var jump = lb << 1, l = 0, r = new String (token);
@@ -386,7 +386,7 @@ as a key there (e.g. 'foo'), then it will be sandwiched between binary operators
token in {} && (token = '@' + token);
if (t.is_value() && '[('.indexOf (token) > -1) openers.push (t = t.push_op (token + '!').graft (located_token()));
- else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && token != 'else' && (t = t.push_op(';'));
+ else if (($_ = r.closers[token]) && last(openers).op == $_) t = openers.pop().parent, token === '}' && t.is_value() && r.statement[t.op] && (t = t.push_op(';'));
else if (token === '?') openers.push (t = t.push_op (located_token()).graft ('?:'));
else if (r.openers[token]) openers.push (t = t.graft (located_token()));
else if (precedence[token]) t = t.push_op (located_token());
@@ -418,12 +418,12 @@ as a key there (e.g. 'foo'), then it will be sandwiched between binary operators
toString: function () {var left_in = function (x, ops) {return x.xs && x.xs[0] && (ops[x.xs[0].op] && x.xs[0].op ||
x.xs[0].xs && x.xs[0].xs[1] && ops[x.xs[0].xs[1].op] && x.xs[0].xs[1].op)},
right_in = function (x, ops) {return x.xs && x.xs[1] && ops[x.xs[1].op] && x.xs[1].op},
- right = null;
+ $_ = '';
return '([{'.indexOf(this.op) > -1 ? this.op + s(this.xs[0]) + r.openers[this.op] :
this.op == '?' ? s(this.xs[0]) + ' ? ' + s(this.xs[1].xs[0]) + ' : ' + s(this.xs[2]) :
this.op == '(!' || this.op == '[!' ? s(this.xs[0]) + s(this.xs[1]) :
r.implicit_assignment[this.op] ? '(' + (this.op.charAt(0) === 'u' ? this.op.substring(1) + s(this.xs[0]) : s(this.xs[0]) + this.op) + ')' :
- this.xs[1] && r.connected[this.xs[1].op] ? s(this.xs[0]) + ' ' + s(this.xs[1]) :
+ this.xs[1] && r.connected[this.xs[1].op] ? (($_ = s(this.xs[0])).charAt($_.length - 1) === '}' ? $_ + ' ' : $_ + ';') + s(this.xs[1]) :
r.unary[this.op] ? (r.translations[this.op] || this.op) + ' ' + s(this.xs[0]) :
r.prefix_binary[this.op] ? this.op + ' ' + s(this.xs[0]) + ' ' + s(this.xs[1]) :
s(this.xs[0]) + ' ' + this.op + ' ' + s(this.xs[1])}}),
@@ -507,7 +507,7 @@ as a key there (e.g. 'foo'), then it will be sandwiched between binary operators
enable it like this:
r.enable_inline_macro = (function (enabled) {return function () {enabled || (enabled = !! d.inline_macros.push ('$0.toString()'.compose (r.transform).compose (r.parse)))}}) (false)}) ();
-__Y9OhLB7+1JzfjXmc9F/PpFxLBakQCv0sXa5yLrKz2vA
+__DqIssH8bjKC2SnJ0+1crtCCdML7eim9hw/l1WeeqFa4
meta::code('test', <<'__FWHNsYkV5opOl+iFJSG8FqyD3pzxfXnTPwn5zC78hrI');
Divergence Rebase unit tests | Spencer Tipping <spencer@spencertipping.com>
Please sign in to comment.
Something went wrong with that request. Please try again.