Caret topic (pipe operator) (#13749)

* parser: Add caret as topic reference (tests)

* parser: Add caret as topic reference (implement)

* generator: Avoid reconstructing validTopicTokenSet

* babel-parser: Remove redundant throws in expression.js

* Minimize diff

* Update error message

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
J. S. Choi 2021-10-28 16:04:55 -04:00 committed by GitHub
parent ddc45a5a50
commit ad59a2c618
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
402 changed files with 7200 additions and 128 deletions

View File

@ -238,18 +238,19 @@ export function DecimalLiteral(this: Printer, node: t.DecimalLiteral) {
} }
// Hack pipe operator // Hack pipe operator
const validTopicTokenSet = new Set(["^", "%", "#"]);
export function TopicReference(this: Printer) { export function TopicReference(this: Printer) {
const { topicToken } = this.format; const { topicToken } = this.format;
switch (topicToken) {
case "#":
this.token("#");
break;
default: { if (validTopicTokenSet.has(topicToken)) {
const givenTopicTokenJSON = JSON.stringify(topicToken); this.token(topicToken);
const message = `The "topicToken" generator option must be "#" (${givenTopicTokenJSON} received instead).`; } else {
throw new Error(message); const givenTopicTokenJSON = JSON.stringify(topicToken);
} const validTopics = Array.from(validTopicTokenSet, v => JSON.stringify(v));
throw new Error(
`The "topicToken" generator option must be one of ` +
`${validTopics.join(", ")} (${givenTopicTokenJSON} received instead).`,
);
} }
} }

View File

@ -203,7 +203,7 @@ export interface GeneratorOptions {
* For use with the Hack-style pipe operator. * For use with the Hack-style pipe operator.
* Changes what token is used for pipe bodies topic references. * Changes what token is used for pipe bodies topic references.
*/ */
topicToken?: "#"; topicToken?: "^" | "%" | "#";
} }
export interface GeneratorResult { export interface GeneratorResult {

View File

@ -0,0 +1 @@
2 + 3 |> ^.toString(16);

View File

@ -0,0 +1,4 @@
{
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "^" }]],
"topicToken": "^"
}

View File

@ -0,0 +1 @@
2 + 3 |> ^.toString(16);

View File

@ -1,5 +1,5 @@
{ {
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]],
"topicToken": "invalid", "topicToken": "invalid",
"throws": "The \"topicToken\" generator option must be \"#\" (\"invalid\" received instead)." "throws": "The \"topicToken\" generator option must be one of \"^\", \"%\", \"#\" (\"invalid\" received instead)."
} }

View File

@ -1,4 +1,4 @@
{ {
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]], "plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "#" }]],
"throws": "The \"topicToken\" generator option must be \"#\" (undefined received instead)." "throws": "The \"topicToken\" generator option must be one of \"^\", \"%\", \"#\" (undefined received instead)."
} }

View File

@ -0,0 +1 @@
2 + 3 |> %.toString(16);

View File

@ -0,0 +1,4 @@
{
"plugins": [["pipelineOperator", { "proposal": "hack", "topicToken": "%" }]],
"topicToken": "%"
}

View File

@ -0,0 +1 @@
2 + 3 |> %.toString(16);

View File

