79 lines
2.0 KiB
C
79 lines
2.0 KiB
C
#include <stdlib.h>
|
|
|
|
#define HL_HIGHLIGHT_NUMBERS (1<<0)
|
|
#define HL_HIGHLIGHT_STRINGS (1<<1)
|
|
|
|
struct editorSyntax {
|
|
char *filetype;
|
|
char **filematch;
|
|
char *singleline_comment_start;
|
|
char *multiline_comment_start;
|
|
char *multiline_comment_end;
|
|
char **keywords;
|
|
int flags;
|
|
};
|
|
|
|
//
|
|
// filetypes
|
|
// ---------
|
|
char *C_HL_extensions[] = {".c", ".h", ".cpp", NULL};
|
|
char *C_HL_keywords[] = {
|
|
"switch", "if", "while", "for", "break", "return", "else", "continue",
|
|
"struct|", "union", "typedef", "static", "enum|", "class", "case|",
|
|
"int|", "long|", "double|", "float|", "char|", "unsigned|", "signed|",
|
|
"void|", "NULL", NULL
|
|
};
|
|
|
|
char *PY_HL_extensions[] = {".py", ".pyc", NULL};
|
|
char *PY_HL_keywords[] = {
|
|
"if", "elif", "for", "break", "return", "else",
|
|
"def", "", "static", "enum", "class", "with", "assert",
|
|
"except", "continue", "while", "finally", "try", "global",
|
|
"False|", "True|", "None|", "not|", "and|", "as|", "yield|",
|
|
"void|", "or|", "import|", "is|", "in|", "lambda|", "pass|",
|
|
"raise|", "del|", NULL
|
|
};
|
|
|
|
char *GO_HL_extensions[] = {".go", NULL};
|
|
char *GO_HL_keywords[] = {
|
|
"break", "switch", "continue", "func", "interface", "select",
|
|
"case", "defer", "go", "map", "struct", "chan", "else", "goto",
|
|
"package", "const", "fallthrough|", "if", "range|", "type",
|
|
"for", "import", "return", "var", "uint8|", "uint16|", "uint32|",
|
|
"uint64", "int|", "uint|", "int8|", "int16|", "int32|", "int64|",
|
|
"float32|", "float", "float64|", "complex64|", "complex128|",
|
|
"byte|", "rune|", "uintptr|", "string|", "bool|", NULL
|
|
};
|
|
|
|
static struct editorSyntax HLDB[] = {
|
|
{
|
|
"c",
|
|
C_HL_extensions,
|
|
"//",
|
|
"/*",
|
|
"*/",
|
|
C_HL_keywords,
|
|
HL_HIGHLIGHT_NUMBERS | HL_HIGHLIGHT_STRINGS
|
|
},
|
|
{
|
|
"python",
|
|
PY_HL_extensions,
|
|
"#",
|
|
"'''",
|
|
"'''",
|
|
PY_HL_keywords,
|
|
HL_HIGHLIGHT_NUMBERS | HL_HIGHLIGHT_STRINGS
|
|
},
|
|
{
|
|
"go",
|
|
GO_HL_extensions,
|
|
"//",
|
|
"/*",
|
|
"*/",
|
|
GO_HL_keywords,
|
|
HL_HIGHLIGHT_NUMBERS | HL_HIGHLIGHT_STRINGS
|
|
}
|
|
};
|
|
|
|
#define HLDB_ENTRIES (sizeof(HLDB) / sizeof(HLDB[0]))
|