#ifndef SYNTAX_DECL_H #define SYNTAX_DECL_H #include "io/knot.h" #include "io/sysio.h" #include "pch.h" #include "syntax/trie.h" #define MAX_LINES_LOOKBEHIND 80 struct Highlight { uint32_t fg{0xFFFFFF}; uint32_t bg{0x000000}; uint8_t flags{0}; }; enum struct TokenKind : uint8_t { #define ADD(name) name, #include "syntax/tokens.def" #undef ADD Count }; constexpr size_t TOKEN_KIND_COUNT = static_cast(TokenKind::Count); const std::unordered_map kind_map = { #define ADD(name) {#name, TokenKind::name}, #include "syntax/tokens.def" #undef ADD }; extern std::array highlights; struct Token { uint32_t start; uint32_t end; TokenKind type; }; struct StateBase { virtual ~StateBase() = default; virtual std::unique_ptr clone() const = 0; }; struct CustomState : StateBase { std::string value; explicit CustomState(std::string v) : value(std::move(v)) {} std::unique_ptr clone() const override { return std::make_unique(value); } }; struct LineData { std::unique_ptr out_state; std::vector tokens; std::unique_ptr in_state; }; #endif