mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibJS: Have JS::Lexer take a JS::SourceCode as input
This moves the responsibility of setting up a SourceCode object to the users of JS::Lexer. This means Lexer and Parser are free to use string views into the SourceCode internally while working. It also means Lexer no longer has to think about anything other than UTF-16 (or ASCII) inputs. So the unit test for parsing various invalid UTF-8 sequences is deleted here.
This commit is contained in:
parent
9ca25e55d7
commit
0dacc94edd
Notes:
github-actions[bot]
2025-11-09 11:15:22 +00:00
Author: https://github.com/awesomekling
Commit: 0dacc94edd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6764
16 changed files with 59 additions and 227 deletions
|
|
@ -55,7 +55,8 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(HTML::BrowsingCo
|
|||
}})~~~",
|
||||
body);
|
||||
|
||||
auto parser = JS::Parser { JS::Lexer { source_text } };
|
||||
auto parser = JS::Parser(JS::Lexer(JS::SourceCode::create({}, Utf16String::from_utf8(source_text))));
|
||||
;
|
||||
auto function_expression = parser.parse_function_node<JS::FunctionExpression>();
|
||||
|
||||
// 4. If body is not parsable as a FunctionBody or if parsing detects an early error, return Completion { [[Type]]: normal, [[Value]]: null, [[Target]]: empty }.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue