262 Commits

Author SHA1 Message Date
Marijn Haverbeke
141905f9fd Consume whitespace before, rather than after, reading a token
Simplifies several things
2015-03-05 15:59:12 +01:00
Marijn Haverbeke
bc48c02a18 Move the parser state into an object
Makes almost everything in acorn.js a method of this object.

Performance is not significantly affected on a modern V8. Makes the
code reentrant and allows us to more easily expose more methods
externally in the future.

On the other hand, the proliferation of `this.` is unfortunate.
2015-03-05 15:59:12 +01:00
Marijn Haverbeke
33307e789a Update tools/generate-identifier-regex.js
So that it can also spit out the astral maps.
2015-03-05 15:55:38 +01:00
Marijn Haverbeke
d76ea4b3be Make the tokenizer aware of multi-byte characters in ES6 mode
Add a data structure to recognize astral identifier chars. Parse whole
code points when looking for identifiers.

Issue #215
2015-03-05 15:55:38 +01:00
Marijn Haverbeke
891d5d07dd Allow braced \u escapes in identifiers
We still can't properly recognize code points as ES6-style
identifier chars.

Issue #214
2015-03-04 15:37:26 +01:00
Marijn Haverbeke
59dc29f3f0 In ES6-mode, don't treat keywords with escaped characters as regular identifiers
See https://mathiasbynens.be/notes/javascript-identifiers-es6
2015-03-04 15:29:15 +01:00
Marijn Haverbeke
cbd8aa8f06 Bump version number post-0.12 2015-03-02 11:31:27 +01:00
Marijn Haverbeke
99f1989f72 Mark release 0.12 2015-03-02 11:31:11 +01:00
Ingvar Stepanyan
7264bc0178 Fix found V8 deopt.
Increases perf from 230K to 360K lines/sec on std bench on my machine.
2015-02-05 00:02:21 +02:00
Ingvar Stepanyan
c034550215 Disallow line break between arrow function params and =>. 2015-02-04 12:57:18 +02:00
Ingvar Stepanyan
6eb177582d Fix export default declarations.
Closes #184.
2015-01-27 16:21:41 +02:00
Ingvar Stepanyan
6660a21b79 Disallow MemberExpression in bindings; clarify function namings. 2015-01-27 15:23:09 +02:00
Ingvar Stepanyan
3d5964ceed Fix locations for AssignmentPatterns. 2015-01-27 15:10:25 +02:00
Ingvar Stepanyan
5d96bbd781 Simplify & fix rest argument validity checks. 2015-01-24 13:38:14 +02:00
Ingvar Stepanyan
cdd444eff1 Speed-up reading words, strings and templates.
Now identifiers and strings even with escaped chars are read
in optimized way by reading entire chunks delimited by escape
chars (and not bailing to deopt mode on first one).
2015-01-24 12:42:19 +02:00
Ingvar Stepanyan
65d09eac6e Implement shorthand property assignment in ambiguous contexts.
Issue #181.
2015-01-24 12:40:24 +02:00
Ingvar Stepanyan
f0569147e6 Avoid extra call and arg in parseExpression for single-expression case. 2015-01-23 21:48:33 +02:00
Ingvar Stepanyan
41ad304955 Introduce helpers for contextual keywords. 2015-01-23 21:36:16 +02:00
Ingvar Stepanyan
917de714b1 Switch from Function.{rest,defaults} to AssignmentPattern and RestElement.
Closes #182.
2015-01-23 15:29:37 +02:00
Ingvar Stepanyan
38609ae26d Closes #205. 2015-01-23 14:14:02 +02:00
Ingvar Stepanyan
e6f1e1027e Fix dividing function expression.
Fixes #204.
2015-01-23 13:17:03 +02:00
Ingvar Stepanyan
39d752dc6b Make top-level equal to block statement context.
Fixes #203.
2015-01-23 11:48:39 +02:00
Ingvar Stepanyan
555c7898c8 Remove Token::{startLoc,endLoc} so they don't appear in next release. 2015-01-22 18:21:38 +02:00
Ingvar Stepanyan
caa5da6ce1 Improve spread element parsing (fix allowed contexts and error locations). 2015-01-21 23:51:40 +02:00
Marijn Haverbeke
94b5efcd3e Disallow declaration statements in block-less context
Closes #202
2015-01-20 12:55:21 +01:00
Marijn Haverbeke
a1d2561cfa Restore patch 9f7cb552648829796ab4d6836d08246e95f16b9d to original shape
And make loose parser handle stray class semicolons

