From 8f98dc579af1993ec85bd849656c4835b4039dd6 Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Mon, 23 Feb 2026 22:18:22 -0500 Subject: [willow]: frontend plumbing (#13) ... --- willow/tools/willowc/include/parser.hpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'willow/tools/willowc/include/parser.hpp') diff --git a/willow/tools/willowc/include/parser.hpp b/willow/tools/willowc/include/parser.hpp index 825dfdd..59f6bfb 100644 --- a/willow/tools/willowc/include/parser.hpp +++ b/willow/tools/willowc/include/parser.hpp @@ -1,31 +1,39 @@ #ifndef WILLOWC_INCLUDE_PARSER_HPP #define WILLOWC_INCLUDE_PARSER_HPP -#include #include +#include +#include + +#include -#include #include +#include #include namespace willowc { class Parser { - std::string_view buf; +public: + Parser(SourceManager::File &f, willow::DiagnosticEngine &diagnostic_engine) + : file_(f), tokenizer_(f.buf.get()), + diagnostic_engine_(diagnostic_engine) {} - std::vector kinds; - std::vector starts; - Tokenizer tokenizer; + std::optional> run(); - std::size_t pos; + TokenKind kind() const { return kinds_[pos_]; } + std::size_t start() const { return starts_[pos_]; } -public: - Parser(std::string_view buf) : buf(buf), tokenizer(buf) {} +private: + willow::DiagnosticBuilder emitParserError(Token t, willow::Severity severity); - std::optional> parse(); + SourceManager::File &file_; + std::vector kinds_; + std::vector starts_; + Tokenizer tokenizer_; + std::size_t pos_; + willow::DiagnosticEngine &diagnostic_engine_; - TokenKind kind() const { return kinds[pos]; } - std::size_t start() const { return starts[pos]; } }; } // namespace willowc -- cgit v1.2.3