mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
JSSpecCompiler: Parse "NewTarget" in xspec mode
This commit is contained in:
parent
4d8f74c149
commit
ba61b61d67
Notes:
sideshowbarker
2024-07-17 18:46:57 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/ba61b61d67 Pull-request: https://github.com/SerenityOS/serenity/pull/23123 Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 5 additions and 1 deletions
|
@ -135,6 +135,7 @@ class WellKnownNode : public Expression {
|
|||
public:
|
||||
enum Type {
|
||||
False,
|
||||
NewTarget,
|
||||
Null,
|
||||
This,
|
||||
True,
|
||||
|
|
|
@ -39,6 +39,7 @@ void WellKnownNode::dump_tree(StringBuilder& builder)
|
|||
{
|
||||
static constexpr StringView type_to_name[] = {
|
||||
"False"sv,
|
||||
"NewTarget"sv,
|
||||
"Null"sv,
|
||||
"This"sv,
|
||||
"True"sv,
|
||||
|
|
|
@ -76,6 +76,7 @@ void tokenize_string(SpecificationParsingContext& ctx, XML::Node const* node, St
|
|||
{ "?"sv, TokenType::QuestionMark },
|
||||
{ "]"sv, TokenType::SquareBracketClose },
|
||||
{ "["sv, TokenType::SquareBracketOpen },
|
||||
{ "NewTarget"sv, TokenType::WellKnownValue },
|
||||
};
|
||||
|
||||
LineTrackingLexer lexer(view, node->offset);
|
||||
|
@ -95,7 +96,7 @@ void tokenize_string(SpecificationParsingContext& ctx, XML::Node const* node, St
|
|||
bool matched = false;
|
||||
for (auto const& [text_to_match, token_type] : choices) {
|
||||
if (lexer.consume_specific(text_to_match)) {
|
||||
tokens.append({ token_type, ""sv, move(token_location) });
|
||||
tokens.append({ token_type, text_to_match, move(token_location) });
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -220,6 +220,7 @@ TextParseErrorOr<Tree> TextParser::parse_value()
|
|||
WellKnownNode::Type type;
|
||||
} translations[] = {
|
||||
{ "false"sv, WellKnownNode::Type::False },
|
||||
{ "NewTarget"sv, WellKnownNode::Type::NewTarget },
|
||||
{ "null"sv, WellKnownNode::Type::Null },
|
||||
{ "this"sv, WellKnownNode::Type::This },
|
||||
{ "true"sv, WellKnownNode::Type::True },
|
||||
|
|
Loading…
Reference in a new issue