bim: sync with upstream
This commit is contained in:
parent
8e86b94748
commit
ddf7a79707
@ -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;
|
*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) {
|
static KrkValue krk_bim_get_commands(int argc, const KrkValue argv[], int hasKw) {
|
||||||
|
78
base/usr/share/bim/syntax/graphql.krk
Normal file
78
base/usr/share/bim/syntax/graphql.krk
Normal 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)
|
||||||
|
|
@ -81,35 +81,31 @@ class JavaHighlighter(Highlighter):
|
|||||||
return 1
|
return 1
|
||||||
def calculate():
|
def calculate():
|
||||||
if self.state <= 0:
|
if self.state <= 0:
|
||||||
if not self.cKeywordQualifier(self[-1]) and self.isdigit(self[0]):
|
while self[0] is not None:
|
||||||
CHighlighter.paintCNumeral(self)
|
if not self.cKeywordQualifier(self[-1]) and self.isdigit(self[0]):
|
||||||
return 0
|
CHighlighter.paintCNumeral(self)
|
||||||
else if self[0] == '/' and self[1] == '/':
|
else if self[0] == '/' and self[1] == '/':
|
||||||
self.paintComment()
|
self.paintComment()
|
||||||
else if self[0] == '/' and self[1] == '*':
|
else if self[0] == '/' and self[1] == '*':
|
||||||
if self.paintJavaComment() == 1: return 1
|
if self.paintJavaComment() == 1: return 1
|
||||||
else if self.findKeywords(self.keywords, self.FLAG_KEYWORD, self.keywordQualifier):
|
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):
|
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):
|
else if self.findKeywords(self.special, self.FLAG_NUMERAL, self.cKeywordQualifier):
|
||||||
return 0
|
pass
|
||||||
else if self[0] == '"':
|
else if self[0] == '"':
|
||||||
self.paintSimpleString()
|
self.paintSimpleString()
|
||||||
return 0
|
else if self[0] == "'":
|
||||||
else if self[0] == "'":
|
CHighlighter.paintCChar(self)
|
||||||
CHighlighter.paintCChar(self)
|
else if self[0] == '@':
|
||||||
return 0
|
self.paint(1, self.FLAG_PRAGMA)
|
||||||
else if self[0] == '@':
|
while self.cKeywordQualifier(self[0]): self.paint(1, self.FLAG_PRAGMA)
|
||||||
self.paint(1, self.FLAG_PRAGMA)
|
else if self[0]:
|
||||||
while self.cKeywordQualifier(self[0]): self.paint(1, self.FLAG_PRAGMA)
|
self.skip()
|
||||||
return 0
|
|
||||||
else if self[0]:
|
|
||||||
self.skip()
|
|
||||||
return 0
|
|
||||||
else if self.state == 1:
|
else if self.state == 1:
|
||||||
if self.paintJavaComment() == 1: return 1
|
while self[0] is not None:
|
||||||
return 0
|
if self.paintJavaComment() == 1: return 1
|
||||||
return None
|
return None
|
||||||
|
|
||||||
bind(JavaHighlighter)
|
bind(JavaHighlighter)
|
||||||
|
@ -14,7 +14,7 @@ class KrkHighlighter(Highlighter):
|
|||||||
checkKrkCode = None
|
checkKrkCode = None
|
||||||
|
|
||||||
keywords = [
|
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',
|
'or','return','while','try','except','raise','continue','break','as','from',
|
||||||
'elif', 'lambda', 'pass', 'with', 'is', 'del', 'assert', 'yield', 'finally',
|
'elif', 'lambda', 'pass', 'with', 'is', 'del', 'assert', 'yield', 'finally',
|
||||||
'async', 'await',
|
'async', 'await',
|
||||||
|
@ -74,7 +74,7 @@ class GnumakeHighlighter(Highlighter):
|
|||||||
self.makeVar()
|
self.makeVar()
|
||||||
else:
|
else:
|
||||||
self.paint(1, self.FLAG_STRING)
|
self.paint(1, self.FLAG_STRING)
|
||||||
def variableOrComment(flag):
|
def variableOrComment(flag, next):
|
||||||
while self[0]:
|
while self[0]:
|
||||||
if self[0] == '$':
|
if self[0] == '$':
|
||||||
self.makeVar()
|
self.makeVar()
|
||||||
@ -84,15 +84,21 @@ class GnumakeHighlighter(Highlighter):
|
|||||||
self.paintString()
|
self.paintString()
|
||||||
else if self[0] == '"':
|
else if self[0] == '"':
|
||||||
self.paintString()
|
self.paintString()
|
||||||
|
else if self[0] == '\\' and not self[1]:
|
||||||
|
return next
|
||||||
else:
|
else:
|
||||||
self.paint(1, flag)
|
self.paint(1, flag)
|
||||||
return 0
|
return 0
|
||||||
def calculate():
|
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':
|
if self.i == 0 and self[0] == '\t':
|
||||||
self.skip()
|
self.skip()
|
||||||
if self[0] == '@':
|
if self[0] == '@':
|
||||||
self.paint(1, self.FLAG_KEYWORD)
|
self.paint(1, self.FLAG_KEYWORD)
|
||||||
self.variableOrComment(self.FLAG_NUMERAL)
|
return self.variableOrComment(self.FLAG_NUMERAL, 2)
|
||||||
else:
|
else:
|
||||||
while self[0] == ' ': self.skip()
|
while self[0] == ' ': self.skip()
|
||||||
let whatisit
|
let whatisit
|
||||||
@ -112,7 +118,7 @@ class GnumakeHighlighter(Highlighter):
|
|||||||
else if self.findKeywords(self.commands, self.FLAG_KEYWORD, self.commandQualifier):
|
else if self.findKeywords(self.commands, self.FLAG_KEYWORD, self.commandQualifier):
|
||||||
continue
|
continue
|
||||||
else if self[0] == '$':
|
else if self[0] == '$':
|
||||||
self.variableOrComment(self.FLAG_NONE)
|
self.variableOrComment(self.FLAG_NONE, 3)
|
||||||
else:
|
else:
|
||||||
self.skip()
|
self.skip()
|
||||||
else if whatisit == 1: # rule
|
else if whatisit == 1: # rule
|
||||||
@ -121,7 +127,7 @@ class GnumakeHighlighter(Highlighter):
|
|||||||
self.paintComment()
|
self.paintComment()
|
||||||
else if self[0] == ':':
|
else if self[0] == ':':
|
||||||
self.paint(1, self.FLAG_TYPE)
|
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):
|
else if self.findKeywords(self.targets, self.FLAG_KEYWORD, self.commandQualifier):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@ -132,7 +138,7 @@ class GnumakeHighlighter(Highlighter):
|
|||||||
self.paint(1, self.FLAG_TYPE)
|
self.paint(1, self.FLAG_TYPE)
|
||||||
while self[0] and self[0] != '=':
|
while self[0] and self[0] != '=':
|
||||||
self.skip()
|
self.skip()
|
||||||
self.variableOrComment(self.FLAG_NONE)
|
return self.variableOrComment(self.FLAG_NONE, 3)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
bind(GnumakeHighlighter)
|
bind(GnumakeHighlighter)
|
||||||
|
Loading…
Reference in New Issue
Block a user