#ifndef roza_LEXER_HPP #define roza_LEXER_HPP #include "commons.hpp" #include "Node.hpp" #include "SrcLoc.hpp" #include "StatusLog.hpp" namespace roza { struct ScanInfo { std::shared_ptr node = nullptr; size_t cursor = 0; }; using scanner = std::function; class Lexer { public: explicit Lexer(StatusLog& log, SrcLoc loc); virtual ~Lexer(); SrcLoc loc() const { return m_loc; } size_t size() const { return m_nodes.size(); } void scan(std::string const& source); void skip_blanks(); std::shared_ptr get_or_nullptr(size_t index) const; private: StatusLog& m_log; SrcLoc m_loc; std::string m_source; size_t m_cursor = 0; std::vector> m_nodes; std::vector m_scanners; ScanInfo scan_int() const; }; } #endif