Skip to content

Commit

Permalink
Remove whiteblock
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Oct 10, 2017
1 parent b9ca11a commit f95f78b
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 55 deletions.
33 changes: 0 additions & 33 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,39 +234,6 @@ Labeled expressions increase the number of scenarios where objects and blocks ca
(In terms of the parser unit test suite, this change eliminated around 20 situations where LightScript was parsing vanilla JavaScript incorrectly, as well as four parsing situations labeled as `unfortunate` in the test suite itself.)
## `whiteblock` compiler option added.
### Change
When this option is enabled, only whitespace-delimited syntax can be used for introducing blocks of code. `{ }` are reserved for object literals and some other constructs like `import`/`export`.
For example,
```js
f(x) ->
y
// compiles to
function(x) { return y; }
// both with and without `whiteblock`

// However,
f(x) -> {
y
}
// compiles to
function(x) { return y; }
// without `whiteblock`, but with `whiteblock`, the `{`s are interpreted
// as delimiting an object, so instead you get
function(x) {
return { y }
}
```
In the simplest possible terms, `whiteblock` makes the compiler behave as if you are always writing idiomatic whitespaced LightScript code, and so `{}`s will never be used to set off code blocks.
### Rationale
The context-sensitive brace parser is implemented using speculative branching, which can essentially double the amount of work the parser has to do in a lot of situations. This flag will greatly speed up the LightScript parser for those who use whitespace-sensitive syntax, as it is no longer necessary for the parser to speculate when encountering `{ }`.
## `pipeCall` option eliminated
### Change
Expand Down
18 changes: 1 addition & 17 deletions src/config.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export getMetadata() -> {
defaultValue: "default"
stage: "1"
}
whiteblock: {
description: "Disable `{` `}` as block delimiters."
valueType: "boolean"
}
bangCall: {
description: "Call functions with paren-free syntax using `!`"
valueType: "boolean"
Expand All @@ -37,12 +33,6 @@ export getMetadata() -> {
description: "Postfix `?` checks that an expression is not loose-equal to `null`"
valueType: "boolean"
}
enhancedComprehension: {
description: "Positional comprehensions and `case` syntax for comprehensions"
valueType: "boolean"
defaultValue: true
stage: "0"
}
noEnforcedSubscriptIndentation: {
description: "Do not enforce indentation for subscripts on subsequent lines."
valueType: "boolean"
Expand Down Expand Up @@ -103,15 +93,9 @@ export getParserOpts(pluginOpts, initialParserOpts) ->
"objectRestSpread", "asyncFunctions", "asyncGenerators"
"classProperties", "classConstructorCall", "decorators"
"dynamicImport", "doExpressions", "seqExprRequiresParen"
"noLabeledExpressionStatements", "spreadLoop"
"noLabeledExpressionStatements", "spreadLoop", "whiteblockPreferred"
)

if pluginOpts?.whiteblock:
if pluginOpts.whiteblock != "compat":
plugins.push("whiteblockOnly")
else:
plugins.push("whiteblockPreferred")

if not pluginOpts?.disableJsx: plugins.push("jsx")
if not pluginOpts?.disableFlow: plugins.push("flow")
if pluginOpts?.safeCall != false: plugins.push("safeCallExpression")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit f95f78b

Please sign in to comment.