Issue #190
2015-01-20 12:02:30 +01:00
Sebastian McKenzie
9f7cb55264 Add stray semicolons as class elements 2015-01-20 11:56:33 +01:00
Ingvar Stepanyan
6dee98d1b9 Adapt ES6 template handling to new tokenizer.
Avoid need for:
* extra `templates` array in favor of new `tokContext`;
* special location handling for first & last template elements;
* separate `_templateContinued` token in favor of same `_template`.

Adds:
* token types for backQuote and dollarBraceL instead of skipping them
so they can be handled (i.e. highlighted differently).
2015-01-17 22:21:22 +01:00
Ingvar Stepanyan
f6c45ac59f Re-read only number or string after "use strict".
Fixes double-entering same tokContext for various parentheses.
2015-01-14 23:10:10 +02:00
Ingvar Stepanyan
e7beee177d Remove deprecated ComprehensionBlock.of property.
Comprehensions were moved to ES7 anyway, so there is no sense
in keeping intermediate no-more-supported syntax.
2015-01-14 12:35:00 +02:00
Ingvar Stepanyan
7e85da74cb shouldSkipSpace is no more needed in finishToken. 2015-01-14 12:31:59 +02:00
Ingvar Stepanyan
ad9411d2ae Made tokenize() compliant with ES6 iterables for easier processing. 2015-01-14 12:29:20 +02:00
Marijn Haverbeke
0f55a53a7d [loose parser] Fetch token before comment when tokenizer raises unterminated comment error
Closes #197
2015-01-13 22:18:55 +01:00
Ingvar Stepanyan
d1f95ece42 Revert "Disallow parentheses in lvalue except as in computed keys or default values."
This reverts commit 85087f2a0951f60ca035ca6d785e4bab6d96d8f7.
Fixes #193.
2015-01-12 20:31:38 +02:00
Ingvar Stepanyan
bc2e01aa03 Allow static as method name in class (fixes #192).
Add uncommitted tests for #191.
2015-01-09 15:31:01 +02:00
Ingvar Stepanyan
3d9048a692 Allow pattern in catch param (fixes #191). 2015-01-09 02:50:32 +02:00
Ingvar Stepanyan
85087f2a09 Disallow parentheses in lvalue except as in computed keys or default values. 2015-01-08 23:00:22 +02:00
Ingvar Stepanyan
4d4a76588c Parse assignment patterns in-place in certain contexts.
* Parsing assignables without extra transform step when possible (speed-up).
* Added support for shorthand defaults in such certain contexts (issue #181).
2015-01-08 20:19:48 +02:00
Marijn Haverbeke
0897901f1f Slight cleanup of '/' disambiguation
Issue #189
2015-01-06 11:03:50 +01:00
Marijn Haverbeke
b6b085ac8e Make tokenizer independent of parser (with regards to '/' disambiguation)
Issue #189
2015-01-06 10:58:52 +01:00
Marijn Haverbeke
7c6a8b7c76 Use parseExprSubscripts instead of parseExpression when parsing superclass
Issue #187
2015-01-04 22:30:50 +01:00
Marijn Haverbeke
045d8c02f5 Revert "Require superclass expressions to be lvals"
This reverts commit 0b59fc198baf2cd970091ee96fe5dd0f90034692.

Issue #187
2015-01-04 22:28:16 +01:00
Marijn Haverbeke
e271168cf6 Make onToken only fire for actual final tokens
Issue #189
2015-01-04 22:27:03 +01:00
Ingvar Stepanyan
431a44bc74 Add support for destructuring defaults (not for shorthand props yet).
Related to #181.
2015-01-04 12:15:24 +02:00
Marijn Haverbeke
0b59fc198b Require superclass expressions to be lvals
And remove a test that violates this.

Closes #185
2014-12-30 12:54:25 +01:00
Ingvar Stepanyan
0084ac14ae Fixed #186. 2014-12-30 13:42:37 +02:00
Ingvar Stepanyan
adec9f4b8e Provide better error on member expression in binding's left side. 2014-12-17 20:37:00 +02:00
Ingvar Stepanyan
e37c07248e Added optional support for hashbang directives.
Fixes #180.
2014-12-17 19:58:38 +02:00
Marijn Haverbeke
8e84aa02f4 Bump version number post-0.11 2014-12-17 11:54:40 +01:00
Marijn Haverbeke
78e1d7ada6 Mark version 0.11.0 2014-12-17 11:54:09 +01:00