12158 Commits

Author SHA1 Message Date
Paul Harper
559518acc8 .parse_dammit() now recognizes the locations option, and will add a loc object to the ast nodes as .parse() does 2013-03-17 22:07:14 +01:00
Marijn Haverbeke
38179fd855 Fix node boundaries for unexpected regular expressions
Closes #33
2013-02-28 19:28:20 +01:00
Marijn Haverbeke
0b10aa2256 Add walk.findNodeBefore 2013-02-28 19:27:29 +01:00
Marijn Haverbeke
83cdcf7dbf Remove outdated option from bin/acorn 2013-02-27 09:59:42 +01:00
zsjforcn
173d94f019 [package] Add "bin" property to package.json for npm to auto generate exection files. 2013-02-27 09:39:09 +01:00
Marijn Haverbeke
9a55d60324 Move back to regular string accumulation in readString
The apply call is a stack overflow hazard.

Closes #31
2013-02-24 21:26:09 +01:00
Marijn Haverbeke
b1845b51b1 [util/walk] Add findNodeAfter 2013-02-24 21:25:25 +01:00
Marijn Haverbeke
72d2fc2644 Fix start offset of block nodes 2013-02-20 10:48:36 +01:00
Marijn Haverbeke
782259bea1 [loose parser] Fix bug where peeked tokens persist across parses 2013-02-14 14:05:54 +01:00
Marijn Haverbeke
adcb354498 [walker] Fix broken handling of node predicates 2013-02-14 14:02:48 +01:00
Marijn Haverbeke
006d5f1c04 Bump version post-0.1 2013-02-14 10:02:27 +01:00
Marijn Haverbeke
c108741d07 Mark release 0.1 2013-02-14 10:00:19 +01:00
Marijn Haverbeke
da83f80d29 Allow passing a test predicate to findNodeAt and findNodeAround 2013-02-12 17:35:04 +01:00
Marijn Haverbeke
76c41d3a71 [loose parser] Improve closing heuristic in parseExprList 2013-02-06 13:47:05 +01:00
Marijn Haverbeke
82980794a9 Fix bug in expression-terminating heuristic
Dedented tokens should only end an expression if they are actually the first
token on the line.

This to prevent code like this from going wrong:

    x = (function(..) {
      blah();
    })(); // <-- indented same as start of expression
2013-02-05 13:49:51 +01:00
Marijn Haverbeke
d98e378590 Store default walker in exports.base, rather than exports itself
My initial idea, that client code would constantly need to access the individual
walker functions directly, isn't actually the case. This prevents unnecessary copying
of other interface functions into walkers.
2013-01-30 19:11:27 +01:00
Alistair Braidwood
0632b36c94 Improve options.locations performance by tracking newlines rather than finding them 2013-01-30 17:30:38 +01:00
Marijn Haverbeke
87a6a5a8cd Clean up readNumber, fix parsing of '2.+2'
Issue #9
2013-01-30 16:38:31 +01:00
Marijn Haverbeke
792fa96e93 Add walk.findNodeAround 2013-01-28 17:17:51 +01:00
Marijn Haverbeke
1de79a277c [loose parser] Refine block-closing heuristics, add expression-continuing heuristics 2013-01-28 16:43:19 +01:00
Marijn Haverbeke
e95c4cce50 Add walk.findNodeAt utility 2013-01-28 13:00:08 +01:00
keeyipchan
44f7aff2b7 Add testAssert() for arbitrary tests; fix skinLineComments() passing off-by-1 character to onComment(slice(.., end)) 2013-01-27 10:09:06 +01:00
Marijn Haverbeke
17a0094694 [loose parser] Improve recovery from unterminated strings and regexps 2013-01-17 15:01:13 +01:00
Marijn Haverbeke
f8bcc75378 [loose parser] Fix typo 2013-01-17 14:49:20 +01:00
Marijn Haverbeke
e130dc3fbb [loose parser] Use ✖ rather than question mark for placeholders
This way, attempts to re-parse the pretty-printed code won't
be confused by the question marks.
2013-01-17 14:45:16 +01:00
Marijn Haverbeke
207bf64e8d [loose parser] Revise strategy for forcing token consumption
It's easier and more flexible to simply handle it at the call site.
2013-01-17 14:44:00 +01:00
Marijn Haverbeke
b8ec8aab2c [loose parser] Fix bug in argument list parsing 2013-01-17 14:17:22 +01:00
Marijn Haverbeke
7d73fe243a Upgrade Esprima 2013-01-17 14:17:10 +01:00
Marijn Haverbeke
1d974ce2b6 [loose parser] Several small tweaks 2013-01-16 19:09:06 +01:00
Marijn Haverbeke
d08144c1d7 [loose parser] Support tabSize option 2013-01-16 17:53:37 +01:00
Marijn Haverbeke
3981dfa133 [loose parser] Add note about imprecision 2013-01-16 17:43:27 +01:00
Marijn Haverbeke
a2788f8864 [loose parser] Make expect check two tokens ahead if it fails to find its target 2013-01-16 17:38:56 +01:00
Marijn Haverbeke
038e438949 Add a loose parser
For getting a halfway meaningful AST out of code that may contain
syntax errors.

