#ifndef jk_LEXER_HPP #define jk_LEXER_HPP #include "commons.hpp" #include "Logger.hpp" #include "Node.hpp" namespace jk { JK_ERROR(lexical_error); struct ScanInfo { size_t cursor; NodeType type; std::string repr; }; using scanner_t = std::function()>; class Lexer { public: explicit Lexer(Logger& logger, Loc const& loc); virtual ~Lexer(); void scan(std::string const& source); std::shared_ptr next(); private: Logger& m_logger; Loc m_loc; size_t m_cursor; std::string m_source; std::vector m_scanners; bool more(size_t index) const; char current(size_t index) const; void skip_spaces(); std::optional scan_int() const; }; } #endif