1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:48:11 +00:00

LibRegex: Implement an ECMA262-compatible parser

This also adds support for lookarounds and individually-negated
comparisons.
The only unimplemented part of the parser spec is the unicode stuff.
This commit is contained in:
AnotherTest 2020-11-27 19:33:53 +03:30 committed by Andreas Kling
parent 3200ff5f4f
commit dbef2b1ee9
11 changed files with 1321 additions and 25 deletions

View file

@ -26,6 +26,7 @@
#include "RegexLexer.h"
#include <AK/Assertions.h>
#include <AK/LogStream.h>
#include <stdio.h>
namespace regex {
@ -89,6 +90,15 @@ void Lexer::reset()
m_previous_position = 0;
}
bool Lexer::try_skip(char c)
{
if (peek() != c)
return false;
consume();
return true;
}
Token Lexer::next()
{
size_t token_start_position;
@ -127,7 +137,9 @@ Token Lexer::next()
case '\\':
return 2;
default:
fprintf(stderr, "[LEXER] Found invalid escape sequence: \\%c\n", peek(1));
#ifdef REGEX_DEBUG
fprintf(stderr, "[LEXER] Found invalid escape sequence: \\%c (the parser will have to deal with this!)\n", peek(1));
#endif
return 0;
}
};