rline: Update krk highlighter from kuroko
This commit is contained in:
parent
d4be70cfa0
commit
123940ec37
64
lib/rline.c
64
lib/rline.c
@ -535,7 +535,7 @@ char * syn_krk_keywords[] = {
|
||||
"and","class","def","else","for","if","in","import","del",
|
||||
"let","not","or","return","while","try","except","raise",
|
||||
"continue","break","as","from","elif","lambda","with","is",
|
||||
"pass",
|
||||
"pass","assert","yield","finally",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -544,8 +544,10 @@ char * syn_krk_types[] = {
|
||||
"self", "super", /* implicit in a class method */
|
||||
"len", "str", "int", "float", "dir", "repr", /* global functions from __builtins__ */
|
||||
"list","dict","range", /* builtin classes */
|
||||
"object","exception","isinstance","type",
|
||||
"print","set","any","all","bool","ord","chr","hex",
|
||||
"object","exception","isinstance","type","tuple","reversed",
|
||||
"print","set","any","all","bool","ord","chr","hex","oct","filter",
|
||||
"sorted","bytes","getattr","sum","min","max","id","hash","map","bin",
|
||||
"enumerate","zip","setattr","property","staticmethod","classmethod",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -554,6 +556,13 @@ char * syn_krk_special[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
char * syn_krk_exception[] = {
|
||||
"TypeError","ArgumentError","IndexError","KeyError","AttributeError",
|
||||
"NameError","ImportError","IOError","ValueError","KeyboardInterrupt",
|
||||
"ZeroDivisionError","SyntaxError","Exception",
|
||||
NULL
|
||||
};
|
||||
|
||||
int paint_krk_numeral(struct syntax_state * state) {
|
||||
if (charat() == '0' && (nextchar() == 'x' || nextchar() == 'X')) {
|
||||
paint(2, FLAG_NUMERAL);
|
||||
@ -614,6 +623,8 @@ int syn_krk_calculate(struct syntax_state * state) {
|
||||
return 0;
|
||||
} else if (find_keywords(state, syn_krk_special, FLAG_NUMERAL, c_keyword_qualifier)) {
|
||||
return 0;
|
||||
} else if (find_keywords(state, syn_krk_exception, FLAG_PRAGMA, c_keyword_qualifier)) {
|
||||
return 0;
|
||||
} else if (!c_keyword_qualifier(lastchar()) && isdigit(charat())) {
|
||||
paint_krk_numeral(state);
|
||||
return 0;
|
||||
@ -630,6 +641,52 @@ int syn_krk_calculate(struct syntax_state * state) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
char * syn_krk_dbg_commands[] = {
|
||||
"s", "skip",
|
||||
"c", "continue",
|
||||
"q", "quit",
|
||||
"e", "enable",
|
||||
"d", "disable",
|
||||
"r", "remove",
|
||||
"bt", "backtrace",
|
||||
"break",
|
||||
"abort",
|
||||
"help",
|
||||
NULL,
|
||||
};
|
||||
|
||||
char * syn_krk_dbg_info_types[] = {
|
||||
"breakpoints",
|
||||
NULL,
|
||||
};
|
||||
|
||||
int syn_krk_dbg_calculate(struct syntax_state * state) {
|
||||
if (state->state < 1) {
|
||||
if (state->i == 0) {
|
||||
if (match_and_paint(state, "p", FLAG_KEYWORD, c_keyword_qualifier) ||
|
||||
match_and_paint(state, "print", FLAG_KEYWORD, c_keyword_qualifier)) {
|
||||
while (1) {
|
||||
int result = syn_krk_calculate(state);
|
||||
if (result == 0) continue;
|
||||
if (result == -1) return -1;
|
||||
return result + 1;
|
||||
}
|
||||
} else if (match_and_paint(state,"info", FLAG_KEYWORD, c_keyword_qualifier) ||
|
||||
match_and_paint(state,"i", FLAG_KEYWORD, c_keyword_qualifier)) {
|
||||
skip();
|
||||
find_keywords(state,syn_krk_dbg_info_types, FLAG_TYPE, c_keyword_qualifier);
|
||||
return -1;
|
||||
} else if (find_keywords(state, syn_krk_dbg_commands, FLAG_KEYWORD, c_keyword_qualifier)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
state->state -= 1;
|
||||
return syn_krk_calculate(state) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __toaru__
|
||||
int esh_variable_qualifier(int c) {
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c == '_');
|
||||
@ -1020,6 +1077,7 @@ struct syntax_definition {
|
||||
int tabIndents;
|
||||
} syntaxes[] = {
|
||||
{"krk",syn_krk_calculate, 1},
|
||||
{"krk-dbg",syn_krk_dbg_calculate, 1},
|
||||
#ifdef __toaru__
|
||||
{"python",syn_py_calculate, 1},
|
||||
{"esh",syn_esh_calculate, 0},
|
||||
|
Loading…
x
Reference in New Issue
Block a user