forked from lightscript/babylon-lightscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Syntactic placeholders - Pipe calls `|>`, `<|` - Track block nesting level in parser state - Fix bang call subscript unwinding crossing block boundaries - Fix premature “comprehensions are illegal” error disallowing patterns with “for” or “case” keys - Don’t lint when testing commit 64f066f Author: William C. Johnson <wcjohnson@oigroup.net> Date: Mon Sep 25 15:36:41 2017 -0400 Fix for bang call subscripting issue across block boundaries commit bda54e5 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Mon Sep 25 14:38:44 2017 -0400 Comprehension fixes commit 476419a Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sat Sep 23 15:53:55 2017 -0400 Run lint and flow at `preversion`, not `test` commit 266f948 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Mon Sep 18 23:16:07 2017 -0400 @oigroup/babylon-lightscript@2.3.0-alpha.3 commit 2342c39 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Tue Sep 5 16:51:01 2017 -0400 @oigroup/babylon-lightscript@2.3.0-alpha.2 commit 21a26a8 Merge: e61679c 7c5e20e Author: William C. Johnson <wcjohnson@oigroup.net> Date: Tue Sep 5 15:24:38 2017 -0400 Merge branch 'prerelease/2.3.0' of https://github.com/wcjohnson/babylon-lightscript into prerelease/2.3.0 commit e61679c Author: William C. Johnson <wcjohnson@oigroup.net> Date: Tue Sep 5 15:24:20 2017 -0400 Unit test for unfortunate flow typecast in if test clause commit 7c5e20e Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Aug 6 12:58:46 2017 -0400 Misc cleanup - Remove errant copypasta from tildeCall.js - Clean up spacing/comments commit ffb7ddb Author: William C. Johnson <wcjohnson@oigroup.net> Date: Wed Jul 19 21:43:42 2017 -0400 @oigroup/babylon-lightscript@2.3.0-alpha.1 commit fb570ee Author: William C. Johnson <wcjohnson@oigroup.net> Date: Wed Jul 19 21:28:23 2017 -0400 Pipe call improvements - Support arrows as pipe call operands - Support leftward-pointing pipe calls commit f248451 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Mon Jul 17 16:09:12 2017 -0400 @oigroup/babylon-lightscript@2.3.0-alpha.0 commit 00a76ef Author: William C. Johnson <wcjohnson@oigroup.net> Date: Mon Jul 17 15:52:31 2017 -0400 Fix for left-associativity and subscripts of pipeCalls commit 6d4d300 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Mon Jul 17 00:43:08 2017 -0400 `pipeCall` tests commit 4e579c7 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Mon Jul 17 00:28:40 2017 -0400 @oigroup/babylon-lightscript@2.3.0-2 commit 17f5a44 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 23:19:22 2017 -0400 @oigroup/babylon-lightscript@2.3.0-1 commit 0bcd865 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 23:07:36 2017 -0400 @oigroup/babylon-lightscript@2.3.0-0 commit 6975053 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 23:03:53 2017 -0400 Parsing for pipe operator commit b10a5e48d1552ff389de314762e863197bc0da7e Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 22:55:34 2017 -0400 Fix associativity commit 0fac7c226b9cd9cda94a5956a45a067a145e2976 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 22:22:34 2017 -0400 Parse pipe operator as subscript commit b21acb2f12941d9d7d4279320de4c55c7ee3b50f Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 21:17:17 2017 -0400 Basic pipeCall parsing commit 70ee2c8 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 20:46:52 2017 -0400 Syntactic placeholders commit d5d4e74 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 20:41:48 2017 -0400 Allow placeholder to be changed via config commit 32e43a0 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 20:24:59 2017 -0400 Spread placeholder tests commit 73b9d32 Author: William C. Johnson <wcjohnson@oigroup.net> Date: Sun Jul 16 15:31:50 2017 -0400 Initial implementation of syntactic placeholders
- Loading branch information
Showing
48 changed files
with
2,043 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Parser from "../parser"; | ||
import { types as tt, TokenType } from "../tokenizer/types"; | ||
const pp = Parser.prototype; | ||
|
||
export default function(parser) { | ||
if (parser.__pipeCallPluginInstalled) return; | ||
parser.__pipeCallPluginInstalled = true; | ||
|
||
tt.pipeCall = new TokenType("|>"); | ||
|
||
pp.parsePipeCall = function(node, left) { | ||
if (this.state.value === "|>") { | ||
return this.parseRightPointingPipeCall(node, left); | ||
} else { | ||
return this.parseLeftPointingPipeCall(node, left); | ||
} | ||
}; | ||
|
||
pp.parseRightPointingPipeCall = function(node, left) { | ||
this.next(); | ||
|
||
node.left = left; | ||
|
||
// To get left-associative parsing for pipe calls, we can't let the RHS | ||
// of a pipe call subscript into another pipe call. | ||
// Thus we use a state flag to prevent deep parsing of pipe calls | ||
// Hackish but avoids changing the core args of parseSubscripts | ||
if (this.match(tt.parenL) || this.match(tt.name)) { | ||
this.state.potentialArrowAt = this.state.start; | ||
} | ||
const right = this.parseExprAtom(); | ||
this.state.noPipeSubscripts = true; | ||
node.right = this.parseSubscripts(right, this.state.start, this.state.startLoc); | ||
|
||
return this.finishNode(node, "PipeCallExpression"); | ||
}; | ||
|
||
pp.parseLeftPointingPipeCall = function(node, left) { | ||
this.next(); | ||
|
||
node.left = left; | ||
if (this.match(tt.parenL) || this.match(tt.name)) { | ||
this.state.potentialArrowAt = this.state.start; | ||
} | ||
node.right = this.parseSubscripts(this.parseExprAtom(), this.state.start, this.state.startLoc); | ||
node.reversed = true; | ||
|
||
return this.finishNode(node, "PipeCallExpression"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Parser from "../parser"; | ||
import { types as tt } from "../tokenizer/types"; | ||
const pp = Parser.prototype; | ||
|
||
export default function(parser) { | ||
if (parser.__syntacticPlaceholderPluginInstalled) return; | ||
parser.__syntacticPlaceholderPluginInstalled = true; | ||
|
||
const ph = parser.options.placeholder || "_"; | ||
const quotedPh = (ph + "").replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); | ||
const phRegex = new RegExp("^" + quotedPh + "([0-9]*)$"); | ||
|
||
pp.isPlaceholderName = function(name) { | ||
return phRegex.test(name); | ||
}; | ||
|
||
// c/p parseIdentifier | ||
pp._parseIdentifierOrPlaceholder = function(liberal) { | ||
const node = this.startNode(); | ||
if (!liberal) { | ||
this.checkReservedWord(this.state.value, this.state.start, !!this.state.type.keyword, false); | ||
} | ||
|
||
let name; | ||
if (this.match(tt.name)) { | ||
name = this.state.value; | ||
} else if (this.state.type.keyword) { | ||
name = this.state.type.keyword; | ||
} else { | ||
this.unexpected(); | ||
} | ||
|
||
const matches = phRegex.exec(name); | ||
if (matches) { | ||
if (matches[1]) node.index = parseInt(matches[1]); | ||
this.next(); | ||
return this.finishNode(node, "PlaceholderExpression"); | ||
} | ||
|
||
node.name = name; | ||
|
||
if (!liberal && node.name === "await" && this.state.inAsync) { | ||
this.raise(node.start, "invalid use of await inside of an async function"); | ||
} | ||
|
||
node.loc.identifierName = node.name; | ||
|
||
this.next(); | ||
return this.finishNode(node, "Identifier"); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.