/// AUTOGENERATED COPYRIGHT HEADER START // Copyright (C) 2017-2025 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 { NONE, // There is no token here. 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(); bool operator==(blitz::token::variant rhs); bool operator==(std::string const& rhs); }; class lexer { std::filesystem::path _file; std::ifstream _stream; // Current location in the file. std::pair _location; blitz::token _current; blitz::token _next; 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(); /** Peek at the next token in the given stream. * * The current token will remain in-tact. */ blitz::token peek(); public: std::filesystem::path file(); }; } // namespace blitz