Add more keywords to the stdlib highlighter

This commit is contained in:
K. Lange 2022-06-03 13:45:12 +09:00
parent 5a79f27b83
commit b4349303e9

View File

@ -22,19 +22,29 @@ let FLAG_ESCAPE = 13
let keywords = [
'and','class','def','else','export','for','if','in','import','let','not',
'or','return','while','try','except','raise','continue','break','as','from',
'elif', 'lambda', 'pass', 'with', 'is', 'del'
'elif', 'lambda', 'pass', 'with', 'is', 'del', 'assert', 'yield', 'finally',
'async', 'await',
]
let types = [
'self','super','len','str','int','float','dir','repr','list','dict','range',
'object','exception','isinstance','type','print','tuple','bool','any','all',
'hex','ord','chr'
'hex','ord','chr','bytes','set','getattr','setattr','input','zip','enumerate',
'property','staticmethod','classmethod','filter','min','max','id','map','bin',
'sum','sorted','issubclass','hasattr','delattr', 'NotImplemented', 'abs',
]
let special = [
'True', 'False', 'None'
]
let exceptions = [
'Exception', 'TypeError', 'ArgumentError', 'IndexError', 'KeyError',
'AttributeError', 'NameError', 'ImportError', 'IOError', 'ValueError',
'KeyboardInterrupt', 'ZeroDivisionError', 'NotImplementedError', 'SyntaxError',
'AssertionError',
]
def toTerminal(processed,colors=None):
if not colors:
colors = {
@ -233,6 +243,8 @@ class KurokoHighlighter(State):
return 0
else if self.findKeywords(special, FLAG_NUMERAL, self.cKeywordQualifier):
return 0
else if self.findKeywords(exceptions, FLAG_PRAGMA, self.cKeywordQualifier):
return 0
else if not self.cKeywordQualifier(self.lastchar()) and self.isdigit(self.charat()):
self.paintNumeral()
return 0