/// AUTOGENERATED COPYRIGHT HEADER START // Copyright (C) 2017-2024 Michael Fabian 'Xaymar' Dirks // AUTOGENERATED COPYRIGHT HEADER END #pragma once #include #include #include #include #include #include #include #include #include "error.hpp" // ToDo: // - Figure out a way to let the lexer output line and character information? namespace blitz { struct token { std::pair location; std::string text; enum class variant : uint64_t { UNKNOWN, // We have absolutely no fucking clue. ENDOFFILE, // End of the file. NEWLINE, // New Line. SEPARATOR, // Command Separator. CONTROL, // All kinds of control signals SYMBOL, // All kinds of symbols. COMMENT, // ; Whatever TEXT, // HelloWorld STRING, // "HelloWorld" INTEGER, // 1, 1% (without the %) REAL, // 1.0, 1# (without the #) } type; std::string to_string(); }; class lexer { std::filesystem::path _file; std::ifstream _stream; // Current location in the file. std::pair _location; blitz::token _current; blitz::token _override; public: ~lexer(); lexer(std::filesystem::path file); /** Retrieve the current token information. */ blitz::token current(); /** Retrieve the next token in the given stream. * * This will replace the current token. */ blitz::token next(); }; } // namespace blitz