Use case: analyzing code as the user is editing it.
2013-01-16 17:27:28 +01:00
Marijn Haverbeke
965166cdfd Small fixes noticed while going over the when writing loose parser 2013-01-16 16:47:21 +01:00
Marijn Haverbeke
4d2d8408de Export the tokenizer 2013-01-16 12:46:26 +01:00
Marijn Haverbeke
c2dd92fec0 Attach position information to errors 2013-01-16 12:20:19 +01:00
Marijn Haverbeke
3c2bd590da Fix regexp detection after void/typeof/instanceof/delete 2013-01-15 15:58:16 +01:00
Marijn Haverbeke
8104257495 Bump version to 0.0.2 2013-01-13 22:05:46 +01:00
Marijn Haverbeke
cade51347a Remove trackComments, add onComment option
trackComments was too obscure and complicated, and not all that useful.
2013-01-13 22:04:45 +01:00
Martin Carlberg
5e4ea00f3c Unnecessary 'if' as we already know 'ch !== 92' 2013-01-09 10:13:26 +01:00
Marijn Haverbeke
e6485e61fd [walker] Allow recursive walks without building a new walker obj 2013-01-08 13:17:37 +01:00
Marijn Haverbeke
cc5971f617 Formatting 2013-01-04 09:37:21 +01:00
Arian Stolwijk
f6e0182a3a Fixes sourceFile option.
When setting the .prototype.source the sourceFile variable is undefined, and
setting the sourceFile option doesn't change the .source property on the
prototype anymore.

By setting the .source property inside the node_loc_t constructor, the correct
sourceFile is set in the loc object.
2013-01-04 09:32:43 +01:00
Alistair Braidwood
3d0f85d616 line_loc type for v8 perf 2012-12-30 12:46:54 +01:00
Alistair Braidwood
c8eb50fabe create node 'class' - improve v8 performance 2012-12-30 12:46:45 +01:00
Alistair Braidwood
2bad03e654 reduce array creation in readString 2012-12-30 12:27:13 +01:00
krator
5b19196bac Give true/false/null literals a raw property
In the generated ast, "null"/"true"/"false" are "Literal" nodes.
As every "Literal" node has a 'raw' property,
When i am doing something with the ast using python,
the 3 "Literal"s caused some problem.
make the 3 "Literal"s have 'raw' property.
2012-12-24 14:26:03 +01:00
Marijn Haverbeke
f58bb9a480 Use 'self' instead of 'window' in browser, in order to work in a web worker 2012-11-29 10:08:32 +01:00
Marijn Haverbeke
d36c70bbbf Add missing labels.pop() to allow re-using labels in a block
Issue #15
2012-11-22 10:11:00 +01:00
Marijn Haverbeke
5c44c13465 Make sure readInt doesn't try to read past len, if given
Issue #15
2012-11-22 10:07:19 +01:00