1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:47:44 +00:00

LibJS: Lex and parse regex literals, add RegExp objects

This adds regex parsing/lexing, as well as a relatively empty
RegExpObject. The purpose of this patch is to allow the engine to not
get hung up on parsing regexes. This will aid in finding new syntax
errors (say, from google or twitter) without having to replace all of
their regexes first!
This commit is contained in:
Matthew Olsson 2020-06-03 16:05:49 -07:00 committed by Andreas Kling
parent 984a6ff97b
commit 61ac1d3ffa
20 changed files with 424 additions and 5 deletions

View file

@ -585,6 +585,27 @@ private:
virtual const char* class_name() const override { return "NullLiteral"; }
};
class RegExpLiteral final : public Literal {
public:
explicit RegExpLiteral(String content, String flags)
: m_content(content)
, m_flags(flags)
{
}
virtual Value execute(Interpreter&) const override;
virtual void dump(int indent) const override;
const String& content() const { return m_content; }
const String& flags() const { return m_flags; }
private:
virtual const char* class_name() const override { return "RegexLiteral"; }
String m_content;
String m_flags;
};
class Identifier final : public Expression {
public:
explicit Identifier(const FlyString& string)