Summary
Add support for regex literal syntax (/pattern/flags) and a basic RegExp runtime.
Motivation
The runtime already has String.prototype.match, matchAll, replace, replaceAll, split, and search that accept string patterns. Adding /pattern/flags literals and a RegExp object would let users write regex naturally and is essential for compatibility with most non-trivial JS code.
Scope
- Lexer: parse
/pattern/flags as a regex token
- AST node for regex literals
RegExp constructor and test() method
RegExp.prototype.exec()
- Support flags:
g, i, m, s, u
- Wire up existing string methods to accept
RegExp objects in addition to strings
Out of scope
RegExp lookbehind/lookahead
- Unicode property escapes
String.prototype.matchAll returning an iterator (it exists as a basic implementation)
Summary
Add support for regex literal syntax (
/pattern/flags) and a basicRegExpruntime.Motivation
The runtime already has
String.prototype.match,matchAll,replace,replaceAll,split, andsearchthat accept string patterns. Adding/pattern/flagsliterals and aRegExpobject would let users write regex naturally and is essential for compatibility with most non-trivial JS code.Scope
/pattern/flagsas a regex tokenRegExpconstructor andtest()methodRegExp.prototype.exec()g,i,m,s,uRegExpobjects in addition to stringsOut of scope
RegExplookbehind/lookaheadString.prototype.matchAllreturning an iterator (it exists as a basic implementation)