Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,10 @@
var your => (code) => here;
```

### Babylon/Babel Configuration
<!--- If describing a bug, tell us what your babel configuration looks like -->

```js
{
"your": { "config": "here" }
}
```

### Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->

### Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->

### Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->

| software | version
| ---------------- | -------
| Babylon |
| node |
| npm |
| Operating System |
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ coverage
lib
node_modules
npm-debug.log
lerna-debug.log
13 changes: 0 additions & 13 deletions CODE_OF_CONDUCT.md

This file was deleted.

11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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!
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babylon-lightscript",
"version": "0.4.1",
"name": "@oigroup/babylon-lightscript",
"version": "0.4.3",
"description": "A LightScript parser, based on babylon (a JavaScript parser)",
"author": "Alex Rattray <rattray.alex@gmail.com>",
"homepage": "http://lightscript.org/",
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/lightscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
};
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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": []
}
}

This file was deleted.