Skip to content

Commit

Permalink
Add a note about the unreliability of tokenizing to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Aug 28, 2023
1 parent 6cae5ec commit ec1beab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions acorn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ option is enabled). When the token's type is `tokTypes.eof`, you
should stop calling the method, since it will keep returning that same
token forever.

Note that tokenizing JavaScript without parsing it is, in modern
versions of the language, not really possible due to the way syntax is
overloaded in ways that can only be disambiguated by the parse
context. This package applies a bunch of heuristics to try and do a
reasonable job, but you are advised to use `parse` with the `onToken`
option instead of this.

In ES6 environment, returned result can be used as any other
protocol-compliant iterable:

Expand Down

0 comments on commit ec1beab

Please sign in to comment.