Files
crib/include/syntax/langs.h
Syed Daanish 5b66f503e4 Improve highlighting structure
- switched to a sparse delta based map
- true lazy-loading to avoid any unneccessary allocations
- fixed windows management api
2026-02-11 18:18:28 +00:00

37 lines
1.3 KiB
C++

#ifndef SYNTAX_LANGS_H
#define SYNTAX_LANGS_H
#include "syntax/decl.h"
#define DEF_LANG(name) \
std::unique_ptr<StateBase> name##_parse( \
std::vector<Token> *tokens, StateBase *in_state, const char *text, \
uint32_t len, uint32_t line_num); \
bool name##_state_match(StateBase *state_1, StateBase *state_2);
#define LANG_A(name) \
{ \
#name, { name##_parse, name##_state_match } \
}
template <typename B, typename A>
std::unique_ptr<B> static_unique_ptr_cast(std::unique_ptr<A> &&p) {
return std::unique_ptr<B>(static_cast<B *>(p.release()));
}
DEF_LANG(ruby);
DEF_LANG(bash);
inline static const std::unordered_map<
std::string,
std::tuple<std::unique_ptr<StateBase> (*)(
std::vector<Token> *tokens, StateBase *in_state,
const char *text, uint32_t len, uint32_t line_num),
bool (*)(StateBase *state_1, StateBase *state_2)>>
parsers = {
LANG_A(ruby),
LANG_A(bash),
};
#endif