70 Commits

Author SHA1 Message Date
Marijn Haverbeke
249e6961f8 Make tests pass for loose parser
Define Program node extent to be the whole program, make
both parser and the tests conform to this.

Fix a bunch of bugs in the loose parser's handling of corner
cases.

Issue #151
2014-11-12 17:05:19 +01:00
Ingvar Stepanyan
96ccdb05fa Web-driver support for loose parser + small fixes.
* Added support for acorn_loose and grouped log to web-driver.
* Removed unused copy-pasted `parseTemplate` from loose parser.
* Throw non-SyntaxError errors immediately (as those are generic).
2014-11-12 16:19:16 +01:00
Ingvar Stepanyan
6bf8311061 Loose: fix #33. 2014-11-12 16:19:16 +01:00
Ingvar Stepanyan
2419de74dc Loose: Fix regex after tokenizer changes in #144. 2014-11-12 16:19:16 +01:00
Ingvar Stepanyan
fc2e96fa01 Loose: respect optional semicolons in break/continue/class/import/export. 2014-11-12 16:19:16 +01:00
Ingvar Stepanyan
d4565fed53 Loose: ES6 import, export.
Removed "kind" from tests for ES6 import/export as it's
left only for backward compatibility.
2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
4647f966eb Loose: don't silently skip missed elements in expr list. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
aa96edf769 Loose: support for-of without var. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
1589a959fa Loose: yield support. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
bdce88c184 Loose: for-of statement. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
992fc0503d Loose: arrow functions. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
ede10a079c Loose: class support. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
c6b6ef389e Loose: Remove own tabSize initialization in favor of defaultOptions. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
9cdc6809ce Loose: fix pattern+defaults case in function params. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
b46b53e149 Loose: implement object methods; expose processed options from acorn. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
dda90580df Loose: Added support for shorthand properties. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
963a26e46f Loose: Added support for let and const.
Fixes #146.
2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
4879af22d1 Loose: Added support for assignment patterns to expression and variables. 2014-11-12 16:19:15 +01:00
Ingvar Stepanyan
eba8a5646c Loose: added support for holes in arrays (but disallows trailing comma). 2014-11-12 16:19:14 +01:00
Ingvar Stepanyan
a14a5c8192 Loose: Added support for rest parameters.
Includes correction of mistype ".." vs "...".
2014-11-12 16:19:14 +01:00
Ingvar Stepanyan
11ecb20e9e Loose: ES6 function params support. 2014-11-12 16:19:14 +01:00
Ingvar Stepanyan
61d2067b2b Loose: Added ParenthesizedExpression. 2014-11-12 16:19:13 +01:00
Marijn Haverbeke
437ce2d9be [loose parser] Ignore shebang lines
Closes marijnh/tern#408
2014-10-21 12:35:06 +02:00
Mike Rennie
ad69446c0a Make parse_dammit honour the 'ranges' option
Closes #140
2014-10-21 12:14:18 +02:00
Marijn Haverbeke
bdee9e8195 Make locations in loose parser consistent with those in regular parser
Issue #136
2014-10-08 12:35:57 +02:00
Marijn Haverbeke
49680b1c60 [loose parser] Take brace-line indentation into account for objlit closing heuristic 2014-09-22 15:15:12 +02:00
Marijn Haverbeke
39fa62e90f [loose parser] Be slightly more agressive about heuristically closing object literals 2014-09-22 15:03:54 +02:00
Marijn Haverbeke
12cbfed34f [loose parser] Don't omit unfinished object literal properties 2014-09-22 14:46:41 +02:00
Marijn Haverbeke
6c854ad221 [loose parser] Be more careful about calling resetTo
It will try to eat whitespace, and can thus raise an unterminated comment exception

