From 3426c905d73247a764f6d1014c5810b14526831e Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Wed, 5 Apr 2017 18:58:17 -0400 Subject: [PATCH 1/6] Scope package name --- .gitignore | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4dfb35cc7a..b48cbbc6ac 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ coverage lib node_modules npm-debug.log +lerna-debug.log diff --git a/package.json b/package.json index 2021894d0b..da449e31a9 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "babylon-lightscript", + "name": "@oigroup/babylon-lightscript", "version": "0.4.1", "description": "A LightScript parser, based on babylon (a JavaScript parser)", "author": "Alex Rattray ", From b54f8aabe6e0819f5a366a430bb376a54546d133 Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Wed, 5 Apr 2017 19:15:16 -0400 Subject: [PATCH 2/6] 0.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da449e31a9..398b76814e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oigroup/babylon-lightscript", - "version": "0.4.1", + "version": "0.4.2", "description": "A LightScript parser, based on babylon (a JavaScript parser)", "author": "Alex Rattray ", "homepage": "http://lightscript.org/", From affb5b7040cbdd120c605c9790a1e3152c3c7351 Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Wed, 5 Apr 2017 19:47:19 -0400 Subject: [PATCH 3/6] Readme update --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8de191c4d..8ecf084a25 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ -# babylon-lightscript +# @oigroup/babylon-lightscript + +> NB: This is a fork of babylon-lightscript which implements language changes that are not necessarily endorsed by upstream. Generally speaking, our intent is to closely follow the upstream language -- however, there may be notable deviations which are documented below. The parser for [LightScript](http://lightscript.org). -To be used with [babel-plugin-lightscript](https://github.com/lightscript/babel-plugin-lightscript). +To be used with [@oigroup/babel-plugin-lightscript](https://github.com/wcjohnson/babel-plugin-lightscript). A minimally-invasive fork of [Babylon](https://github.com/babel/babylon). With the exception of a few reserved keywords, it parses JS as JS unless the `"lightscript"` plugin is passed. - ### Contributing yarn @@ -17,3 +18,7 @@ it parses JS as JS unless the `"lightscript"` plugin is passed. New tests should go in the [lightscript](https://github.com/lightscript/babylon-lightscript/tree/lightscript/test/fixtures/lightscript) directory. + +### Deviations from LightScript proper + +None so far! From 5235687407a8886dd2065495b4fe9415595b4374 Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Thu, 6 Apr 2017 14:52:46 -0400 Subject: [PATCH 4/6] Administrivia - Removed code of conduct - Modification to issue template --- .github/ISSUE_TEMPLATE.md | 19 ------------------- CODE_OF_CONDUCT.md | 13 ------------- 2 files changed, 32 deletions(-) delete mode 100644 CODE_OF_CONDUCT.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 720ddada29..54bd9ee3fb 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -7,15 +7,6 @@ var your => (code) => here; ``` -### Babylon/Babel Configuration - - -```js -{ - "your": { "config": "here" } -} -``` - ### Expected Behavior @@ -23,13 +14,3 @@ var your => (code) => here; ### Current Behavior - -### Your Environment - - -| software | version -| ---------------- | ------- -| Babylon | -| node | -| npm | -| Operating System | diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 4ead0e1daf..0000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,13 +0,0 @@ -# Contributor Code of Conduct - -As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. - -We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. - -Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) From eec28f128d094017abd6c84ef742c86c2f67fe5d Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Thu, 6 Apr 2017 15:04:01 -0400 Subject: [PATCH 5/6] Allow empty arrow bodies Fixes #1 - Modify parser to accept empty arrow bodies - Update old fixture that regards empty arrow as malformed --- src/plugins/lightscript.js | 7 +- .../actual.js | 0 .../skinny-white-empty/expected.json | 123 ++++++++++++++++++ .../options.json | 3 - 4 files changed, 127 insertions(+), 6 deletions(-) rename test/fixtures/lightscript/named-arrow-functions/{skinny-white-malformed-dedent => skinny-white-empty}/actual.js (100%) create mode 100644 test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/expected.json delete mode 100644 test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/options.json diff --git a/src/plugins/lightscript.js b/src/plugins/lightscript.js index c33f34e6ca..96af4b709f 100644 --- a/src/plugins/lightscript.js +++ b/src/plugins/lightscript.js @@ -168,7 +168,7 @@ pp.parseNumericLiteralMember = function () { // c/p parseBlock -pp.parseWhiteBlock = function (allowDirectives?, isIfExpression?) { +pp.parseWhiteBlock = function (allowDirectives?, isIfExpression?, isArrowBody?) { const node = this.startNode(), indentLevel = this.state.indentLevel; // must start with colon or arrow @@ -197,7 +197,8 @@ pp.parseWhiteBlock = function (allowDirectives?, isIfExpression?) { // never parse directives if curly braces aren't used (TODO: document) this.parseBlockBody(node, false, false, indentLevel); this.addExtra(node, "curly", false); - if (!node.body.length) this.unexpected(node.start, "Expected an Indent or Statement"); + if (!isArrowBody && !node.body.length) + this.unexpected(node.start, "Expected an Indent or Statement"); return this.finishNode(node, "BlockStatement"); }; @@ -333,7 +334,7 @@ pp.parseArrowFunctionBody = function (node) { this.state.labels = []; this.state.inFunction = true; - node.body = this.parseWhiteBlock(true); + node.body = this.parseWhiteBlock(true, false, true); if (node.body.type !== "BlockStatement") { node.expression = true; diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/actual.js b/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/actual.js similarity index 100% rename from test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/actual.js rename to test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/actual.js diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/expected.json b/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/expected.json new file mode 100644 index 0000000000..8da8ceb211 --- /dev/null +++ b/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/expected.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "script", + "body": [ + { + "type": "NamedArrowDeclaration", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "expression": false, + "async": false, + "params": [], + "skinny": true, + "body": { + "type": "BlockStatement", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "body": [], + "directives": [], + "extra": { + "curly": false + } + } + }, + { + "type": "ExpressionStatement", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "expression": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/options.json b/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/options.json deleted file mode 100644 index f568ef6fed..0000000000 --- a/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected an Indent or Statement (1:5)" -} From ca98a3d1a28b019e6c1a713607d9db2fafebe911 Mon Sep 17 00:00:00 2001 From: "William C. Johnson" Date: Thu, 6 Apr 2017 15:05:20 -0400 Subject: [PATCH 6/6] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 398b76814e..1a49cff2b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oigroup/babylon-lightscript", - "version": "0.4.2", + "version": "0.4.3", "description": "A LightScript parser, based on babylon (a JavaScript parser)", "author": "Alex Rattray ", "homepage": "http://lightscript.org/",