Add basic c syntax highlighting.

This commit is contained in:
2026-09-14 11:25:29 +01:00
parent 8f67be87ee
commit 6711ecbaee
8 changed files with 448 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
#include "internal/syntax/c/parser.h"
namespace bed::internal::syntax::c {
Language lang_c() {
return Language{
.none_state = []() {
CState *st = (CState *)malloc(
sizeof(CState)
+ sizeof(CState::CInternalState)
);
st->top = 1;
st->stack()[0] = {
.brace_level = 1,
.state = CState::CInternalState::NONE,
.flags = 0
};
return st; },
.parse = c_parse,
.copy = [](void *v_i_st) {
CState *i_st = (CState *)v_i_st;
uint32_t bytes = sizeof(CState)
+ sizeof(CState::CInternalState) * i_st->top;
CState *o_st = (CState *)malloc(bytes);
memcpy(o_st, i_st, bytes);
return o_st; },
.equal = [](void *v_a_st, void *v_b_st) {
CState *a_st = (CState *)v_a_st;
uint32_t a_bytes = sizeof(CState)
+ sizeof(CState::CInternalState) * a_st->top;
CState *b_st = (CState *)v_b_st;
uint32_t b_bytes = sizeof(CState)
+ sizeof(CState::CInternalState) * b_st->top;
return a_bytes == b_bytes && memcmp(a_st, b_st, a_bytes) == 0; },
.destroy = [](void *v_st) { free(v_st); },
};
}
} // namespace bed::internal::syntax::c