"use strict" ; import { getOption } from "../lib/util" ; export function parse ( source , options ? ) { const comments = [ ] ; const ast = require ( "esprima" ) . parse ( source , { loc : true , locations : true , comment : true , onComment : comments , range : getOption ( options , "range" , false ) , tolerant : getOption ( options , "tolerant" , true ) , tokens : true , jsx : getOption ( options , "jsx" , false ) } ) ; if ( ! Array . isArray ( ast . comments ) ) { ast . comments = comments ; } return ast ; } ;