Closed GoogleCodeExporter closed 9 years ago
Esprima favors a single flag for tolerating certain syntax violation (for
maintenance reason). I will include the illegal import and export declarations
in that tolerant mode.
Original comment by ariya.hi...@gmail.com
on 12 Jan 2015 at 3:20
With the change, the example output will be as follows:
require('./esprima').parse('function f() { import "jquery" }', { tolerant: true
})
{ type: 'Program',
body:
[ { type: 'FunctionDeclaration',
id: [Object],
params: [],
defaults: [],
body: [Object],
rest: null,
generator: false,
expression: false } ],
errors:
[ { [Error: Line 1: Illegal import declaration]
index: 14,
lineNumber: 1,
column: 15,
description: 'Illegal import declaration' } ] }
Note that there might be other invalid syntax tolerated by tolerant=true. If
you want to stop if there are other syntax errors, check the errors array and
make sure it only contains the "Illegal import declaration".
Original comment by ariya.hi...@gmail.com
on 12 Jan 2015 at 3:24
Tolerate illegal import and export declarations.
https://github.com/ariya/esprima/commit/b1dd29e985
Original comment by ariya.hi...@gmail.com
on 12 Jan 2015 at 3:26
Original issue reported on code.google.com by
cvreb...@gmail.com
on 4 Jan 2015 at 11:23