xarbon/language/flat.h

67 lines
4.7 KiB
C
Raw Permalink Normal View History

2024-09-28 13:33:22 -04:00
static void highlight_flat (void) {
char * separators = ".,+-=:;(){}[]%$<> \t\r\n";
char * instructions [] = {
"mov", "movabs", "movapd", "movaps", "movebe", "movsd", "movsx", "movzx",
"movsxd", "movd", "movq", "movs", "movsb", "movsw", "movsd", "movsq",
"cmovmp", "cmovrcxz", "cmovc", "cmovnc", "cmove", "cmovne", "cmovz", "cmovnz",
"cmovg", "cmovng", "cmovge", "cmovnge", "cmovl", "cmovnl", "cmovle", "cmovnle",
"cmova", "cmovna", "cmovae", "cmovnae", "cmovb", "cmovnb", "cmovbe", "cmovnbe",
"cmovs", "cmovns", "cmovo", "cmovno", "cmovp", "cmovnp", "cmovpo", "cmovpe",
"cmp", "cmps", "cmpsb", "cmpsw", "cmpsd", "cmpsq", "cmpxchg", "lea",
"monitor", "cpuid", "in", "out", "syscall", "sysenter", "sysret", "sysexit",
"swap", "bswap", "pop", "push", "call", "ret", "enter", "leave",
"and", "or", "not", "neg", "sal", "sar", "shl", "shr",
"inc", "dec", "add", "sub", "mul", "div", "imul", "idiv",
"nop", "fnop", "adc", "sbb", "aaa", "aas", "aam", "aad",
"jmp", "jrcxz", "jc", "jnc", "je", "jne", "jz", "jnz",
"jg", "jng", "jge", "jnge", "jl", "jnl", "jle", "jnle",
"ja", "jna", "jae", "jnae", "jb", "jnb", "jbe", "jnbe",
"js", "jns", "jo", "jno", "jp", "jnp", "jpo", "jpe",
"rep", "repe", "repz", "repne", "repnz", "loop", "loope", "loopne"
};
char * registers [] = {
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
"r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d",
"ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
"r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w",
"al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
"r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b",
"ah", "ch", "dh", "bh"
};
char * keywords [] = {
"format", "executable", "readable", "writable", "segment", "sector", "entry", "macro",
"db", "dw", "dd", "dq", "rb", "rw", "rd", "rq"
};
int word;
syntax_define (false, false, ";", "\n", '\0', (int) 0xff777777, 0);
syntax_define (false, false, "'", "'", '\\', (int) 0xff7733cc, 0);
syntax_define (false, false, "\"", "\"", '\\', (int) 0xffcc3377, 0);
for (word = 0; word != (int) (sizeof (instructions) / sizeof (instructions [0])); ++word) {
syntax_define (false, true, instructions [word], separators, '\0', (int) 0xff33ccee, 0);
}
for (word = 0; word != (int) (sizeof (registers) / sizeof (registers [0])); ++word) {
syntax_define (false, true, registers [word], separators, '\0', (int) 0xffccaa77, 0);
}
for (word = 0; word != (int) (sizeof (keywords) / sizeof (keywords [0])); ++word) {
syntax_define (false, true, keywords [word], separators, '\0', (int) 0xff55aacc, 0);
}
syntax_define (true, false, "()[]{}", "", '\0', (int) 0xffee5533, 0);
syntax_define (true, false, ".,+-=:;%$<>", "", '\0', (int) 0xffeeaa33, 0);
syntax_define (true, true, "0123456789", separators, '\0', (int) 0xffee33aa, 0);
syntax_define (true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', (int) 0xffcccccc, 0);
syntax_define (true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', (int) 0xffeeeeee, 0);
syntax_define (true, true, "_", separators, '\0', (int) 0xffaaaaaa, 0);
}