@ -1193,26 +1193,15 @@ export default class ExpressionParser extends LValParser {
return this.parsePrivateName(); return this.parsePrivateName();
} }
case tt.moduloAssign: case tt.moduloAssign: {
if ( return this.parseTopicReferenceThenEqualsSign(tt.modulo, "%");
this.getPluginOption("pipelineOperator", "proposal") === "hack" && }
this.getPluginOption("pipelineOperator", "topicToken") === "%"
) {
// If we find %= in an expression position, and the Hack-pipes proposal is active,
// then the % could be the topic token (e.g., in x |> %==y or x |> %===y), and so we
// reparse it as %.
// The next readToken() call will start parsing from =.
this.state.value = "%"; case tt.xorAssign: {
this.state.type = tt.modulo; return this.parseTopicReferenceThenEqualsSign(tt.bitwiseXOR, "^");
this.state.pos--; }
this.state.end--;
this.state.endLoc.column--;
} else {
throw this.unexpected();
}
// falls through case tt.bitwiseXOR:
case tt.modulo: case tt.modulo:
case tt.hash: { case tt.hash: {
const pipeProposal = this.getPluginOption( const pipeProposal = this.getPluginOption(
@ -1221,24 +1210,7 @@ export default class ExpressionParser extends LValParser {
); );
if (pipeProposal) { if (pipeProposal) {
// A pipe-operator proposal is active, return this.parseTopicReference(pipeProposal);
// although its configuration might not match the current tokens type.
node = this.startNode();
const start = this.state.start;
const tokenType = this.state.type;
// Consume the current token.
this.next();
// If the pipe-operator plugins configuration matches the current tokens type,
// then this will return `node`, will have been finished as a topic reference.
// Otherwise, this will throw a `PipeTopicUnconfiguredToken` error.
return this.finishTopicReference(
node,
start,
pipeProposal,
tokenType,
);
} }
} }
@ -1325,6 +1297,61 @@ export default class ExpressionParser extends LValParser {
} }
} }
// This helper method should only be called
// when the parser has reached a potential Hack pipe topic token
// that is followed by an equals sign.
// See <https://github.com/js-choi/proposal-hack-pipes>.
// If we find ^= or %= in an expression position
// (i.e., the tt.moduloAssign or tt.xorAssign token types),
// and if the Hack-pipes proposal is active with ^ or % as its topicToken,
// then the ^ or % could be the topic token (e.g., in x |> ^==y or x |> ^===y),
// and so we reparse the current token as ^ or %.
// Otherwise, this throws an unexpected-token error.
parseTopicReferenceThenEqualsSign(
topicTokenType: TokenType,
topicTokenValue: string,
): N.Expression {
const pipeProposal = this.getPluginOption("pipelineOperator", "proposal");
if (pipeProposal) {
// Set the most-recent token to be a topic token
// given by the tokenType and tokenValue.
// Now the next readToken() call (in parseTopicReference)
// will consume that “topic token”.
this.state.type = topicTokenType;
this.state.value = topicTokenValue;
// Rewind the tokenizer to the end of the “topic token”,
// so that the following token starts at the equals sign after that topic token.
this.state.pos--;
this.state.end--;
this.state.endLoc.column--;
// Now actually consume the topic token.
return this.parseTopicReference(pipeProposal);
} else {
throw this.unexpected();
}
}
// This helper method should only be called
// when the proposal-pipeline-operator plugin is active,
// and when the parser has reached a potential Hack pipe topic token.
// Although a pipe-operator proposal is assumed to be active,
// its configuration might not match the current tokens type.
// See <https://github.com/js-choi/proposal-hack-pipes>.
parseTopicReference(pipeProposal: string): N.Expression {
const node = this.startNode();
const start = this.state.start;
const tokenType = this.state.type;
// Consume the current token.
this.next();
// If the pipe-operator plugins configuration matches the current tokens type,
// then this will return `node`, will have been finished as a topic reference.
// Otherwise, this will throw a `PipeTopicUnconfiguredToken` error.
return this.finishTopicReference(node, start, pipeProposal, tokenType);
}
// This helper method attempts to finish the given `node` // This helper method attempts to finish the given `node`
// into a topic-reference node for the given `pipeProposal`. // into a topic-reference node for the given `pipeProposal`.
// See <https://github.com/js-choi/proposal-hack-pipes>. // See <https://github.com/js-choi/proposal-hack-pipes>.

View File