Issue #375
2014-09-05 15:31:15 +02:00
Max Schaefer
1ca2115294 Remove unused local variables. 2014-08-21 18:10:48 +02:00
Marijn Haverbeke
69cadaa1e9 Add basic ES6 support in util/walk.js 2014-08-14 13:23:03 +02:00
Ingvar Stepanyan
ef045b9718 Remove copyToken from acorn_loose (not needed anymore). 2014-07-31 14:33:40 +03:00
Conrad Irwin
2de16b8cb0 [loose parser] Fix interpretation of f."
Before this the ast produced by parse_dammit crashed in the following
code, as Uglify correctly noticed that f."" is invalid.

    sample = 'f."';

    loose = require('acorn/acorn_loose');
    uglify = require('uglify-js');

    out = new uglify.OutputStream();
    ast = loose.parse_dammit(sample);
    ast = uglify.AST_Node.from_mozilla_ast(ast);
    ast.print(out);
    // TypeError: Cannot call method 'toString' of undefined
    // member_exp.computed = false && member_exp.property == ""

    console.log(out.toString());

After this the round-tripped AST looks like: `t.✖;"";`, which is
consistent with how `foo.{` is parsed.

I also considered making it parse as t[""], but as this only turns up in
the wild when people try to use multiline strings, I felt it was better
to be obviously wrong.
2014-04-17 23:03:18 +02:00
Marijn Haverbeke
4869ccfa55 Prevent loose parser from tripping on invalid regexps
Issue #39
2014-03-25 17:45:58 +01:00
Marijn Haverbeke
93124c9eb8 Don't export Node from loose parser, reuse existing Node's proto
Issue #92
2014-03-25 17:31:03 +01:00
Marijn Haverbeke
e5439847fd Rename remaining *_t constructors to something sane 2014-03-25 17:29:17 +01:00
David Bonnet
7b9a46710d Renamed node_t to Node and exported it
This is to let programmers extend the Node object with utility methods
2014-03-25 17:23:30 +01:00
Marijn Haverbeke
d973261940 [loose parser] Make sure VariableDeclaration nodes have at least one decl
Closes marijnh/tern#255
2013-12-09 17:55:16 +01:00
Marijn Haverbeke
356e0be759 Add directSourceFile option 2013-10-15 13:08:56 +02:00
Marijn Haverbeke
2ace0fa8dc Further refine parseExprList indentation heuristic
Closes marijnh/tern#221
2013-08-27 12:52:02 +02:00
Jürg Lehni
097b4162da Pass on 'this' as root scope, for better inclusion of Acorn inside Paper.js
Use same approach as Esprima.
2013-07-26 08:59:07 +02:00
Marijn Haverbeke
328d0e514c Linting 2013-07-08 09:07:10 +02:00
Marijn Haverbeke
2372b12df7 [loose parser] Refine closing heuristic for expression lists
Issue marijnh/tern#171
2013-06-10 18:02:17 +02:00
Marijn Haverbeke
3ca3aa5a25 Run a lint pass, clean up lots of small issues 2013-06-10 16:52:22 +02:00
Marijn Haverbeke
6fe123947b Prefix keywords with underscore in tokTypes object 2013-06-10 15:47:29 +02:00
Marijn Haverbeke
6dd35f870a [loose parser] Fix bug in continued-expression closing
When the continued expression sat on column 1 after a non-whitespace char,
the heuristic would consider it the start of the line, even though it wasn't.

Issue marijnh/tern#141
2013-05-15 12:03:00 +02:00
Marijn Haverbeke
9eee5300db [loose parser] Less aggressive termination heuristic for comma-separated lists
See https://github.com/marijnh/tern/issues/118
2013-05-08 15:21:25 +02:00
Marijn Haverbeke
4d8eeabf52 In browser loader, refer to global object as 'this', not 'self'
Closes #41
2013-05-08 15:16:06 +02:00
Marijn Haverbeke
f3c70d76ef Remove assignment to non-existing var 2013-04-03 15:05:00 +02:00
Marijn Haverbeke
cc12062b9c [loose parser] Fix a whole bunch of issues in the options.locations support
Closes #40
2013-04-02 13:47:50 +02:00