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
|
|
@ -132,7 +132,7 @@ void SourceTextModule::visit_edges(Cell::Visitor& visitor)
|
|||
Result<GC::Ref<SourceTextModule>, Vector<ParserError>> SourceTextModule::parse(StringView source_text, Realm& realm, StringView filename, Script::HostDefined* host_defined)
|
||||
{
|
||||
// 1. Let body be ParseText(sourceText, Module).
|
||||
auto parser = Parser(Lexer(source_text, filename), Program::Type::Module);
|
||||
auto parser = Parser(Lexer(SourceCode::create(String::from_utf8(filename).release_value_but_fixme_should_propagate_errors(), Utf16String::from_utf8(source_text))), Program::Type::Module);
|
||||
auto body = parser.parse_program();
|
||||
|
||||
// 2. If body is a List of errors, return body.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue