1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:57:44 +00:00

JSSpecCompiler: Add functions for splitting node contents into tokens

This commit is contained in:
Dan Klishch 2023-08-17 22:29:05 -04:00 committed by Andrew Kaster
parent 8342361481
commit 9f29e04897
6 changed files with 378 additions and 0 deletions

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2023, Dan Klishch <danilklishch@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <LibXML/DOM/Node.h>
namespace JSSpecCompiler {
class ParseError : public RefCounted<ParseError> {
public:
ParseError(String&& message, XML::Node const* node)
: m_message(move(message))
, m_node(node)
{
}
static NonnullRefPtr<ParseError> create(String message, XML::Node const* node);
static NonnullRefPtr<ParseError> create(StringView message, XML::Node const* node);
static NonnullRefPtr<ParseError> create(ErrorOr<String> message, XML::Node const* node);
String to_string() const;
private:
String m_message;
XML::Node const* m_node;
// TODO: Support chained parse errors
};
template<typename T>
using ParseErrorOr = ErrorOr<T, NonnullRefPtr<ParseError>>;
}