@ -39,7 +39,7 @@ export function getPluginOption(
} }
const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"]; const PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
const TOPIC_TOKENS = ["%", "#"]; const TOPIC_TOKENS = ["^", "%", "#"];
const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
export function validatePlugins(plugins: PluginList) { export function validatePlugins(plugins: PluginList) {

View File

@ -605,20 +605,24 @@ export default class Tokenizer extends ParserErrors {
} }
readToken_mult_modulo(code: number): void { readToken_mult_modulo(code: number): void {
// '%*' // '%' or '*'
let type = code === charCodes.asterisk ? tt.star : tt.modulo; let type = code === charCodes.asterisk ? tt.star : tt.modulo;
let width = 1; let width = 1;
let next = this.input.charCodeAt(this.state.pos + 1); let next = this.input.charCodeAt(this.state.pos + 1);
// Exponentiation operator ** // Exponentiation operator '**'
if (code === charCodes.asterisk && next === charCodes.asterisk) { if (code === charCodes.asterisk && next === charCodes.asterisk) {
width++; width++;
next = this.input.charCodeAt(this.state.pos + 2); next = this.input.charCodeAt(this.state.pos + 2);
type = tt.exponent; type = tt.exponent;
} }
// '%=' or '*='
if (next === charCodes.equalsTo && !this.state.inType) { if (next === charCodes.equalsTo && !this.state.inType) {
width++; width++;
// `tt.moduloAssign` is only needed to support % as a Hack-pipe topic token.
// If the proposal ends up choosing a different token,
// it can be merged with tt.assign.
type = code === charCodes.percentSign ? tt.moduloAssign : tt.assign; type = code === charCodes.percentSign ? tt.moduloAssign : tt.assign;
} }
@ -692,11 +696,17 @@ export default class Tokenizer extends ParserErrors {
} }
readToken_caret(): void { readToken_caret(): void {
// '^'
const next = this.input.charCodeAt(this.state.pos + 1); const next = this.input.charCodeAt(this.state.pos + 1);
if (next === charCodes.equalsTo) {
this.finishOp(tt.assign, 2); // '^='
} else { if (next === charCodes.equalsTo && !this.state.inType) {
// `tt.xorAssign` is only needed to support ^ as a Hack-pipe topic token.
// If the proposal ends up choosing a different token,
// it can be merged with tt.assign.
this.finishOp(tt.xorAssign, 2);
}
// '^'
else {
this.finishOp(tt.bitwiseXOR, 1); this.finishOp(tt.bitwiseXOR, 1);
} }
} }

View File

@ -182,8 +182,9 @@ export const tt: { [name: string]: TokenType } = {
eq: createToken("=", { beforeExpr, isAssign }), eq: createToken("=", { beforeExpr, isAssign }),
assign: createToken("_=", { beforeExpr, isAssign }), assign: createToken("_=", { beforeExpr, isAssign }),
slashAssign: createToken("_=", { beforeExpr, isAssign }), slashAssign: createToken("_=", { beforeExpr, isAssign }),
// This is only needed to support % as a Hack-pipe topic token. If the proposal // These are only needed to support % and ^ as a Hack-pipe topic token. When the
// ends up choosing a different token, it can be merged with tt.assign. // proposal settles on a token, the others can be merged with tt.assign.
xorAssign: createToken("_=", { beforeExpr, isAssign }),
moduloAssign: createToken("_=", { beforeExpr, isAssign }), moduloAssign: createToken("_=", { beforeExpr, isAssign }),
// end: isAssign // end: isAssign

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"program": {
"type": "Program",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}},
"left": {
"type": "TopicReference",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}
},
"operator": "+",
"right": {
"type": "NumericLiteral",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"program": {
"type": "Program",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}},
"left": {
"type": "NumericLiteral",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"operator": "+",
"right": {
"type": "TopicReference",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"errors": [
"SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:9)"
],
"program": {
"type": "Program",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}},
"left": {
"type": "Identifier",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"},
"name": "a"
},
"operator": "+",
"right": {
"type": "Identifier",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"b"},
"name": "b"
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,57 @@
{
"type": "File",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
"program": {
"type": "Program",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start":10,"end":21,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":21}},
"extra": {
"parenthesized": true,
"parenStart": 9
},
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BinaryExpression",
"start":16,"end":21,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":21}},
"left": {
"type": "TopicReference",
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}}
},
"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
}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,11 @@
{
"plugins": [
[
"pipelineOperator",
{
"proposal": "hack",
"topicToken": "^"
}
]
]
}

View File

@ -0,0 +1,62 @@
{
"type": "File",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"errors": [
"SyntaxError: Hack-style pipe body cannot be an unparenthesized arrow function expression; please wrap it in parentheses. (1:6)"
],
"program": {
"type": "Program",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
"left": {
"type": "NumericLiteral",
"start":0,"end":2,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":2}},
"extra": {
"rawValue": 10,
"raw": "10"
},
"value": 10
},
"operator": "|>",
"right": {
"type": "ArrowFunctionExpression",
"start":6,"end":16,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":16}},
"id": null,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start":6,"end":7,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7},"identifierName":"x"},
"name": "x"
}
],
"body": {
"type": "BinaryExpression",
"start":11,"end":16,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":16}},
"left": {
"type": "Identifier",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"},
"name": "x"
},
"operator": "+",
"right": {
"type": "TopicReference",
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}
}
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
"program": {
"type": "Program",
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":25,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":25}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":24,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":24}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "AssignmentExpression",
"start":10,"end":23,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":23}},
"extra": {
"parenthesized": true,
"parenStart": 9
},
"operator": "^=",
"left": {
"type": "Identifier",
"start":10,"end":18,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":18},"identifierName":"variable"},
"name": "variable"
},
"right": {
"type": "TopicReference",
"start":22,"end":23,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":23}}
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"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": "BinaryExpression",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":22}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "AssignmentExpression",
"start":10,"end":21,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":21}},
"extra": {
"parenthesized": true,
"parenStart": 9
},
"operator": "^=",
"left": {
"type": "Identifier",
"start":10,"end":18,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":18},"identifierName":"variable"},
"name": "variable"
},
"right": {
"type": "TopicReference",
"start":20,"end":21,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":21}}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,11 @@
{
"plugins": [
[
"pipelineOperator",
{
"proposal": "hack",
"topicToken": "^"
}
]
]
}

View File

@ -0,0 +1,45 @@
{
"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": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "AssignmentExpression",
"start":10,"end":17,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":17}},
"operator": "&&=",
"left": {
"type": "Identifier",
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "TopicReference",
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}}
},
"extra": {
"parenthesized": true,
"parenStart": 9
}
}
}
}
],
"directives": []
}
}

View File

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

View File

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

View File

@ -0,0 +1,11 @@
{
"plugins": [
[
"pipelineOperator",
{
"proposal": "hack",
"topicToken": "^"
}
]
]
}

View File

@ -0,0 +1,56 @@
{
"type": "File",
"start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}},
"program": {
"type": "Program",
"start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "AssignmentExpression",
"start":10,"end":20,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":20}},
"operator": "=",
"left": {
"type": "ArrayPattern",
"start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}},
"elements": [
{
"type": "Identifier",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"x"},
"name": "x"
},
{
"type": "Identifier",
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15},"identifierName":"y"},
"name": "y"
}
]
},
"right": {
"type": "TopicReference",
"start":19,"end":20,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}
},
"extra": {
"parenthesized": true,
"parenStart": 9
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,11 @@
{
"plugins": [
[
"pipelineOperator",
{
"proposal": "hack",
"topicToken": "^"
}
]
]
}

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"program": {
"type": "Program",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "AssignmentExpression",
"start":10,"end":16,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":16}},
"operator": "+=",
"left": {
"type": "Identifier",
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "TopicReference",
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}
},
"extra": {
"parenthesized": true,
"parenStart": 9
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,52 @@
{
"type": "File",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"errors": [
"SyntaxError: Invalid left-hand side in assignment expression. (1:10)"
],
"program": {
"type": "Program",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":16,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":16}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "AssignmentExpression",
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15}},
"extra": {
"parenthesized": true,
"parenStart": 9
},
"operator": "=",
"left": {
"type": "TopicReference",
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}}
},
"right": {
"type": "NumericLiteral",
"start":14,"end":15,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":15}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,11 @@
{
"plugins": [
[
"pipelineOperator",
{
"proposal": "hack",
"topicToken": "^"
}
]
]
}

View File

@ -0,0 +1,55 @@
{
"type": "File",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
"errors": [
"SyntaxError: Hack-style pipe body cannot be an unparenthesized assignment expression; please wrap it in parentheses. (1:9)"
],
"program": {
"type": "Program",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":19}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "AssignmentExpression",
"start":9,"end":19,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":19}},
"operator": "=",
"left": {
"type": "ArrayPattern",
"start":9,"end":15,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":15}},
"elements": [
{
"type": "Identifier",
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11},"identifierName":"x"},
"name": "x"
},
{
"type": "Identifier",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"y"},
"name": "y"
}
]
},
"right": {
"type": "TopicReference",
"start":18,"end":19,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":19}}
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,66 @@
{
"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":17,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":17}},
"left": {
"type": "NumericLiteral",
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":5,"end":17,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":17}},
"left": {
"type": "CallExpression",
"start":5,"end":9,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":9}},
"callee": {
"type": "Identifier",
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6},"identifierName":"f"},
"name": "f"
},
"arguments": [
{
"type": "TopicReference",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}}
}
]
},
"operator": "|>",
"right": {
"type": "CallExpression",
"start":13,"end":17,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":17}},
"callee": {
"type": "Identifier",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14},"identifierName":"g"},
"name": "g"
},
"arguments": [
{
"type": "TopicReference",
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}
}
]
}
}
}
}
],
"directives": []
}
}

View File

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

View File

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

View File

@ -0,0 +1,54 @@
{
"type": "File",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"program": {
"type": "Program",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "FunctionDeclaration",
"start":0,"end":46,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":1}},
"id": {
"type": "Identifier",
"start":15,"end":16,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16},"identifierName":"f"},
"name": "f"
},
"generator": false,
"async": true,
"params": [],
"body": {
"type": "BlockStatement",
"start":20,"end":46,"loc":{"start":{"line":1,"column":20},"end":{"line":3,"column":1}},
"body": [
{
"type": "ReturnStatement",
"start":24,"end":44,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":22}},
"argument": {
"type": "BinaryExpression",
"start":31,"end":43,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":21}},
"left": {
"type": "Identifier",
"start":31,"end":32,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"x"},
"name": "x"
},
"operator": "|>",
"right": {
"type": "AwaitExpression",
"start":36,"end":43,"loc":{"start":{"line":2,"column":14},"end":{"line":2,"column":21}},
"argument": {
"type": "TopicReference",
"start":42,"end":43,"loc":{"start":{"line":2,"column":20},"end":{"line":2,"column":21}}
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,49 @@
{
"type": "File",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
"program": {
"type": "Program",
"start":0,"end":22,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
"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": "TopicReference",
"start":5,"end":6,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":6}}
}
}
},
{
"type": "FunctionDeclaration",
"start":7,"end":22,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":15}},
"id": {
"type": "Identifier",
"start":16,"end":17,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"f"},
"name": "f"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":20,"end":22,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":15}},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
"program": {
"type": "Program",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":19,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
"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": "FunctionExpression",
"start":4,"end":19,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":15}},
"id": {
"type": "Identifier",
"start":13,"end":14,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":10},"identifierName":"f"},
"name": "f"
},
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":17,"end":19,"loc":{"start":{"line":2,"column":13},"end":{"line":2,"column":15}},
"body": [],
"directives": []
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,40 @@
{
"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",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":9,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":8,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":8}},
"left": {
"type": "NumericLiteral",
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1}},
"extra": {
"rawValue": 5,
"raw": "5"
},
"value": 5
},
"operator": "^",
"right": {
"type": "RegExpLiteral",
"start":4,"end":8,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":8}},
"extra": {
"raw": "/3/g"
},
"pattern": "3",
"flags": "g"
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
"program": {
"type": "Program",
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}},
"left": {
"type": "TopicReference",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}
},
"operator": "^",
"right": {
"type": "NumericLiteral",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"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",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
"left": {
"type": "TopicReference",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}}
},
"operator": "^",
"right": {
"type": "NumericLiteral",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
"program": {
"type": "Program",
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":14,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":14}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":9,"end":14,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":14}},
"left": {
"type": "NumericLiteral",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
},
"operator": "^",
"right": {
"type": "TopicReference",
"start":13,"end":14,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":14}}
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"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",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "BinaryExpression",
"start":9,"end":12,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":12}},
"left": {
"type": "NumericLiteral",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10}},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
},
"operator": "^",
"right": {
"type": "TopicReference",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}}
}
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,9 @@
value |> new (
@classDecorator
class Thing {
@methodDecorator
method () {
return ^ + this.property;
}
}
);

View File

@ -0,0 +1,6 @@
{
"plugins": [
["pipelineOperator", { "proposal": "hack", "topicToken": "^" }],
["decorators", {"decoratorsBeforeExport": true}]
]
}

View File

@ -0,0 +1,124 @@
{
"type": "File",
"start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}},
"program": {
"type": "Program",
"start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":130,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":2}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":129,"loc":{"start":{"line":1,"column":0},"end":{"line":9,"column":1}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "NewExpression",
"start":9,"end":129,"loc":{"start":{"line":1,"column":9},"end":{"line":9,"column":1}},
"callee": {
"type": "ClassExpression",
"start":17,"end":127,"loc":{"start":{"line":2,"column":2},"end":{"line":8,"column":3}},
"extra": {
"parenthesized": true,
"parenStart": 13
},
"decorators": [
{
"type": "Decorator",
"start":17,"end":32,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":17}},
"expression": {
"type": "Identifier",
"start":18,"end":32,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":17},"identifierName":"classDecorator"},
"name": "classDecorator"
}
}
],
"id": {
"type": "Identifier",
"start":41,"end":46,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":13},"identifierName":"Thing"},
"name": "Thing"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start":47,"end":127,"loc":{"start":{"line":3,"column":14},"end":{"line":8,"column":3}},
"body": [
{
"type": "ClassMethod",
"start":53,"end":123,"loc":{"start":{"line":4,"column":4},"end":{"line":7,"column":5}},
"decorators": [
{
"type": "Decorator",
"start":53,"end":69,"loc":{"start":{"line":4,"column":4},"end":{"line":4,"column":20}},
"expression": {
"type": "Identifier",
"start":54,"end":69,"loc":{"start":{"line":4,"column":5},"end":{"line":4,"column":20},"identifierName":"methodDecorator"},
"name": "methodDecorator"
}
}
],
"static": false,
"key": {
"type": "Identifier",
"start":74,"end":80,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":10},"identifierName":"method"},
"name": "method"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":84,"end":123,"loc":{"start":{"line":5,"column":14},"end":{"line":7,"column":5}},
"body": [
{
"type": "ReturnStatement",
"start":92,"end":117,"loc":{"start":{"line":6,"column":6},"end":{"line":6,"column":31}},
"argument": {
"type": "BinaryExpression",
"start":99,"end":116,"loc":{"start":{"line":6,"column":13},"end":{"line":6,"column":30}},
"left": {
"type": "TopicReference",
"start":99,"end":100,"loc":{"start":{"line":6,"column":13},"end":{"line":6,"column":14}}
},
"operator": "+",
"right": {
"type": "MemberExpression",
"start":103,"end":116,"loc":{"start":{"line":6,"column":17},"end":{"line":6,"column":30}},
"object": {
"type": "ThisExpression",
"start":103,"end":107,"loc":{"start":{"line":6,"column":17},"end":{"line":6,"column":21}}
},
"computed": false,
"property": {
"type": "Identifier",
"start":108,"end":116,"loc":{"start":{"line":6,"column":22},"end":{"line":6,"column":30},"identifierName":"property"},
"name": "property"
}
}
}
}
],
"directives": []
}
}
]
}
},
"arguments": []
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,7 @@
value |> new (class Thing {
#property;
method () {
return ^ + this.#property;
}
});

View File

@ -0,0 +1,7 @@
{
"plugins": [
["pipelineOperator", { "proposal": "hack", "topicToken": "^" }],
"classPrivateProperties",
"classPrivateMethods"
]
}

View File

@ -0,0 +1,121 @@
{
"type": "File",
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}},
"program": {
"type": "Program",
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":94,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":3}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":93,"loc":{"start":{"line":1,"column":0},"end":{"line":7,"column":2}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "NewExpression",
"start":9,"end":93,"loc":{"start":{"line":1,"column":9},"end":{"line":7,"column":2}},
"callee": {
"type": "ClassExpression",
"start":14,"end":92,"loc":{"start":{"line":1,"column":14},"end":{"line":7,"column":1}},
"extra": {
"parenthesized": true,
"parenStart": 13
},
"id": {
"type": "Identifier",
"start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25},"identifierName":"Thing"},
"name": "Thing"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start":26,"end":92,"loc":{"start":{"line":1,"column":26},"end":{"line":7,"column":1}},
"body": [
{
"type": "ClassPrivateProperty",
"start":30,"end":40,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":12}},
"static": false,
"key": {
"type": "PrivateName",
"start":30,"end":39,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":11}},
"id": {
"type": "Identifier",
"start":31,"end":39,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":11},"identifierName":"property"},
"name": "property"
}
},
"value": null
},
{
"type": "ClassMethod",
"start":44,"end":90,"loc":{"start":{"line":4,"column":2},"end":{"line":6,"column":3}},
"static": false,
"key": {
"type": "Identifier",
"start":44,"end":50,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":8},"identifierName":"method"},
"name": "method"
},
"computed": false,
"kind": "method",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":54,"end":90,"loc":{"start":{"line":4,"column":12},"end":{"line":6,"column":3}},
"body": [
{
"type": "ReturnStatement",
"start":60,"end":86,"loc":{"start":{"line":5,"column":4},"end":{"line":5,"column":30}},
"argument": {
"type": "BinaryExpression",
"start":67,"end":85,"loc":{"start":{"line":5,"column":11},"end":{"line":5,"column":29}},
"left": {
"type": "TopicReference",
"start":67,"end":68,"loc":{"start":{"line":5,"column":11},"end":{"line":5,"column":12}}
},
"operator": "+",
"right": {
"type": "MemberExpression",
"start":71,"end":85,"loc":{"start":{"line":5,"column":15},"end":{"line":5,"column":29}},
"object": {
"type": "ThisExpression",
"start":71,"end":75,"loc":{"start":{"line":5,"column":15},"end":{"line":5,"column":19}}
},
"computed": false,
"property": {
"type": "PrivateName",
"start":76,"end":85,"loc":{"start":{"line":5,"column":20},"end":{"line":5,"column":29}},
"id": {
"type": "Identifier",
"start":77,"end":85,"loc":{"start":{"line":5,"column":21},"end":{"line":5,"column":29},"identifierName":"property"},
"name": "property"
}
}
}
}
}
],
"directives": []
}
}
]
}
},
"arguments": []
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
x |> class { constructor () { this.x = ^; } }

View File

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

View File

@ -0,0 +1,89 @@
{
"type": "File",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"program": {
"type": "Program",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"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": "ClassExpression",
"start":5,"end":45,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":45}},
"id": null,
"superClass": null,
"body": {
"type": "ClassBody",
"start":11,"end":45,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":45}},
"body": [
{
"type": "ClassMethod",
"start":13,"end":43,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":43}},
"static": false,
"key": {
"type": "Identifier",
"start":13,"end":24,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":24},"identifierName":"constructor"},
"name": "constructor"
},
"computed": false,
"kind": "constructor",
"id": null,
"generator": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start":28,"end":43,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":43}},
"body": [
{
"type": "ExpressionStatement",
"start":30,"end":41,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":41}},
"expression": {
"type": "AssignmentExpression",
"start":30,"end":40,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":40}},
"operator": "=",
"left": {
"type": "MemberExpression",
"start":30,"end":36,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":36}},
"object": {
"type": "ThisExpression",
"start":30,"end":34,"loc":{"start":{"line":1,"column":30},"end":{"line":1,"column":34}}
},
"computed": false,
"property": {
"type": "Identifier",
"start":35,"end":36,"loc":{"start":{"line":1,"column":35},"end":{"line":1,"column":36},"identifierName":"x"},
"name": "x"
}
},
"right": {
"type": "TopicReference",
"start":39,"end":40,"loc":{"start":{"line":1,"column":39},"end":{"line":1,"column":40}}
}
}
}
],
"directives": []
}
}
]
}
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,49 @@
{
"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",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":12,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":12}},
"left": {
"type": "NumericLiteral",
"start":0,"end":2,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":2}},
"extra": {
"rawValue": 10,
"raw": "10"
},
"value": 10
},
"operator": "|>",
"right": {
"type": "SequenceExpression",
"start":7,"end":11,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":11}},
"extra": {
"parenthesized": true,
"parenStart": 6
},
"expressions": [
{
"type": "TopicReference",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}}
},
{
"type": "TopicReference",
"start":10,"end":11,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":11}}
}
]
}
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,45 @@
{
"type": "File",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"errors": [
"SyntaxError: Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once. (1:9)"
],
"program": {
"type": "Program",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"expression": {
"type": "BinaryExpression",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"left": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"value"},
"name": "value"
},
"operator": "|>",
"right": {
"type": "MemberExpression",
"start":9,"end":13,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":13}},
"object": {
"type": "Identifier",
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"a"},
"name": "a"
},
"computed": true,
"property": {
"type": "Identifier",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12},"identifierName":"b"},
"name": "b"
}
}
}
}
],
"directives": []
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More