Highlight builtin exception type names

This commit is contained in:
K. Lange 2021-01-24 12:54:32 +09:00
parent 50e4902170
commit 75ed11abea

View File

@ -552,13 +552,21 @@ 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",
"object","exception","isinstance","type","tuple",
"print","set","any","all","bool","ord","chr","hex",
NULL
};
char * syn_krk_special[] = {
"True","False","None",
/* Exception names */
NULL
};
char * syn_krk_exception[] = {
"TypeError","ArgumentError","IndexError","KeyError","AttributeError",
"NameError","ImportError","IOError","ValueError","KeyboardInterrupt",
"ZeroDivisionError","SyntaxError","Exception",
NULL
};
@ -622,6 +630,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;