mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
JSSpecCompiler: Make it compile and dump AST created from stdin input
This commit is contained in:
parent
db0a03d1fb
commit
66f4cdba85
Notes:
sideshowbarker
2024-07-16 22:51:10 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/66f4cdba85 Pull-request: https://github.com/SerenityOS/serenity/pull/20632 Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 53 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
add_subdirectory(GMLCompiler)
|
||||
add_subdirectory(IPCCompiler)
|
||||
if (BUILD_LAGOM)
|
||||
add_subdirectory(JSSpecCompiler)
|
||||
endif()
|
||||
add_subdirectory(LibEDID)
|
||||
add_subdirectory(LibGL)
|
||||
add_subdirectory(LibLocale)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
set(SOURCES
|
||||
AST/ASTPrinting.cpp
|
||||
Parser/Lexer.cpp
|
||||
Parser/ParseError.cpp
|
||||
Parser/SpecParser.cpp
|
||||
Parser/TextParser.cpp
|
||||
Parser/XMLUtils.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
lagom_tool(JSSpecCompiler LIBS LibMain LibXML)
|
||||
target_include_directories(JSSpecCompiler PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_compile_options(JSSpecCompiler PRIVATE -Wno-missing-field-initializers)
|
37
Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/main.cpp
Normal file
37
Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/main.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibXML/Parser/Parser.h>
|
||||
|
||||
#include "Parser/SpecParser.h"
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
using namespace JSSpecCompiler;
|
||||
|
||||
auto input = TRY(TRY(Core::File::standard_input())->read_until_eof());
|
||||
XML::Parser parser { StringView(input.bytes()) };
|
||||
|
||||
auto maybe_document = parser.parse();
|
||||
if (maybe_document.is_error()) {
|
||||
outln("{}", maybe_document.error());
|
||||
return 1;
|
||||
}
|
||||
auto document = maybe_document.release_value();
|
||||
|
||||
auto maybe_function = JSSpecCompiler::Function::create(&document.root());
|
||||
if (maybe_function.is_error()) {
|
||||
outln("{}", maybe_function.error()->to_string());
|
||||
return 1;
|
||||
}
|
||||
auto function = maybe_function.value();
|
||||
|
||||
out("{}", function.m_algorithm.m_tree);
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue