mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-09 11:37:35 +03:00
Better syntax highlighting
This commit is contained in:
parent
fed849201e
commit
785d2d2311
@ -18,7 +18,7 @@
|
||||
'begin' : '(@@)'
|
||||
'beginCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.lawspec'
|
||||
'name' : 'markup.heading.title.lawspec'
|
||||
}
|
||||
}
|
||||
'patterns' : [
|
||||
@ -29,7 +29,7 @@
|
||||
'end' : '(@@)'
|
||||
'endCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.lawspec'
|
||||
'name' : 'markup.heading.title.lawspec'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -37,7 +37,7 @@
|
||||
'begin' : '(@)'
|
||||
'beginCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.heading.lawspec'
|
||||
'name' : 'markup.heading.subtitle.lawspec'
|
||||
}
|
||||
}
|
||||
'patterns' : [
|
||||
@ -48,19 +48,19 @@
|
||||
'end' : '(@)'
|
||||
'endCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.heading.lawspec'
|
||||
'name' : 'markup.heading.subtitle.lawspec'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'match' : '([^\\/])'
|
||||
'name' : 'text.lawspec'
|
||||
'name' : 'entity.law.lawspec'
|
||||
}
|
||||
{
|
||||
'begin' : '(\\/\\*)'
|
||||
'beginCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.prompt.lawspec'
|
||||
'name' : 'comment.block.documentation.lawspec'
|
||||
}
|
||||
}
|
||||
'patterns' : [
|
||||
@ -71,7 +71,7 @@
|
||||
'end' : '(\\*\\/)'
|
||||
'endCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.prompt.lawspec'
|
||||
'name' : 'comment.block.documentation.lawspec'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,14 +81,32 @@
|
||||
'patterns' : [
|
||||
{
|
||||
'match' : '(\\s*\\#.*$)'
|
||||
'name' : 'comment.lawspec'
|
||||
'name' : 'comment.line.lawspec'
|
||||
}
|
||||
{
|
||||
'match' : '\\b(choix|situation|optionnel|donnée|source|de|type|règle|pour|tout|on|a|tel|que|existe|défini|comme|fonction|paramètres|renvoie|selon|sous\\s*|forme|assertion|varie|avec|décroissante|croissante|fixé|par|conséquence|condition)\\b'
|
||||
'match' : '(donnée|constante)(\\s+)([a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}][a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}A-Z\\x{00c9}\\x{00c8}\\x{00c0}\\x{00c2}\\x{00d9}\\x{00ce}\\x{00ca}\\x{0152}\\x{00c7}0-9_\\\']*)'
|
||||
'captures' : {
|
||||
'1' : {
|
||||
'name' : 'keyword.lawspec'
|
||||
}
|
||||
'2' : {
|
||||
'name' : 'text.lawspec'
|
||||
}
|
||||
'3' : {
|
||||
'name' : 'variable.lawspec'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'match' : '\\b(existe|selon|sous\\s+forme|fixé\\s+par|décroissante|croissante|varie\\s+avec|on\\s+a|tel\\s+que|pour\\s+tout)\\b'
|
||||
'name' : 'keyword.control.lawspec'
|
||||
}
|
||||
{
|
||||
'match' : '\\b(choix|situation|donnée|optionnel|source|de|type|règle|défini|comme|fonction|paramètres|renvoie|assertion|conséquence|condition|collection|constante)\\b'
|
||||
'name' : 'keyword.lawspec'
|
||||
}
|
||||
{
|
||||
'match' : '(\\-\\-|;|\\.|:|\\(|\\))'
|
||||
'match' : '(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))'
|
||||
'name' : 'punctuation.lawspec'
|
||||
}
|
||||
{
|
||||
@ -96,15 +114,15 @@
|
||||
'name' : 'keyword.operator.lawspec'
|
||||
}
|
||||
{
|
||||
'match' : '\\b(entier|booléen|date|montant)\\b'
|
||||
'name' : 'entity.name.type.lawspec'
|
||||
'match' : '\\b(entier|booléen|date|montant|décret|loi|an|mois|jour)\\b'
|
||||
'name' : 'support.type.lawspec'
|
||||
}
|
||||
{
|
||||
'match' : '\\b([a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}][a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}A-Z\\x{00c9}\\x{00c8}\\x{00c0}\\x{00c2}\\x{00d9}\\x{00ce}\\x{00ca}\\x{0152}\\x{00c7}0-9_]*)\\b'
|
||||
'name' : 'variable.lawspec'
|
||||
'match' : '\\b([a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}][a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}A-Z\\x{00c9}\\x{00c8}\\x{00c0}\\x{00c2}\\x{00d9}\\x{00ce}\\x{00ca}\\x{0152}\\x{00c7}0-9_\\\']*)\\b'
|
||||
'name' : 'meta.variable_id.lawspec'
|
||||
}
|
||||
{
|
||||
'match' : '\\b([A-Z\\x{00c9}\\x{00c8}\\x{00c0}\\x{00c2}\\x{00d9}\\x{00ce}\\x{00ca}\\x{0152}\\x{00c7}][a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}A-Z\\x{00c9}\\x{00c8}\\x{00c0}\\x{00c2}\\x{00d9}\\x{00ce}\\x{00ca}\\x{0152}\\x{00c7}0-9_]*)\\b'
|
||||
'match' : '\\b([A-Z\\x{00c9}\\x{00c8}\\x{00c0}\\x{00c2}\\x{00d9}\\x{00ce}\\x{00ca}\\x{0152}\\x{00c7}][a-z\\x{00e9}\\x{00e8}\\x{00e0}\\x{00e2}\\x{00f9}\\x{00ee}\\x{00ea}\\x{0153}\\x{00e7}A-Z\\x{00c9}\\x{00c8}\\x{00c0}\\x{00c2}\\x{00d9}\\x{00ce}\\x{00ca}\\x{0152}\\x{00c7}0-9_\\\']*)\\b'
|
||||
'name' : 'entity.name.class.lawspec'
|
||||
}
|
||||
]
|
||||
@ -113,7 +131,7 @@
|
||||
'patterns' : [
|
||||
{
|
||||
'match' : '(.)'
|
||||
'name' : 'markup.lawspec'
|
||||
'name' : 'markup.heading.title.lawspec'
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -121,7 +139,7 @@
|
||||
'patterns' : [
|
||||
{
|
||||
'match' : '(.)'
|
||||
'name' : 'markup.heading.lawspec'
|
||||
'name' : 'markup.heading.subtitle.lawspec'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -10,12 +10,17 @@ styles [] {
|
||||
.comment : style {
|
||||
color = light_green
|
||||
italic = true
|
||||
ace_scope = comment
|
||||
textmate_scope = comment
|
||||
pygments_scope = Comment
|
||||
textmate_scope = comment.line
|
||||
pygments_scope = Comment.Single
|
||||
}
|
||||
|
||||
.sc_id : style {
|
||||
textmate_scope = meta.variable_id
|
||||
pygments_scope = String
|
||||
}
|
||||
|
||||
.var_decl : style {
|
||||
color = orange
|
||||
textmate_scope = variable
|
||||
pygments_scope = Name.Variable
|
||||
}
|
||||
@ -30,49 +35,61 @@ styles [] {
|
||||
.law_title : style {
|
||||
color = yellow
|
||||
italic = false
|
||||
textmate_scope = markup
|
||||
pygments_scope = Generic
|
||||
textmate_scope = markup.heading.title
|
||||
pygments_scope = Generic.Heading
|
||||
}
|
||||
|
||||
.law_subtitle : style {
|
||||
color = gold
|
||||
italic = true
|
||||
textmate_scope = markup.heading
|
||||
textmate_scope = markup.heading.subtitle
|
||||
pygments_scope = Generic.Heading
|
||||
}
|
||||
|
||||
.law : style {
|
||||
color = light_yellow
|
||||
italic = false
|
||||
textmate_scope = text
|
||||
textmate_scope = entity.law
|
||||
pygments_scope = String.Doc
|
||||
}
|
||||
|
||||
.code_delimiter : style {
|
||||
color = grey
|
||||
italic = false
|
||||
textmate_scope = markup.prompt
|
||||
pygments_scope = Generic.Prompt
|
||||
textmate_scope = comment.block.documentation
|
||||
pygments_scope = Comment.Special
|
||||
}
|
||||
|
||||
.primitive : style {
|
||||
color = purple
|
||||
textmate_scope = entity.name.type
|
||||
textmate_scope = support.type
|
||||
pygments_scope = Keyword.Type
|
||||
}
|
||||
|
||||
.keyword : style {
|
||||
.whitespace : style {
|
||||
textmate_scope = text
|
||||
pygments_scope = String
|
||||
}
|
||||
|
||||
.keyword_expression : style {
|
||||
color = pink
|
||||
ace_scope = keyword
|
||||
textmate_scope = keyword.control
|
||||
pygments_scope = Keyword
|
||||
}
|
||||
|
||||
.keyword_rule : style {
|
||||
color = cyan
|
||||
ace_scope = keyword
|
||||
textmate_scope = keyword
|
||||
pygments_scope = Keyword
|
||||
pygments_scope = Keyword.Declaration
|
||||
}
|
||||
|
||||
.punctuation : style {
|
||||
color = red_2
|
||||
ace_scope = punctuation
|
||||
textmate_scope = punctuation
|
||||
pygments_scope = Punctuation
|
||||
pygments_scope = Operator
|
||||
}
|
||||
|
||||
.operator : style {
|
||||
@ -91,9 +108,9 @@ __LOWER_CHARS \= a-zéèàâùîêœç
|
||||
|
||||
__UPPER_CHARS \= A-ZÉÈÀÂÙÎÊŒÇ
|
||||
|
||||
__SC_ID \= [$${__LOWER_CHARS}][$${__LOWER_CHARS}$${__UPPER_CHARS}0-9_]*
|
||||
__SC_ID \= [$${__LOWER_CHARS}][$${__LOWER_CHARS}$${__UPPER_CHARS}0-9_\']*
|
||||
|
||||
__CC_ID \= [$${__UPPER_CHARS}][$${__LOWER_CHARS}$${__UPPER_CHARS}0-9_]*
|
||||
__CC_ID \= [$${__UPPER_CHARS}][$${__LOWER_CHARS}$${__UPPER_CHARS}0-9_\']*
|
||||
|
||||
contexts [] {
|
||||
|
||||
@ -155,12 +172,22 @@ code : context {
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(choix|situation|donnée|optionnel|source|de|type|règle|pour|tout|on|a|tel|que|existe|défini|comme|fonction|paramètres|renvoie|selon|sous\s*|forme|assertion|varie|avec|décroissante|croissante|fixé|par|conséquence|condition)\b
|
||||
styles [] = .keyword ;
|
||||
regex \= (donnée|constante)(\s+)($${__SC_ID})
|
||||
styles [] = .keyword_rule, .whitespace, .var_decl;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (\-\-|;|\.|:|\(|\))
|
||||
regex \= \b(existe|selon|sous\s+forme|fixé\s+par|décroissante|croissante|varie\s+avec|on\s+a|tel\s+que|pour\s+tout)\b
|
||||
styles [] = .keyword_expression ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(choix|situation|donnée|optionnel|source|de|type|règle|défini|comme|fonction|paramètres|renvoie|assertion|conséquence|condition|collection|constante)\b
|
||||
styles [] = .keyword_rule ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (\-\-|\;|\.|\,|\:|\(|\))
|
||||
styles [] = .punctuation;
|
||||
}
|
||||
|
||||
@ -170,7 +197,7 @@ code : context {
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(entier|booléen|date|montant)\b
|
||||
regex \= \b(entier|booléen|date|montant|décret|loi|an|mois|jour)\b
|
||||
styles [] = .primitive;
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,15 @@ class LawspecLexer(RegexLexer):
|
||||
# ],
|
||||
# 'main__3' : [
|
||||
# (u'(\\*\\/)', bygroups(Generic.Prompt), '#pop'),
|
||||
(u'(\\s*\\#.*$)', bygroups(Comment)),
|
||||
(u'\\b(choix|situation|donn\xe9e|optionnel|source|de|type|r\xe8gle|pour|tout|on|a|tel|que|existe|d\xe9fini|comme|fonction|param\xe8tres|renvoie|selon|sous\\s*|forme|assertion|varie|avec|d\xe9croissante|croissante|fix\xe9|par|cons\xe9quence|condition)\\b', bygroups(Keyword)),
|
||||
(u'(\\-\\-|;|\\.|:|\\(|\\))', bygroups(Punctuation)),
|
||||
(u'(\\s*\\#.*$)', bygroups(Comment.Single)),
|
||||
(u'(donn\xe9e|constante)(\\s+)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)', bygroups(Keyword.Declaration, String, Name.Variable)),
|
||||
(u'\\b(existe|selon|sous\\s+forme|fix\xe9\\s+par|d\xe9croissante|croissante|varie\\s+avec|on\\s+a|tel\\s+que|pour\\s+tout)\\b', bygroups(Keyword)),
|
||||
(u'\\b(choix|situation|donn\xe9e|optionnel|source|de|type|r\xe8gle|d\xe9fini|comme|fonction|param\xe8tres|renvoie|assertion|cons\xe9quence|condition|collection|constante)\\b', bygroups(Keyword.Declaration)),
|
||||
(u'(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))', bygroups(Operator)),
|
||||
(u'(\\+|\\-|\\*|/|\\!|ou|et|=|>|<)', bygroups(Operator)),
|
||||
(u'\\b(entier|bool\xe9en|date|montant)\\b', bygroups(Keyword.Type)),
|
||||
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_]*)\\b', bygroups(Name.Variable)),
|
||||
(u'\\b([A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_]*)\\b', bygroups(Name.Class)),
|
||||
(u'\\b(entier|bool\xe9en|date|montant|d\xe9cret|loi|an|mois|jour)\\b', bygroups(Keyword.Type)),
|
||||
(u'\\b([a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Text)),
|
||||
(u'\\b([A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xca\u0152\xc70-9_\\\']*)\\b', bygroups(Name.Class)),
|
||||
('(\n|\r|\r\n)', String),
|
||||
('.', String),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user