1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

JSSpecCompiler: Start converting crashes to error messages

I got fed up with looking at error messages that tell me "VERIFICATION
FAILED: !is_error()". So this commit introduces DiagnosticEngine class
whose purpose is to accumulate and print more user-friendly errors.
This commit is contained in:
Dan Klishch 2024-01-18 21:09:53 -05:00 committed by Andrew Kaster
parent 3aec6952a2
commit 0806ccaeec
8 changed files with 262 additions and 4 deletions

View file

@ -15,6 +15,31 @@
#include "Parser/Token.h"
namespace JSSpecCompiler {
class SpecificationParsingContext {
AK_MAKE_NONCOPYABLE(SpecificationParsingContext);
AK_MAKE_NONMOVABLE(SpecificationParsingContext);
public:
SpecificationParsingContext(TranslationUnitRef translation_unit)
: m_translation_unit(translation_unit)
{
}
DiagnosticEngine& diag();
template<typename Func>
auto with_new_logical_scope(Func&& func);
LogicalLocation& current_logical_scope();
Location file_scope() const;
Location location_from_xml_offset(XML::Offset offset) const;
private:
TranslationUnitRef m_translation_unit;
RefPtr<LogicalLocation> m_current_logical_scope;
};
class AlgorithmStepList {
public:
static ParseErrorOr<AlgorithmStepList> create(XML::Node::Element const& element);