Implement f# pipeline in parser (#9450)

This commit is contained in:
James DiGioia 2019-05-14 16:12:17 -04:00 committed by Nicolò Ribaudo
parent 0a98814329
commit 6b8a37c413
54 changed files with 4295 additions and 19 deletions

View File

@ -331,8 +331,11 @@ export default class ExpressionParser extends LValParser {
const prec = this.state.type.binop;
if (prec != null && (!noIn || !this.match(tt._in))) {
if (prec > minPrec) {
const node = this.startNodeAt(leftStartPos, leftStartLoc);
const operator = this.state.value;
if (operator === "|>" && this.state.inFSharpPipelineDirectBody) {
return left;
}
const node = this.startNodeAt(leftStartPos, leftStartLoc);
node.left = left;
node.operator = operator;
if (
@ -406,11 +409,12 @@ export default class ExpressionParser extends LValParser {
prec: number,
noIn: ?boolean,
): N.Expression {
switch (op) {
case tt.pipeline:
if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
switch (op) {
case tt.pipeline:
switch (this.getPluginOption("pipelineOperator", "proposal")) {
case "smart":
return this.withTopicPermittingContext(() => {
return this.parseSmartPipelineBody(
this.parseExprOpBaseRightExpr(op, prec, noIn),
@ -418,6 +422,10 @@ export default class ExpressionParser extends LValParser {
startLoc,
);
});
case "fsharp":
return this.withSoloAwaitPermittingContext(() => {
return this.parseFSharpPipelineBody(prec, noIn);
});
}
// falls through
@ -766,6 +774,8 @@ export default class ExpressionParser extends LValParser {
const elts = [];
let innerParenStart;
let first = true;
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = false;
while (!this.eat(close)) {
if (first) {
@ -804,6 +814,8 @@ export default class ExpressionParser extends LValParser {
this.unexpected();
}
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return elts;
}
@ -969,7 +981,10 @@ export default class ExpressionParser extends LValParser {
case tt.parenL:
return this.parseParenAndDistinguishExpression(canBeArrow);
case tt.bracketL:
case tt.bracketL: {
const oldInFSharpPipelineDirectBody = this.state
.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = false;
node = this.startNode();
this.next();
node.elements = this.parseExprList(
@ -985,11 +1000,17 @@ export default class ExpressionParser extends LValParser {
// expression by calling toReferencedListDeep.
this.toReferencedList(node.elements);
}
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return this.finishNode(node, "ArrayExpression");
case tt.braceL:
return this.parseObj(false, refShorthandDefaultPos);
}
case tt.braceL: {
const oldInFSharpPipelineDirectBody = this.state
.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = false;
const ret = this.parseObj(false, refShorthandDefaultPos);
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return ret;
}
case tt._function:
return this.parseFunctionExpression();
@ -1177,9 +1198,11 @@ export default class ExpressionParser extends LValParser {
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
const oldYieldPos = this.state.yieldPos;
const oldAwaitPos = this.state.awaitPos;
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
this.state.maybeInArrowParameters = true;
this.state.yieldPos = 0;
this.state.awaitPos = 0;
this.state.inFSharpPipelineDirectBody = false;
const innerStartPos = this.state.start;
const innerStartLoc = this.state.startLoc;
@ -1233,6 +1256,7 @@ export default class ExpressionParser extends LValParser {
this.expect(tt.parenR);
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
let arrowNode = this.startNodeAt(startPos, startLoc);
if (
@ -2114,7 +2138,9 @@ export default class ExpressionParser extends LValParser {
);
}
if (!this.state.soloAwait) {
node.argument = this.parseMaybeUnary();
}
return this.finishNode(node, "AwaitExpression");
}
@ -2304,6 +2330,17 @@ export default class ExpressionParser extends LValParser {
}
}
withSoloAwaitPermittingContext<T>(callback: () => T): T {
const outerContextSoloAwaitState = this.state.soloAwait;
this.state.soloAwait = true;
try {
return callback();
} finally {
this.state.soloAwait = outerContextSoloAwaitState;
}
}
// Register the use of a primary topic reference (`#`) within the current
// topic context.
registerTopicReference(): void {
@ -2320,4 +2357,25 @@ export default class ExpressionParser extends LValParser {
this.state.topicContext.maxTopicIndex >= 0
);
}
parseFSharpPipelineBody(prec: number, noIn: ?boolean): N.Expression {
const startPos = this.state.start;
const startLoc = this.state.startLoc;
this.state.potentialArrowAt = this.state.start;
const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
this.state.inFSharpPipelineDirectBody = true;
const ret = this.parseExprOp(
this.parseMaybeUnary(),
startPos,
startLoc,
prec,
noIn,
);
this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
return ret;
}
}

View File

@ -38,7 +38,7 @@ export function getPluginOption(
return null;
}
const PIPELINE_PROPOSALS = ["minimal", "smart"];
const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"];
export function validatePlugins(plugins: PluginList) {
if (hasPlugin(plugins, "decorators")) {

View File

@ -77,6 +77,10 @@ export default class State {
maxTopicIndex: null,
};
// For the F# plugin
soloAwait: boolean = false;
inFSharpPipelineDirectBody: boolean = false;
// Check whether we are in a (nested) class or not.
classLevel: number = 0;

View File

@ -1,4 +1,4 @@
{
"plugins": [["pipelineOperator", { "proposal": "invalid" }]],
"throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: 'minimal', 'smart'"
"throws": "'pipelineOperator' requires 'proposal' option whose value should be one of: 'minimal', 'smart', 'fsharp'"
}

View File

@ -0,0 +1 @@
x => x |> [y => y + 1 |> z => z * 2]

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,333 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 36
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ArrayExpression",
"start": 10,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 36
}
},
"elements": [
{
"type": "ArrowFunctionExpression",
"start": 11,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 35
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 16,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 35
}
},
"left": {
"type": "BinaryExpression",
"start": 16,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 21
}
},
"left": {
"type": "Identifier",
"start": 16,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 25,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 35
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 30,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 30
},
"end": {
"line": 1,
"column": 35
}
},
"left": {
"type": "Identifier",
"start": 30,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 30
},
"end": {
"line": 1,
"column": 31
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 35
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
]
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x => x |> [y => y + 1] |> z => z * 2

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,333 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 36
}
},
"left": {
"type": "BinaryExpression",
"start": 5,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 22
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ArrayExpression",
"start": 10,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 22
}
},
"elements": [
{
"type": "ArrowFunctionExpression",
"start": 11,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 21
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 16,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 21
}
},
"left": {
"type": "Identifier",
"start": 16,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
]
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 26,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 36
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 27
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 31,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 36
}
},
"left": {
"type": "Identifier",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 32
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 35,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 36
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,240 @@
{
"type": "File",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"program": {
"type": "Program",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 27
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 27
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "CallExpression",
"start": 10,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 27
}
},
"callee": {
"type": "Identifier",
"start": 10,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 13
},
"identifierName": "foo"
},
"name": "foo"
},
"arguments": [
{
"type": "AssignmentExpression",
"start": 14,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 26
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "BinaryExpression",
"start": 18,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 26
}
},
"left": {
"type": "NumericLiteral",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 23,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 26
},
"identifierName": "foo"
},
"name": "foo"
}
}
}
]
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x => x |> { method: y => y + 1 |> z => z * 2 }

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,368 @@
{
"type": "File",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"program": {
"type": "Program",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 46
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ObjectExpression",
"start": 10,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 46
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 12,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 44
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "method"
},
"name": "method"
},
"computed": false,
"shorthand": false,
"value": {
"type": "ArrowFunctionExpression",
"start": 20,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 44
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 25,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 44
}
},
"left": {
"type": "BinaryExpression",
"start": 25,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 30
}
},
"left": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 30
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 34,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 44
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 35
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 39,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 44
}
},
"left": {
"type": "Identifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 43,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 43
},
"end": {
"line": 1,
"column": 44
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
}
]
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x => x |> { method: y => y + 1 } |> z => z * 2

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,368 @@
{
"type": "File",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"program": {
"type": "Program",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 46
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 46
}
},
"left": {
"type": "BinaryExpression",
"start": 5,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 32
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ObjectExpression",
"start": 10,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 32
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 12,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 30
}
},
"method": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "method"
},
"name": "method"
},
"computed": false,
"shorthand": false,
"value": {
"type": "ArrowFunctionExpression",
"start": 20,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 30
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 25,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 30
}
},
"left": {
"type": "Identifier",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 26
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 30
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
}
]
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 36,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 36
},
"end": {
"line": 1,
"column": 46
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 36,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 36
},
"end": {
"line": 1,
"column": 37
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 41,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 41
},
"end": {
"line": 1,
"column": 46
}
},
"left": {
"type": "Identifier",
"start": 41,
"end": 42,
"loc": {
"start": {
"line": 1,
"column": 41
},
"end": {
"line": 1,
"column": 42
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 45,
"end": 46,
"loc": {
"start": {
"line": 1,
"column": 45
},
"end": {
"line": 1,
"column": 46
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,170 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 23
}
},
"left": {
"type": "BinaryExpression",
"start": 5,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 13
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 10,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 13
},
"identifierName": "inc"
},
"name": "inc"
}
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 17,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 23
},
"identifierName": "double"
},
"name": "double"
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x => x |> inc |> double

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,170 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 23
}
},
"left": {
"type": "BinaryExpression",
"start": 5,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 13
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 10,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 13
},
"identifierName": "inc"
},
"name": "inc"
}
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 17,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 23
},
"identifierName": "double"
},
"name": "double"
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x => x |> (y => y + 3 |> (b => y + b))

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,321 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 38
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 11,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 37
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 11,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 16,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 37
}
},
"left": {
"type": "BinaryExpression",
"start": 16,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 21
}
},
"left": {
"type": "Identifier",
"start": 16,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"extra": {
"rawValue": 3,
"raw": "3"
},
"value": 3
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 26,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 36
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 27
},
"identifierName": "b"
},
"name": "b"
}
],
"body": {
"type": "BinaryExpression",
"start": 31,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 36
}
},
"left": {
"type": "Identifier",
"start": 31,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 31
},
"end": {
"line": 1,
"column": 32
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "Identifier",
"start": 35,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 36
},
"identifierName": "b"
},
"name": "b"
}
},
"extra": {
"parenthesized": true,
"parenStart": 25
}
}
},
"extra": {
"parenthesized": true,
"parenStart": 10
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,316 @@
{
"type": "File",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 17
}
},
"program": {
"type": "Program",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 17
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 17
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 17
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1,
"end": 2,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 7,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 3,
"column": 17
}
},
"left": {
"type": "BinaryExpression",
"start": 7,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 2,
"column": 17
}
},
"left": {
"type": "Identifier",
"start": 7,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 8
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 14,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 17
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 21,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 17
}
},
"left": {
"type": "Identifier",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 13
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 25,
"end": 26,
"loc": {
"start": {
"line": 2,
"column": 16
},
"end": {
"line": 2,
"column": 17
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 32,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 17
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 7
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 39,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 12
},
"end": {
"line": 3,
"column": 17
}
},
"left": {
"type": "Identifier",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 3,
"column": 12
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 43,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 16
},
"end": {
"line": 3,
"column": 17
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
x => x
|> y => y + 1
|> z => z * 2

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,316 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 15
}
},
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 15
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 15
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 15
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 3,
"column": 15
}
},
"left": {
"type": "BinaryExpression",
"start": 5,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 2,
"column": 15
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 12,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 15
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 12,
"end": 13,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 17,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 15
}
},
"left": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 11
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 21,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 14
},
"end": {
"line": 2,
"column": 15
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 28,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 15
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 28,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 6
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 33,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 15
}
},
"left": {
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 11
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 37,
"end": 38,
"loc": {
"start": {
"line": 3,
"column": 14
},
"end": {
"line": 3,
"column": 15
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
(x) => x |> (y) => y + 1 |> (z) => z * 2

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,316 @@
{
"type": "File",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"program": {
"type": "Program",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 40
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1,
"end": 2,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 7,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 40
}
},
"left": {
"type": "BinaryExpression",
"start": 7,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 24
}
},
"left": {
"type": "Identifier",
"start": 7,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 8
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 12,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 24
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 13,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 19,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 24
}
},
"left": {
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 28,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 40
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 30
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 35,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 40
}
},
"left": {
"type": "Identifier",
"start": 35,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 35
},
"end": {
"line": 1,
"column": 36
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 39,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 40
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x => x |> y => y + 1 |> z => z * 2

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,316 @@
{
"type": "File",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"program": {
"type": "Program",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 34
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start": 5,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 34
}
},
"left": {
"type": "BinaryExpression",
"start": 5,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 20
}
},
"left": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 10,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 20
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "y"
},
"name": "y"
}
],
"body": {
"type": "BinaryExpression",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"left": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 20
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start": 24,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 34
}
},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 25
},
"identifierName": "z"
},
"name": "z"
}
],
"body": {
"type": "BinaryExpression",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 34
}
},
"left": {
"type": "Identifier",
"start": 29,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 30
},
"identifierName": "z"
},
"name": "z"
},
"operator": "*",
"right": {
"type": "NumericLiteral",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 34
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
async function test () {
return x |> await;
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,151 @@
{
"type": "File",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 15,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 19
},
"identifierName": "test"
},
"name": "test"
},
"generator": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start": 23,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ReturnStatement",
"start": 27,
"end": 45,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 20
}
},
"argument": {
"type": "BinaryExpression",
"start": 34,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 19
}
},
"left": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "AwaitExpression",
"start": 39,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 14
},
"end": {
"line": 2,
"column": 19
}
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
async function test () {
return x |> await |> f;
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,184 @@
{
"type": "File",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 15,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 19
},
"identifierName": "test"
},
"name": "test"
},
"generator": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start": 23,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ReturnStatement",
"start": 27,
"end": 50,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 25
}
},
"argument": {
"type": "BinaryExpression",
"start": 34,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 24
}
},
"left": {
"type": "BinaryExpression",
"start": 34,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 19
}
},
"left": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "AwaitExpression",
"start": 39,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 14
},
"end": {
"line": 2,
"column": 19
}
}
}
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 48,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 24
},
"identifierName": "f"
},
"name": "f"
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
async function test () {
return x |> await f;
}

View File

@ -0,0 +1,4 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]],
"throws": "Unexpected token, expected \";\" (2:20)"
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,100 @@
{
"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",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 6
}
},
"expression": {
"type": "BinaryExpression",
"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"
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 5,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "b"
},
"name": "b"
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x |> inc |> double

View File

@ -0,0 +1,3 @@
{
"plugins": [["pipelineOperator", { "proposal": "fsharp" }]]
}

View File

@ -0,0 +1,133 @@
{
"type": "File",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"program": {
"type": "Program",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"expression": {
"type": "BinaryExpression",
"start": 0,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 18
}
},
"left": {
"type": "BinaryExpression",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"left": {
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "x"
},
"name": "x"
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 5,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 8
},
"identifierName": "inc"
},
"name": "inc"
}
},
"operator": "|>",
"right": {
"type": "Identifier",
"start": 12,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "double"
},
"name": "double"
}
}
}
],
"directives": []
}
}