diff --git a/src/parser/expression.js b/src/parser/expression.js index 4358fbfe8c..1db3481ff1 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -379,12 +379,6 @@ pp.parseExprSubscripts = function (refShorthandDefaultPos) { }; pp.parseSubscripts = function (base, startPos, startLoc, noCalls) { - - // pipeCall plugin hack: pass noPipes via state to avoid changing args - // to core parser function. - const noPipes = this.state.noPipeSubscripts; - this.state.noPipeSubscripts = false; - for (;;) { if (this.hasPlugin("lightscript") && this.crossesWhiteBlockBoundary()) { return base; @@ -482,14 +476,6 @@ pp.parseSubscripts = function (base, startPos, startLoc, noCalls) { node.callee = base; const next = this.parseBangCall(node, "CallExpression"); if (next) base = next; else return node; - } else if ( - !noCalls && - !noPipes && - this.hasPlugin("pipeCall") && - this.match(tt.pipeCall) - ) { - const node = this.startNodeAt(startPos, startLoc); - base = this.parsePipeCall(node, base); } else if (!(this.hasPlugin("lightscript") && this.isNonIndentedBreakFrom(startPos)) && this.eat(tt.bracketL)) { const node = this.startNodeAt(startPos, startLoc); node.object = base; diff --git a/src/plugins/pipeCall.js b/src/plugins/pipeCall.js deleted file mode 100644 index cd3b1a74d0..0000000000 --- a/src/plugins/pipeCall.js +++ /dev/null @@ -1,50 +0,0 @@ -import Parser from "../parser"; -import { types as tt, TokenType } from "../tokenizer/types"; -const pp = Parser.prototype; - -export default function(parser) { - if (parser.__pipeCallPluginInstalled) return; - parser.__pipeCallPluginInstalled = true; - - tt.pipeCall = new TokenType("|>"); - - pp.parsePipeCall = function(node, left) { - if (this.state.value === "|>") { - return this.parseRightPointingPipeCall(node, left); - } else { - return this.parseLeftPointingPipeCall(node, left); - } - }; - - pp.parseRightPointingPipeCall = function(node, left) { - this.next(); - - node.left = left; - - // To get left-associative parsing for pipe calls, we can't let the RHS - // of a pipe call subscript into another pipe call. - // Thus we use a state flag to prevent deep parsing of pipe calls - // Hackish but avoids changing the core args of parseSubscripts - if (this.match(tt.parenL) || this.match(tt.name)) { - this.state.potentialArrowAt = this.state.start; - } - const right = this.parseExprAtom(); - this.state.noPipeSubscripts = true; - node.right = this.parseSubscripts(right, this.state.start, this.state.startLoc); - - return this.finishNode(node, "PipeCallExpression"); - }; - - pp.parseLeftPointingPipeCall = function(node, left) { - this.next(); - - node.left = left; - if (this.match(tt.parenL) || this.match(tt.name)) { - this.state.potentialArrowAt = this.state.start; - } - node.right = this.parseSubscripts(this.parseExprAtom(), this.state.start, this.state.startLoc); - node.reversed = true; - - return this.finishNode(node, "PipeCallExpression"); - }; -} diff --git a/src/registerPlugins.js b/src/registerPlugins.js index ce64a929c8..5a12ada2fb 100644 --- a/src/registerPlugins.js +++ b/src/registerPlugins.js @@ -8,7 +8,6 @@ import bangCallPlugin from "./plugins/bangCall"; import significantWhitespacePlugin from "./plugins/significantWhitespace"; import splatComprehensionPlugin from "./plugins/splatComprehension"; import syntacticPlaceholderPlugin from "./plugins/syntacticPlaceholder"; -import pipeCallPlugin from "./plugins/pipeCall"; import { matchCoreSyntax, match } from "./plugins/match"; function noncePlugin() {} @@ -88,9 +87,6 @@ export default function registerPlugins(plugins, metadata) { // as PlaceholderExpressions. registerPlugin("syntacticPlaceholder", syntacticPlaceholderPlugin); - // |> infix operator for piped function calls - registerPlugin("pipeCall", pipeCallPlugin); - registerPlugin("whiteblockOnly", noncePlugin, { dependencies: ["lightscript"] }); diff --git a/src/tokenizer/index.js b/src/tokenizer/index.js index 8cd5285b8e..e98c64f012 100644 --- a/src/tokenizer/index.js +++ b/src/tokenizer/index.js @@ -360,10 +360,6 @@ export default class Tokenizer { if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2); if (next === 61) return this.finishOp(tt.assign, 2); if (code === 124 && next === 125 && this.hasPlugin("flow")) return this.finishOp(tt.braceBarR, 2); - if (code === 124 && next === 62 && this.hasPlugin("pipeCall")) { - this.state.pos += 2; - return this.finishToken(tt.pipeCall, "|>"); - } return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1); } @@ -456,11 +452,6 @@ export default class Tokenizer { size = 2; } - if (code === 60 && next === 124 && this.hasPlugin("pipeCall")) { - this.state.pos += 2; - return this.finishToken(tt.pipeCall, "<|"); - } - return this.finishOp(tt.relational, size); } diff --git a/test/fixtures/pipe-call/basic/arrow/actual.js b/test/fixtures/pipe-call/basic/arrow/actual.js deleted file mode 100644 index b72bfbb7f6..0000000000 --- a/test/fixtures/pipe-call/basic/arrow/actual.js +++ /dev/null @@ -1 +0,0 @@ -a |> (b) -> c diff --git a/test/fixtures/pipe-call/basic/arrow/expected.json b/test/fixtures/pipe-call/basic/arrow/expected.json deleted file mode 100644 index bea2c40caa..0000000000 --- a/test/fixtures/pipe-call/basic/arrow/expected.json +++ /dev/null @@ -1,137 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "sourceType": "script", - "body": [ - { - "type": "ExpressionStatement", - "start": 0, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "expression": { - "type": "PipeCallExpression", - "start": 0, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "left": { - "type": "Identifier", - "start": 0, - "end": 1, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 1 - }, - "identifierName": "a" - }, - "name": "a" - }, - "right": { - "type": "ArrowFunctionExpression", - "start": 5, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "id": null, - "generator": false, - "expression": true, - "async": false, - "params": [ - { - "type": "Identifier", - "start": 6, - "end": 7, - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 7 - }, - "identifierName": "b" - }, - "name": "b" - } - ], - "skinny": true, - "body": { - "type": "Identifier", - "start": 12, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 13 - }, - "identifierName": "c" - }, - "name": "c" - } - } - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/pipe-call/basic/associativity/actual.js b/test/fixtures/pipe-call/basic/associativity/actual.js deleted file mode 100644 index f7ad5ea59e..0000000000 --- a/test/fixtures/pipe-call/basic/associativity/actual.js +++ /dev/null @@ -1 +0,0 @@ -a |> b |> c diff --git a/test/fixtures/pipe-call/basic/associativity/expected.json b/test/fixtures/pipe-call/basic/associativity/expected.json deleted file mode 100644 index 51e5530e5c..0000000000 --- a/test/fixtures/pipe-call/basic/associativity/expected.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "sourceType": "script", - "body": [ - { - "type": "ExpressionStatement", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "expression": { - "type": "PipeCallExpression", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "left": { - "type": "PipeCallExpression", - "start": 0, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, - "left": { - "type": "Identifier", - "start": 0, - "end": 1, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 1 - }, - "identifierName": "a" - }, - "name": "a" - }, - "right": { - "type": "Identifier", - "start": 5, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - }, - "identifierName": "b" - }, - "name": "b" - } - }, - "right": { - "type": "Identifier", - "start": 10, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 11 - }, - "identifierName": "c" - }, - "name": "c" - } - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/pipe-call/basic/pipe/actual.js b/test/fixtures/pipe-call/basic/pipe/actual.js deleted file mode 100644 index cf3443941f..0000000000 --- a/test/fixtures/pipe-call/basic/pipe/actual.js +++ /dev/null @@ -1 +0,0 @@ -a |> b diff --git a/test/fixtures/pipe-call/basic/pipe/expected.json b/test/fixtures/pipe-call/basic/pipe/expected.json deleted file mode 100644 index 30a9978691..0000000000 --- a/test/fixtures/pipe-call/basic/pipe/expected.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, - "sourceType": "script", - "body": [ - { - "type": "ExpressionStatement", - "start": 0, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, - "expression": { - "type": "PipeCallExpression", - "start": 0, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 6 - } - }, - "left": { - "type": "Identifier", - "start": 0, - "end": 1, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 1 - }, - "identifierName": "a" - }, - "name": "a" - }, - "right": { - "type": "Identifier", - "start": 5, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - }, - "identifierName": "b" - }, - "name": "b" - } - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/pipe-call/basic/rhs-expr/actual.js b/test/fixtures/pipe-call/basic/rhs-expr/actual.js deleted file mode 100644 index c3ecd0849c..0000000000 --- a/test/fixtures/pipe-call/basic/rhs-expr/actual.js +++ /dev/null @@ -1 +0,0 @@ -a |> b(c) diff --git a/test/fixtures/pipe-call/basic/rhs-expr/expected.json b/test/fixtures/pipe-call/basic/rhs-expr/expected.json deleted file mode 100644 index 856c241654..0000000000 --- a/test/fixtures/pipe-call/basic/rhs-expr/expected.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 9, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 9, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - }, - "sourceType": "script", - "body": [ - { - "type": "ExpressionStatement", - "start": 0, - "end": 9, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - }, - "expression": { - "type": "PipeCallExpression", - "start": 0, - "end": 9, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 9 - } - }, - "left": { - "type": "Identifier", - "start": 0, - "end": 1, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 1 - }, - "identifierName": "a" - }, - "name": "a" - }, - "right": { - "type": "CallExpression", - "start": 6, - "end": 9, - "loc": { - "start": { - "line": 1, - "column": 6 - }, - "end": { - "line": 1, - "column": 9 - } - }, - "callee": { - "type": "Identifier", - "start": 5, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - }, - "identifierName": "b" - }, - "name": "b" - }, - "arguments": [ - { - "type": "Identifier", - "start": 7, - "end": 8, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 8 - }, - "identifierName": "c" - }, - "name": "c" - } - ] - } - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/pipe-call/leftward/pipe/actual.js b/test/fixtures/pipe-call/leftward/pipe/actual.js deleted file mode 100644 index 3eb1fe523c..0000000000 --- a/test/fixtures/pipe-call/leftward/pipe/actual.js +++ /dev/null @@ -1 +0,0 @@ -a <| b <| c diff --git a/test/fixtures/pipe-call/leftward/pipe/expected.json b/test/fixtures/pipe-call/leftward/pipe/expected.json deleted file mode 100644 index c465c08960..0000000000 --- a/test/fixtures/pipe-call/leftward/pipe/expected.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "sourceType": "script", - "body": [ - { - "type": "ExpressionStatement", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "expression": { - "type": "PipeCallExpression", - "start": 0, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "left": { - "type": "Identifier", - "start": 0, - "end": 1, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 1 - }, - "identifierName": "a" - }, - "name": "a" - }, - "right": { - "type": "PipeCallExpression", - "start": 7, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 7 - }, - "end": { - "line": 1, - "column": 11 - } - }, - "left": { - "type": "Identifier", - "start": 5, - "end": 6, - "loc": { - "start": { - "line": 1, - "column": 5 - }, - "end": { - "line": 1, - "column": 6 - }, - "identifierName": "b" - }, - "name": "b" - }, - "right": { - "type": "Identifier", - "start": 10, - "end": 11, - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 11 - }, - "identifierName": "c" - }, - "name": "c" - }, - "reversed": true - }, - "reversed": true - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/pipe-call/options.json b/test/fixtures/pipe-call/options.json deleted file mode 100644 index 634ff57aaf..0000000000 --- a/test/fixtures/pipe-call/options.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "alternatives": { - "default": { - "allPlugins": true, - "excludePlugins": ["estree"] - } - } -}