Ignore error while generating JS AST using ESPIRMA

169 Views Asked by At

How to instruct esprima to continue generating AST even if there are syntax errors in the JS file?

Example:

var x = ; // syntax error
var y = 5;
x = y;

The normal esprima output (even when enabling tolerant mode):

description: 'Unexpected token ;'

1

There are 1 best solutions below

0
On BEST ANSWER

Seems it is not possible with ESPIRMA. However, I could achieve that using acorn-loose which will generate the same AST structure.