internal IScript ParseScript([NotNull] string source, [CanBeNull] string scriptName, bool strictEval, bool inFunction) { //https://tc39.github.io/ecma262/#sec-parse-script IScript script; try { var result = Acorn.Parse(source, new Options { ecmaVersion = 8, SourceFile = scriptName, StartInFunction = inFunction }); script = new NodeScript(result); } catch (SyntaxError e) { throw new ScriptException(CreateError(Realm.SyntaxErrorPrototype, e.Message), e); } script.HandleEarlyErrors(this, strictEval); return(script); }
private IModule ParseModule([NotNull] string source, [CanBeNull] string scriptName) { //https://tc39.github.io/ecma262/#sec-parsemodule IModule module; try { var result = Acorn.Parse(source, new Options { ecmaVersion = 8, SourceFile = scriptName, sourceType = SourceType.Module }); module = new NodeModule(result); } catch (SyntaxError e) { throw new ScriptException(CreateError(Realm.SyntaxErrorPrototype, e.Message), e); } module.HandleEarlyErrors(this, false); module.Initialise(); return(module); }