1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:27:45 +00:00

LibJS+LibWeb: Let JS::Script::parse() return a list of errors (on error)

These are really supposed to be a list of SyntaxError objects, but for
now we simply return all the Parser::Error objects we got from Parser.
This commit is contained in:
Andreas Kling 2021-09-14 20:56:57 +02:00
parent 5fa02b8a9e
commit 10c489713d
3 changed files with 17 additions and 8 deletions

View file

@ -10,6 +10,7 @@
#include <AK/RefCounted.h>
#include <LibJS/AST.h>
#include <LibJS/Heap/Handle.h>
#include <LibJS/Parser.h>
#include <LibJS/Runtime/Realm.h>
namespace JS {
@ -18,7 +19,7 @@ namespace JS {
class Script : public RefCounted<Script> {
public:
~Script();
static NonnullRefPtr<Script> parse(StringView source_text, Realm&, StringView filename = {});
static Result<NonnullRefPtr<Script>, Vector<Parser::Error>> parse(StringView source_text, Realm&, StringView filename = {});
Realm& realm() { return *m_realm.cell(); }
Program const& parse_node() const { return *m_parse_node; }