kuroko, bim: sync with upstream

This commit is contained in:
K. Lange 2021-03-28 22:00:23 +09:00
parent 33fbcde1fd
commit 5947bec72c
10 changed files with 241 additions and 109 deletions

View File

@ -76,6 +76,7 @@ global_config_t global_config = {
.has_terminal = 0,
.search_wraps = 1,
.had_error = 0,
.use_biminfo = 1,
/* Integer config values */
.cursor_padding = 4,
.split_percent = 50,
@ -538,7 +539,8 @@ buffer_t * buffer_new(void) {
* Open the biminfo file.
*/
FILE * open_biminfo(void) {
/* TODO: biminfo paths should probably configurable with an arg, like bimrc */
if (!global_config.use_biminfo) return NULL;
char * home = getenv("HOME");
if (!home) {
/* ... but since it's not, we need $HOME, so fail if it isn't set. */
@ -3695,6 +3697,25 @@ int line_matches(line_t * line, char * string) {
void run_onload(buffer_t * env) {
/* TODO */
KrkValue onLoad;
if (krk_tableGet_fast(&krk_currentThread.module->fields, S("onload"), &onLoad)) {
krk_push(onLoad);
krk_push(krk_dict_of(0,NULL,0));
if (env->file_name) {
krk_attachNamedObject(AS_DICT(krk_peek(0)), "filename",
(KrkObj*)krk_copyString(env->file_name,strlen(env->file_name)));
}
if (env->syntax && env->syntax->krkClass) {
krk_attachNamedObject(AS_DICT(krk_peek(0)), "highlighter",
(KrkObj*)env->syntax->krkClass);
}
krk_callSimple(onLoad, 1, 1);
krk_resetStack();
}
}
static void render_syntax_async(background_task_t * task) {
@ -10251,11 +10272,13 @@ int c_keyword_qualifier(int c) {
}
#define BIM_STATE() \
if (argc < 1 || !krk_isInstanceOf(argv[0],syntaxStateClass)) return krk_runtimeError(vm.exceptions->typeError, "expected state"); \
if (unlikely(argc < 1 || !krk_isInstanceOf(argv[0],syntaxStateClass))) return krk_runtimeError(vm.exceptions->typeError, "expected state"); \
KrkInstance * _self = AS_INSTANCE(argv[0]); \
struct SyntaxState * self = (struct SyntaxState*)_self; \
struct syntax_state * state = &self->state;
static KrkTuple * _bim_state_chars = NULL;
static KrkValue bim_krk_state_getstate(int argc, KrkValue argv[], int hasKw) {
BIM_STATE();
if (argc > 1 && IS_INTEGER(argv[1])) {
@ -10289,6 +10312,7 @@ static KrkValue bim_krk_state_get(int argc, KrkValue argv[], int hasKw) {
long arg = AS_INTEGER(argv[1]);
int charRel = charrel(arg);
if (charRel == -1) return NONE_VAL();
if (charRel >= 32 && charRel <= 126) return _bim_state_chars->values.values[charRel - 32];
char tmp[8] = {0};
size_t len = to_eight(charRel, tmp);
return OBJECT_VAL(krk_copyString(tmp,len));
@ -10331,13 +10355,14 @@ static KrkValue bim_krk_state_skip(int argc, KrkValue argv[], int hasKw) {
return NONE_VAL();
}
static KrkValue bim_krk_state_cKeywordQualifier(int argc, KrkValue argv[], int hasKw) {
if (IS_INTEGER(argv[1])) return BOOLEAN_VAL(!!c_keyword_qualifier(AS_INTEGER(argv[1])));
if (!IS_STRING(argv[1])) return BOOLEAN_VAL(0);
if (AS_STRING(argv[1])->length > 1) return BOOLEAN_VAL(0);
return BOOLEAN_VAL(!!c_keyword_qualifier(AS_CSTRING(argv[1])[0]));
if (IS_INTEGER(argv[0])) return BOOLEAN_VAL(!!c_keyword_qualifier(AS_INTEGER(argv[0])));
if (!IS_STRING(argv[0])) return BOOLEAN_VAL(0);
if (AS_STRING(argv[0])->length > 1) return BOOLEAN_VAL(0);
return BOOLEAN_VAL(!!c_keyword_qualifier(AS_CSTRING(argv[0])[0]));
}
static int callQualifier(KrkValue qualifier, int codepoint) {
if (IS_NATIVE(qualifier) && AS_NATIVE(qualifier)->function == bim_krk_state_cKeywordQualifier) return AS_BOOLEAN(!!c_keyword_qualifier(codepoint));
krk_push(qualifier);
krk_push(INTEGER_VAL(codepoint));
KrkValue result = krk_callSimple(krk_peek(1), 1, 1);
@ -10352,7 +10377,7 @@ static int callQualifier(KrkValue qualifier, int codepoint) {
static KrkValue bim_krk_state_findKeywords(int argc, KrkValue argv[], int hasKw) {
BIM_STATE();
if (argc < 4 || !krk_isInstanceOf(argv[1], vm.baseClasses->listClass) || !IS_INTEGER(argv[2]))
if (unlikely(argc < 4 || !(IS_INSTANCE(argv[1]) && AS_INSTANCE(argv[1])->_class == vm.baseClasses->listClass) || !IS_INTEGER(argv[2])))
return krk_runtimeError(vm.exceptions->typeError, "invalid arguments to SyntaxState.findKeywords");
KrkValue qualifier = argv[3];
@ -10704,7 +10729,12 @@ void initialize(void) {
global_config.tab_indicator = strdup(">");
global_config.space_indicator = strdup("-");
#if 0
krk_initVM(KRK_GLOBAL_CALLGRIND); /* no debug flags */
vm.callgrindFile = fopen("callgrind.out","w");
#else
krk_initVM(0); /* no debug flags */
#endif
KrkInstance * bimModule = krk_newInstance(vm.baseClasses->moduleClass);
krk_attachNamedObject(&vm.modules, "bim", (KrkObj*)bimModule);
@ -10758,7 +10788,7 @@ void initialize(void) {
krk_defineNative(&syntaxStateClass->methods, "__init__", bim_krk_state_init);
/* These ones take argumens so they're methods instead of dynamic fields */
krk_defineNative(&syntaxStateClass->methods, "findKeywords", bim_krk_state_findKeywords);
krk_defineNative(&syntaxStateClass->methods, "cKeywordQualifier", bim_krk_state_cKeywordQualifier);
krk_defineNative(&syntaxStateClass->methods, "cKeywordQualifier", bim_krk_state_cKeywordQualifier)->flags |= KRK_NATIVE_FLAGS_IS_STATIC_METHOD;
krk_defineNative(&syntaxStateClass->methods, "isdigit", bim_krk_state_isdigit);
krk_defineNative(&syntaxStateClass->methods, "isxdigit", bim_krk_state_isxdigit);
krk_defineNative(&syntaxStateClass->methods, "paint", bim_krk_state_paint);
@ -10783,6 +10813,13 @@ void initialize(void) {
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_LINK", INTEGER_VAL(FLAG_LINK));
krk_attachNamedValue(&syntaxStateClass->methods, "FLAG_ESCAPE", INTEGER_VAL(FLAG_ESCAPE));
_bim_state_chars = krk_newTuple(95);
krk_attachNamedObject(&syntaxStateClass->methods, "__chars__", (KrkObj*)_bim_state_chars);
for (int c = 0; c < 95; ++c) {
char tmp = c + 32;
_bim_state_chars->values.values[_bim_state_chars->values.count++] = OBJECT_VAL(krk_copyString(&tmp,1));
}
krk_finalizeClass(syntaxStateClass);
krk_resetStack();
@ -11250,6 +11287,7 @@ int main(int argc, char * argv[]) {
case 'C':
/* Print file to stdout using our syntax highlighting and color theme */
initialize();
global_config.use_biminfo = 0;
global_config.go_to_line = 0;
open_file(optarg);
for (int i = 0; i < env->line_count; ++i) {

View File

@ -210,6 +210,7 @@ typedef struct {
unsigned int has_terminal:1;
unsigned int search_wraps:1;
unsigned int had_error:1;
unsigned int use_biminfo:1;
int cursor_padding;
int split_percent;

View File

@ -13,11 +13,15 @@
#include <signal.h>
#include <errno.h>
#ifdef __toaru__
#include <toaru/rline.h>
#else
#ifndef NO_RLINE
#include "vendor/rline.h"
#endif
#endif
#define DEBUG
#include <kuroko/kuroko.h>
#include <kuroko/chunk.h>
#include <kuroko/debug.h>
#include <kuroko/vm.h>
@ -29,6 +33,8 @@
#define PROMPT_MAIN ">>> "
#define PROMPT_BLOCK " > "
#define CALLGRIND_TMP_FILE "/tmp/kuroko.callgrind.tmp"
static int enableRline = 1;
static int exitRepl = 0;
static int pasteEnabled = 0;
@ -258,7 +264,7 @@ static void tab_complete_func(rline_context_t * c) {
KrkValue thisValue = findFromProperty(root, asToken);
krk_push(thisValue);
if (IS_CLOSURE(thisValue) || IS_BOUND_METHOD(thisValue) ||
(IS_NATIVE(thisValue) && !(((KrkNative*)AS_OBJECT(thisValue))->flags & KRK_NATIVE_FLAGS_IS_DYNAMIC_PROPERTY))) {
(IS_NATIVE(thisValue) && !((KrkNative*)AS_OBJECT(thisValue))->flags & KRK_NATIVE_FLAGS_IS_DYNAMIC_PROPERTY)) {
size_t allocSize = s->length + 2;
char * tmp = malloc(allocSize);
size_t len = snprintf(tmp, allocSize, "%s(", s->chars);
@ -368,6 +374,7 @@ _cleanup:
}
#endif
#ifdef DEBUG
static char * lastDebugCommand = NULL;
static int debuggerHook(KrkCallFrame * frame) {
@ -420,7 +427,10 @@ static int debuggerHook(KrkCallFrame * frame) {
}
} else {
#ifndef NO_RLINE
if (enableRline) rline_history_insert(strdup(buf));
if (enableRline) {
rline_history_insert(strdup(buf));
rline_scroll = 0;
}
#endif
if (lastDebugCommand) free(lastDebugCommand);
lastDebugCommand = strdup(buf);
@ -611,6 +621,7 @@ static int debuggerHook(KrkCallFrame * frame) {
_dbgQuit:
return KRK_DEBUGGER_QUIT;
}
#endif
static void handleSigint(int sigNum) {
/* Don't set the signal flag if the VM is not running */
@ -618,8 +629,14 @@ static void handleSigint(int sigNum) {
krk_currentThread.flags |= KRK_THREAD_SIGNALLED;
}
static void handleSigtrap(int sigNum) {
if (!krk_currentThread.frameCount) return;
krk_currentThread.flags |= KRK_THREAD_SINGLE_STEP;
}
static void bindSignalHandlers(void) {
signal(SIGINT, handleSigint);
signal(SIGTRAP, handleSigtrap);
}
static void findInterpreter(char * argv[]) {
@ -721,13 +738,16 @@ int main(int argc, char * argv[]) {
SetConsoleOutputCP(65001);
SetConsoleCP(65001);
#endif
char * runCmd = NULL;
int flags = 0;
int moduleAsMain = 0;
int inspectAfter = 0;
int opt;
while ((opt = getopt(argc, argv, "+c:C:dgm:rstMSV-:")) != -1) {
while ((opt = getopt(argc, argv, "+:c:C:dgGim:rstTMSV-:")) != -1) {
switch (opt) {
case 'c':
return runString(argv, flags, optarg);
runCmd = optarg;
goto _finishArgs;
case 'd':
/* Disassemble code blocks after compilation. */
flags |= KRK_THREAD_ENABLE_DISASSEMBLY;
@ -736,6 +756,9 @@ int main(int argc, char * argv[]) {
/* Always garbage collect during an allocation. */
flags |= KRK_GLOBAL_ENABLE_STRESS_GC;
break;
case 'G':
flags |= KRK_GLOBAL_REPORT_GC_COLLECTS;
break;
case 's':
/* Print debug information during compilation. */
flags |= KRK_THREAD_ENABLE_SCAN_TRACING;
@ -747,6 +770,14 @@ int main(int argc, char * argv[]) {
/* Disassemble instructions as they are executed. */
flags |= KRK_THREAD_ENABLE_TRACING;
break;
case 'T': {
flags |= KRK_GLOBAL_CALLGRIND;
vm.callgrindFile = fopen(CALLGRIND_TMP_FILE,"w");
break;
}
case 'i':
inspectAfter = 1;
break;
case 'm':
moduleAsMain = 1;
optind--; /* to get us back to optarg */
@ -760,19 +791,33 @@ int main(int argc, char * argv[]) {
return runString(argv,0,"import kuroko; print('Kuroko',kuroko.version)\n");
case 'C':
return compileFile(argv,flags,optarg);
case ':':
fprintf(stderr, "%s: option '%c' requires an argument\n", argv[0], optopt);
return 1;
case '?':
if (optopt != '-') {
fprintf(stderr, "%s: unrecognized option '%c'\n", argv[0], optopt);
return 1;
}
optarg = argv[optind]+2;
/* fall through */
case '-':
if (!strcmp(optarg,"version")) {
return runString(argv,0,"import kuroko; print('Kuroko',kuroko.version)\n");
} else if (!strcmp(optarg,"help")) {
#ifndef KRK_NO_DOCUMENTATION
fprintf(stderr,"usage: %s [flags] [FILE...]\n"
"\n"
"Interpreter options:\n"
" -d Debug output from the bytecode compiler.\n"
" -g Collect garbage on every allocation.\n"
" -G Report GC collections.\n"
" -i Enter repl after a running -c, -m, or FILE.\n"
" -m mod Run a module as a script.\n"
" -r Disable complex line editing in the REPL.\n"
" -s Debug output from the scanner/tokenizer.\n"
" -t Disassemble instructions as they are exceuted.\n"
" -T Write call trace file.\n"
" -C file Compile 'file', but do not execute it.\n"
" -M Print the default module import paths.\n"
" -S Enable single-step debugging.\n"
@ -783,6 +828,7 @@ int main(int argc, char * argv[]) {
"\n"
"If no files are provided, the interactive REPL will run.\n",
argv[0]);
#endif
return 0;
} else {
fprintf(stderr,"%s: unrecognized option '--%s'\n",
@ -796,7 +842,9 @@ _finishArgs:
findInterpreter(argv);
krk_initVM(flags);
#ifdef DEBUG
krk_debug_registerCallback(debuggerHook);
#endif
/* Attach kuroko.argv - argv[0] will be set to an empty string for the repl */
if (argc == optind) krk_push(OBJECT_VAL(krk_copyString("",0)));
@ -815,6 +863,7 @@ _finishArgs:
#ifdef BUNDLE_LIBS
/* Add any other modules you want to include that are normally built as shared objects. */
BUNDLED(math);
BUNDLED(socket);
#endif
KrkValue result = INTEGER_VAL(0);
@ -846,8 +895,28 @@ _finishArgs:
krk_dumpTraceback();
krk_resetStack();
}
return out;
} else if (optind == argc) {
if (!inspectAfter) return out;
if (IS_INSTANCE(krk_peek(0))) {
krk_currentThread.module = AS_INSTANCE(krk_peek(0));
}
} else if (optind != argc) {
krk_startModule("__main__");
result = krk_runfile(argv[optind],argv[optind]);
if (IS_NONE(result) && krk_currentThread.flags & KRK_THREAD_HAS_EXCEPTION) result = INTEGER_VAL(1);
}
if (!krk_currentThread.module) {
/* The repl runs in the context of a top-level module so each input
* line can share a globals state with the others. */
krk_startModule("__main__");
krk_attachNamedValue(&krk_currentThread.module->fields,"__doc__", NONE_VAL());
}
if (runCmd) {
result = krk_interpret(runCmd, "<stdin>");
}
if ((!moduleAsMain && !runCmd && optind == argc) || inspectAfter) {
/* Add builtins for the repl, but hide them from the globals() list. */
KRK_DOC(BIND_FUNC(vm.builtins,exit), "@brief Exit the interactive repl.\n\n"
"Only available from the interactive interpreter; exits the repl.");
@ -858,11 +927,6 @@ _finishArgs:
"it will be set to the opposite of the current mode. The new mode will be "
"printed to stderr.");
/* The repl runs in the context of a top-level module so each input
* line can share a globals state with the others. */
krk_startModule("__main__");
krk_attachNamedValue(&krk_currentThread.module->fields,"__doc__", NONE_VAL());
/**
* Python stores version info in a built-in module called `sys`.
* We are not Python, we'll use `sys` to pretend to be Python
@ -1028,7 +1092,10 @@ _finishArgs:
for (size_t i = 0; i < lineCount; ++i) {
if (valid) strcat(allData, lines[i]);
#ifndef NO_RLINE
if (enableRline) rline_history_insert(strdup(lines[i]));
if (enableRline) {
rline_history_insert(strdup(lines[i]));
rline_scroll = 0;
}
#endif
free(lines[i]);
}
@ -1058,10 +1125,20 @@ _finishArgs:
(void)blockWidth;
}
} else {
krk_startModule("__main__");
result = krk_runfile(argv[optind],argv[optind]);
if (IS_NONE(result) && krk_currentThread.flags & KRK_THREAD_HAS_EXCEPTION) result = INTEGER_VAL(1);
}
if (vm.globalFlags & KRK_GLOBAL_CALLGRIND) {
fclose(vm.callgrindFile);
vm.globalFlags &= ~(KRK_GLOBAL_CALLGRIND);
krk_resetStack();
krk_startModule("<callgrind>");
krk_attachNamedObject(&krk_currentThread.module->fields, "filename", (KrkObj*)S(CALLGRIND_TMP_FILE));
krk_interpret(
"from callgrind import processFile\n"
"import kuroko\n"
"import os\n"
"processFile(filename, os.getpid(), ' '.join(kuroko.argv))","<callgrind>");
}
krk_freeVM();

View File

@ -36,10 +36,12 @@ class Highlighter(SyntaxState):
else:
self.paint(1, self.FLAG_STRING)
@staticmethod
def isalpha(c):
c = c if isinstance(c,int) else ord(c)
return (c >= ord('a') and c <= ord('z')) or (c >= ord('A') and c <= ord('Z'))
@staticmethod
def isalnum(c):
c = c if isinstance(c,int) else ord(c)
return (c >= ord('a') and c <= ord('z')) or (c >= ord('A') and c <= ord('Z')) or (c >= ord('0') and c <= ord('9'))

View File

@ -152,55 +152,53 @@ class CHighlighter(Highlighter):
def calculate(self):
let cond = self.state
if cond <= 0:
if self[0] == '#':
for i in range(self.i):
if self[-i-1] != ' ' and self[-i-1] != '\t':
self.skip()
return 0
self.paint(1, self.FLAG_PRAGMA)
while self[0] == ' ':
while self[0]:
if self[0] == '#':
for i in range(self.i):
if self[-i-1] != ' ' and self[-i-1] != '\t':
self.skip()
continue
self.paint(1, self.FLAG_PRAGMA)
if self.matchAndPaint("include", self.FLAG_PRAGMA, self.cKeywordQualifier):
while self[0] == ' ':
self.paint(1, self.FLAG_PRAGMA)
if self[0] == '<':
self.paint(1, self.FLAG_STRING)
while self[0] != '>' and self[0] != None:
if self.matchAndPaint("include", self.FLAG_PRAGMA, self.cKeywordQualifier):
while self[0] == ' ':
self.paint(1, self.FLAG_PRAGMA)
if self[0] == '<':
self.paint(1, self.FLAG_STRING)
if self[0] != None:
self.paint(1, self.FLAG_STRING)
else if self.matchAndPaint("if", self.FLAG_PRAGMA, self.cKeywordQualifier):
if self[0] == ' ' and self[1] == '0' and self[2] == None:
self.paint(2, self.FLAG_COMMENT)
self.rewind(6)
self.paint(-1, self.FLAG_COMMENT)
return self.preprocessor_base_state
else if self.matchAndPaint("else", self.FLAG_PRAGMA, self.cKeywordQualifier):
# Do nothing?
return self.paintCPragma()
else if self[0] == '/' and self[1] == '/':
self.paintComment()
else if self[0] == '/' and self[1] == '*':
self.paint(2, self.FLAG_COMMENT)
return self.paintCComment()
else if self.findKeywords(self.keywords, self.FLAG_KEYWORD, self.cKeywordQualifier):
return 0
else if self.findKeywords(self.types, self.FLAG_TYPE, self.cKeywordQualifier):
return 0
else if self.findKeywords(self.special, self.FLAG_NUMERAL, self.cKeywordQualifier):
return 0
else if self[0] == '"':
self.paint(1, self.FLAG_STRING)
return self.paintCString()
else if self[0] == "'":
self.paintCChar()
return 0
else if not self.cKeywordQualifier(self[-1]) and self.isdigit(self[0]):
self.paintCNumeral()
return 0
else if self[0] != None:
self.skip()
return 0
while self[0] != '>' and self[0] != None:
self.paint(1, self.FLAG_STRING)
if self[0] != None:
self.paint(1, self.FLAG_STRING)
else if self.matchAndPaint("if", self.FLAG_PRAGMA, self.cKeywordQualifier):
if self[0] == ' ' and self[1] == '0' and self[2] == None:
self.paint(2, self.FLAG_COMMENT)
self.rewind(6)
self.paint(-1, self.FLAG_COMMENT)
return self.preprocessor_base_state
else if self.matchAndPaint("else", self.FLAG_PRAGMA, self.cKeywordQualifier):
# Do nothing?
return self.paintCPragma()
else if self[0] == '/' and self[1] == '/':
self.paintComment()
else if self[0] == '/' and self[1] == '*':
self.paint(2, self.FLAG_COMMENT)
return self.paintCComment()
else if self.findKeywords(self.keywords, self.FLAG_KEYWORD, self.cKeywordQualifier):
continue
else if self.findKeywords(self.types, self.FLAG_TYPE, self.cKeywordQualifier):
continue
else if self.findKeywords(self.special, self.FLAG_NUMERAL, self.cKeywordQualifier):
continue
else if self[0] == '"':
self.paint(1, self.FLAG_STRING)
return self.paintCString()
else if self[0] == "'":
self.paintCChar()
else if not self.cKeywordQualifier(self[-1]) and self.isdigit(self[0]):
self.paintCNumeral()
else:
self.skip()
else if cond == 1:
return self.paintCComment()
else if cond == 2:

View File

@ -1,39 +1,48 @@
let doxygen_keywords_at = [
"@author","@brief","@class","@short","@retval",
"@since","@return","@returns","@throws","@bug",
"@version","@deprecated","@attention","@note",
]
def tryDoxygenComment(b,defaultflag=b.FLAG_COMMENT):
def _make_dox():
from syntax import Highlighter
let doxygen_keywords_at = [
"@author","@brief","@class","@short","@retval",
"@since","@return","@returns","@throws","@bug",
"@version","@deprecated","@attention","@note",
]
let doxygen_word_commands = {
'@param': b.FLAG_TYPE,
'@exception': b.FLAG_PRAGMA,
'@def': b.FLAG_TYPE,
'@see': b.FLAG_LINK,
'@p': b.FLAG_TYPE,
'@c': b.FLAG_NONE,
'@file': b.FLAG_LINK,
'@memberof': b.FLAG_TYPE,
'@extends': b.FLAG_TYPE,
'@mainpage': b.FLAG_STRING,
'@section': b.FLAG_BOLD,
'@subsection': b.FLAG_BOLD,
'@package': b.FLAG_TYPE,
'@ref': b.FLAG_LINK,
'@param': Highlighter.FLAG_TYPE,
'@exception': Highlighter.FLAG_PRAGMA,
'@def': Highlighter.FLAG_TYPE,
'@see': Highlighter.FLAG_LINK,
'@p': Highlighter.FLAG_TYPE,
'@c': Highlighter.FLAG_NONE,
'@file': Highlighter.FLAG_LINK,
'@memberof': Highlighter.FLAG_TYPE,
'@extends': Highlighter.FLAG_TYPE,
'@mainpage': Highlighter.FLAG_STRING,
'@section': Highlighter.FLAG_BOLD,
'@subsection': Highlighter.FLAG_BOLD,
'@package': Highlighter.FLAG_TYPE,
'@ref': Highlighter.FLAG_LINK,
}
if b[0] == '@':
def qualifier(c):
if isinstance(c,int):
if c > 0: c = chr(c)
else: return False
return b.isalnum(c) or c in '_@'
if not b.findKeywords(doxygen_keywords_at, b.FLAG_ESCAPE, qualifier):
for keyword, flag in doxygen_word_commands.items():
if b.matchAndPaint(keyword, b.FLAG_ESCAPE, qualifier):
while b[0] == ' ': b.skip()
while b[0] and b[0] != ' ': b.paint(1, flag)
return True
b.paint(1, defaultflag)
return True
return False
def doxygen_qualifier(c):
if isinstance(c,int):
if c > 0: c = chr(c)
else: return False
return Highlighter.isalnum(c) or c in '_@'
def tryDoxygenComment(b,defaultflag=b.FLAG_COMMENT):
if b[0] == '@':
if not b.findKeywords(doxygen_keywords_at, b.FLAG_ESCAPE, doxygen_qualifier):
for keyword, flag in doxygen_word_commands.items():
if b.matchAndPaint(keyword, b.FLAG_ESCAPE, doxygen_qualifier):
while b[0] == ' ': b.skip()
while b[0] and b[0] != ' ': b.paint(1, flag)
return True
b.paint(1, defaultflag)
return True
return False
return tryDoxygenComment
let tryDoxygenComment = _make_dox()

View File

@ -12,7 +12,7 @@ class JavascriptHighlighter(Highlighter):
"if","implements","import","in","instanceof","interface","let","long",
"native","new","package","private","protected","public","return",
"static","super","switch","synchronized","this","throw","throws",
"transienttrue","try","typeof","volatile","while","with","yield",
"transient","true","try","typeof","volatile","while","with","yield",
]
types = [
"int","float","double","short","var","void","byte","char","boolean",

View File

@ -22,7 +22,7 @@ class KrkHighlighter(Highlighter):
'object','exception','isinstance','type','print','tuple','bool','any','all',
'hex','ord','chr','bytes','set','getattr','setattr','input','zip','enumerate',
'property','staticmethod','classmethod','filter','min','max','id','map','bin',
'sum','sorted',
'sum','sorted','issubclass','hasattr','delattr',
]
special = [
@ -79,6 +79,12 @@ class KrkHighlighter(Highlighter):
else if self[0] == strType and not isTriple:
self.paint(-1, self.FLAG_ERROR)
return None
else if self.findKeywords(self.keywords, self.FLAG_ESCAPE, self.cKeywordQualifier):
continue
else if self[-1] != '.' and self.findKeywords(self.types, self.FLAG_TYPE, self.cKeywordQualifier):
continue
else if self.findKeywords(self.exceptions, self.FLAG_PRAGMA, self.cKeywordQualifier):
continue
self.paint(1, self.FLAG_NUMERAL)
else if self.doxygenDocstrings and isTriple and tryDoxygenComment(self, self.FLAG_STRING):
continue

View File

@ -102,6 +102,7 @@ class GnumakeHighlighter(Highlighter):
break
else if self[i] == '=':
whatisit = 2
break
else if self[i] == '#':
break
if not whatisit:

2
kuroko

@ -1 +1 @@
Subproject commit 1ec1e59c5d621d4cbee8e33ff0d10ee6cef2a356
Subproject commit ed5d03b001a6d3b1154999312c233700af0d3e16