bim: sync with upstream

This commit is contained in:
K. Lange 2023-07-04 15:30:09 +09:00
parent 8e86b94748
commit ddf7a79707
5 changed files with 115 additions and 35 deletions

View File

@ -10938,7 +10938,7 @@ static KrkValue bim_krk_state_init(int argc, const KrkValue argv[], int hasKw) {
*state = ((struct SyntaxState*)AS_INSTANCE(argv[1]))->state;
return argv[0];
return NONE_VAL();
}
static KrkValue krk_bim_get_commands(int argc, const KrkValue argv[], int hasKw) {

View File

@ -0,0 +1,78 @@
from syntax import Highlighter, bind
from syntax.c import CHighlighter
class GraphqlHighlighter(Highlighter):
name = 'graphql'
extensions = ('.graphql','.gql',)
keywords = [
'repeatable','on','implements','extend',
'enum','scalar','type','union','input','interface','subscription',
'query','mutation','fragment','directive','schema',
]
constants = [
'true','false','null',
'__schema','__type','__typename',
]
primitives = [
]
def paintTriple():
while self[0]:
if self[0] == "'":
self.paint(1, self.FLAG_STRING)
if self[0] == "'" and self[1] == "'":
self.paint(2, self.FLAG_STRING)
return 0
else:
self.paint(1, self.FLAG_STRING)
return 2
def paintPyTriple(quote):
while self[0]:
if self[0] == quote:
self.paint(1, self.FLAG_STRING)
if self[0] == quote and self[1] == quote:
self.paint(2, self.FLAG_STRING)
return 0
else:
self.paint(1, self.FLAG_STRING)
return 1 if quote == '"' else 2
def calculate():
if self.state <= 0:
if self[0] == '#':
self.paintComment()
else if self[0] == '"':
if self[1] == '"' and self[2] == '"':
self.paint(3, self.FLAG_STRING)
return self.paintPyTriple('"')
self.paintSimpleString()
return 0
else if self[0] == "'":
self.paintSingleString()
return 0
else if self.findKeywords(self.keywords, self.FLAG_KEYWORD, self.cKeywordQualifier):
return 0
else if self.findKeywords(self.primitives, self.FLAG_TYPE, self.cKeywordQualifier):
return 0
else if self.findKeywords(self.constants, self.FLAG_NUMERAL, self.cKeywordQualifier):
return 0
else if not self.cKeywordQualifier(self[-1]) and self.isdigit(self[0]):
CHighlighter.paintCNumeral(self)
return 0
else if self[0] == '@':
self.paint(1, self.FLAG_TYPE)
while self.cKeywordQualifier(self[0]):
self.paint(1, self.FLAG_TYPE)
return 0
else if not self.cKeywordQualifier(self[-1]) and self[0] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
while self.cKeywordQualifier(self[0]):
self.paint(1, self.FLAG_TYPE)
return 0
else if self[0]:
self.skip()
return 0
return None
else if self.state == 1:
return self.paintPyTriple('"')
return None
bind(GraphqlHighlighter)

View File

@ -81,35 +81,31 @@ class JavaHighlighter(Highlighter):
return 1
def calculate():
if self.state <= 0:
while self[0] is not None:
if not self.cKeywordQualifier(self[-1]) and self.isdigit(self[0]):
CHighlighter.paintCNumeral(self)
return 0
else if self[0] == '/' and self[1] == '/':
self.paintComment()
else if self[0] == '/' and self[1] == '*':
if self.paintJavaComment() == 1: return 1
else if self.findKeywords(self.keywords, self.FLAG_KEYWORD, self.keywordQualifier):
return 0
pass
else if self.findKeywords(self.types, self.FLAG_TYPE, self.cKeywordQualifier):
return 0
pass
else if self.findKeywords(self.special, self.FLAG_NUMERAL, self.cKeywordQualifier):
return 0
pass
else if self[0] == '"':
self.paintSimpleString()
return 0
else if self[0] == "'":
CHighlighter.paintCChar(self)
return 0
else if self[0] == '@':
self.paint(1, self.FLAG_PRAGMA)
while self.cKeywordQualifier(self[0]): self.paint(1, self.FLAG_PRAGMA)
return 0
else if self[0]:
self.skip()
return 0
else if self.state == 1:
while self[0] is not None:
if self.paintJavaComment() == 1: return 1
return 0
return None
bind(JavaHighlighter)

View File

@ -14,7 +14,7 @@ class KrkHighlighter(Highlighter):
checkKrkCode = None
keywords = [
'and','class','def','else','export','for','if','in','import','let','not',
'and','class','def','else','for','if','in','import','let','not',
'or','return','while','try','except','raise','continue','break','as','from',
'elif', 'lambda', 'pass', 'with', 'is', 'del', 'assert', 'yield', 'finally',
'async', 'await',

View File

@ -74,7 +74,7 @@ class GnumakeHighlighter(Highlighter):
self.makeVar()
else:
self.paint(1, self.FLAG_STRING)
def variableOrComment(flag):
def variableOrComment(flag, next):
while self[0]:
if self[0] == '$':
self.makeVar()
@ -84,15 +84,21 @@ class GnumakeHighlighter(Highlighter):
self.paintString()
else if self[0] == '"':
self.paintString()
else if self[0] == '\\' and not self[1]:
return next
else:
self.paint(1, flag)
return 0
def calculate():
if self.state == 2:
return self.variableOrComment(self.FLAG_NUMERAL, 2)
else if self.state == 3:
return self.variableOrComment(self.FLAG_NONE, 3)
if self.i == 0 and self[0] == '\t':
self.skip()
if self[0] == '@':
self.paint(1, self.FLAG_KEYWORD)
self.variableOrComment(self.FLAG_NUMERAL)
return self.variableOrComment(self.FLAG_NUMERAL, 2)
else:
while self[0] == ' ': self.skip()
let whatisit
@ -112,7 +118,7 @@ class GnumakeHighlighter(Highlighter):
else if self.findKeywords(self.commands, self.FLAG_KEYWORD, self.commandQualifier):
continue
else if self[0] == '$':
self.variableOrComment(self.FLAG_NONE)
self.variableOrComment(self.FLAG_NONE, 3)
else:
self.skip()
else if whatisit == 1: # rule
@ -121,7 +127,7 @@ class GnumakeHighlighter(Highlighter):
self.paintComment()
else if self[0] == ':':
self.paint(1, self.FLAG_TYPE)
self.variableOrComment(self.FLAG_NONE)
self.variableOrComment(self.FLAG_NONE, 3)
else if self.findKeywords(self.targets, self.FLAG_KEYWORD, self.commandQualifier):
continue
else:
@ -132,7 +138,7 @@ class GnumakeHighlighter(Highlighter):
self.paint(1, self.FLAG_TYPE)
while self[0] and self[0] != '=':
self.skip()
self.variableOrComment(self.FLAG_NONE)
return self.variableOrComment(self.FLAG_NONE, 3)
return None
bind(GnumakeHighlighter)