mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Added english atom syntax highlighting
This commit is contained in:
parent
0ba61d9a0d
commit
bd9401c034
8
Makefile
8
Makefile
@ -42,10 +42,16 @@ $(PYGMENTIZE_EN): $(PYGMENTS_DIR_EN)/set_up_pygments.sh $(PYGMENTS_DIR_EN)/catal
|
||||
|
||||
pygments: $(PYGMENTIZE_FR) $(PYGMENTIZE_EN)
|
||||
|
||||
atom: ${CURDIR}/syntax_highlighting/fr/atom/setup_atom.sh
|
||||
atom_fr: ${CURDIR}/syntax_highlighting/fr/atom/setup_atom.sh
|
||||
chmod +x $<
|
||||
$<
|
||||
|
||||
atom_en: ${CURDIR}/syntax_highlighting/en/atom/setup_atom.sh
|
||||
chmod +x $<
|
||||
$<
|
||||
|
||||
atom: atom_fr atom_en
|
||||
|
||||
# Examples-related rule
|
||||
|
||||
EXAMPLES_DIR=examples
|
||||
|
198
syntax_highlighting/en/atom/grammars/catala_en.cson
Normal file
198
syntax_highlighting/en/atom/grammars/catala_en.cson
Normal file
@ -0,0 +1,198 @@
|
||||
'fileTypes' : [
|
||||
'catala'
|
||||
]
|
||||
'name' : 'catala_en'
|
||||
'patterns' : [
|
||||
{
|
||||
'include' : '#main'
|
||||
}
|
||||
]
|
||||
'scopeName' : 'source.catala_en'
|
||||
'uuid' : ''
|
||||
'repository' : {
|
||||
'main' : {
|
||||
'patterns' : [
|
||||
{
|
||||
'begin' : '(@@)'
|
||||
'beginCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.heading.title.catala_en'
|
||||
}
|
||||
}
|
||||
'patterns' : [
|
||||
{
|
||||
'include' : '#main__1'
|
||||
}
|
||||
]
|
||||
'end' : '(@@[\\+]*)'
|
||||
'endCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.heading.title.catala_en'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'begin' : '(@)'
|
||||
'beginCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.heading.subtitle.catala_en'
|
||||
}
|
||||
}
|
||||
'patterns' : [
|
||||
{
|
||||
'include' : '#main__2'
|
||||
}
|
||||
]
|
||||
'end' : '(@)'
|
||||
'endCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'markup.heading.subtitle.catala_en'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'match' : '([^\\/])'
|
||||
'name' : 'entity.law.catala_en'
|
||||
}
|
||||
{
|
||||
'begin' : '(\\/\\*)'
|
||||
'beginCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'comment.block.documentation.catala_en'
|
||||
}
|
||||
}
|
||||
'patterns' : [
|
||||
{
|
||||
'include' : '#code'
|
||||
}
|
||||
]
|
||||
'end' : '(\\*\\/)'
|
||||
'endCaptures' : {
|
||||
'1' : {
|
||||
'name' : 'comment.block.documentation.catala_en'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
'code' : {
|
||||
'patterns' : [
|
||||
{
|
||||
'match' : '(\\s*\\#.*$)'
|
||||
'name' : 'comment.line.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '(contexte)(\\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.other.catala_en'
|
||||
}
|
||||
'2' : {
|
||||
'name' : 'text.catala_en'
|
||||
}
|
||||
'3' : {
|
||||
'name' : 'entity.name.function.catala_en'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'match' : '(donnée|condition)(\\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.other.catala_en'
|
||||
}
|
||||
'2' : {
|
||||
'name' : 'text.catala_en'
|
||||
}
|
||||
'3' : {
|
||||
'name' : 'meta.variable_id.catala_en'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'match' : '\\b(match|with\\s+pattern|fixed|by|decreasing|increasing|varies|with|we\\s+have|in|such\\s+that|exists|for|all|of|if|then|else)\\b'
|
||||
'name' : 'keyword.control.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '\\b(application\\s+field|depends\\s+on|declaration|includes|collection|content|optional|structure|enumeration|context|rule|under condition|consequence|fulfilled|equals|assertion|definition)\\b'
|
||||
'name' : 'keyword.other.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '(\\|[0-9]+/[0-9]+/[0-9]+\\|)'
|
||||
'name' : 'constant.numeric.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '\\b(vrai|faux)\\b'
|
||||
'name' : 'constant.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '\\b([0-9]+(,[0.9]*|))\\b'
|
||||
'name' : 'constant.numeric.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))'
|
||||
'name' : 'punctuation.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\u24|%|year|month|day)'
|
||||
'name' : 'keyword.operator.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '\\b(integer|boolean|date|amount|text|decimal|number|sum|now)\\b'
|
||||
'name' : 'support.type.catala_en'
|
||||
}
|
||||
{
|
||||
'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_\\\']*)(\\.)([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'
|
||||
'captures' : {
|
||||
'1' : {
|
||||
'name' : 'entity.name.class.catala_en'
|
||||
}
|
||||
'2' : {
|
||||
'name' : 'punctuation.catala_en'
|
||||
}
|
||||
'3' : {
|
||||
'name' : 'entity.name.function.catala_en'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'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_\\\']*)(\\.)([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'
|
||||
'captures' : {
|
||||
'1' : {
|
||||
'name' : 'entity.name.function.catala_en'
|
||||
}
|
||||
'2' : {
|
||||
'name' : 'punctuation.catala_en'
|
||||
}
|
||||
'3' : {
|
||||
'name' : 'meta.variable_id.catala_en'
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
'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' : 'entity.name.function.catala_en'
|
||||
}
|
||||
{
|
||||
'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.catala_en'
|
||||
}
|
||||
]
|
||||
}
|
||||
'main__1' : {
|
||||
'patterns' : [
|
||||
{
|
||||
'match' : '(.)'
|
||||
'name' : 'markup.heading.title.catala_en'
|
||||
}
|
||||
]
|
||||
}
|
||||
'main__2' : {
|
||||
'patterns' : [
|
||||
{
|
||||
'match' : '(.)'
|
||||
'name' : 'markup.heading.subtitle.catala_en'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
17
syntax_highlighting/en/atom/package.json
Normal file
17
syntax_highlighting/en/atom/package.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "language-catala-en",
|
||||
"version": "1.0.0",
|
||||
"description": "English syntax highlighting for the Catala language",
|
||||
"engines": {
|
||||
"atom": "*"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://gitlab.inria.fr/verifisc/catala.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://gitlab.inria.fr/verifisc/catala/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"license": "Apache"
|
||||
}
|
3
syntax_highlighting/en/atom/setup_atom.sh
Executable file
3
syntax_highlighting/en/atom/setup_atom.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
ln -s -f $(dirname "$0") ~/.atom/packages/catala_en
|
279
syntax_highlighting/en/catala_en.iro
Normal file
279
syntax_highlighting/en/catala_en.iro
Normal file
@ -0,0 +1,279 @@
|
||||
# This file is part of the Catala compiler, a specification language for tax and social benefits
|
||||
# computation rules. Copyright (C) 2020 Inria, contributor: Denis Merigoux
|
||||
# <denis.merigoux@inria.fr>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
# in compliance with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
# or implied. See the License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
|
||||
name = catala_en
|
||||
file_extensions [] = catala;
|
||||
|
||||
################################################################
|
||||
## Styles
|
||||
################################################################
|
||||
|
||||
styles [] {
|
||||
|
||||
.comment : style {
|
||||
color = light_green
|
||||
italic = true
|
||||
textmate_scope = comment.line
|
||||
pygments_scope = Comment.Single
|
||||
}
|
||||
|
||||
.sc_id : style {
|
||||
textmate_scope = meta.variable_id
|
||||
pygments_scope = String
|
||||
color = violet_red
|
||||
}
|
||||
|
||||
.sc_id_def : style {
|
||||
textmate_scope = entity.name.function
|
||||
pygments_scope = Name.Variable
|
||||
color = orange
|
||||
}
|
||||
|
||||
|
||||
.cc_id : style {
|
||||
color = light_blue
|
||||
textmate_scope = entity.name.class
|
||||
pygments_scope = Name.Class
|
||||
}
|
||||
|
||||
|
||||
.law_title : style {
|
||||
color = yellow
|
||||
italic = false
|
||||
textmate_scope = markup.heading.title
|
||||
pygments_scope = Generic.Heading
|
||||
}
|
||||
|
||||
.law_subtitle : style {
|
||||
color = gold
|
||||
italic = true
|
||||
textmate_scope = markup.heading.subtitle
|
||||
pygments_scope = Generic.Heading
|
||||
}
|
||||
|
||||
.law : style {
|
||||
color = light_yellow
|
||||
italic = false
|
||||
textmate_scope = entity.law
|
||||
pygments_scope = String.Doc
|
||||
}
|
||||
|
||||
.code_delimiter : style {
|
||||
color = grey
|
||||
italic = false
|
||||
textmate_scope = comment.block.documentation
|
||||
pygments_scope = Comment.Special
|
||||
}
|
||||
|
||||
.primitive : style {
|
||||
color = purple
|
||||
textmate_scope = support.type
|
||||
pygments_scope = Keyword.Type
|
||||
}
|
||||
|
||||
.whitespace : style {
|
||||
textmate_scope = text
|
||||
pygments_scope = String
|
||||
}
|
||||
|
||||
.keyword_expression : style {
|
||||
color = pink
|
||||
textmate_scope = keyword.control
|
||||
pygments_scope = Keyword.Reserved
|
||||
}
|
||||
|
||||
.keyword_rule : style {
|
||||
color = cyan
|
||||
textmate_scope = keyword.other
|
||||
pygments_scope = Keyword.Declaration
|
||||
}
|
||||
|
||||
.punctuation : style {
|
||||
color = red_2
|
||||
ace_scope = punctuation
|
||||
textmate_scope = punctuation
|
||||
pygments_scope = Operator
|
||||
}
|
||||
|
||||
.literal : style {
|
||||
color = green
|
||||
textmate_scope = constant
|
||||
pygments_scope = Keyword.Constant
|
||||
}
|
||||
|
||||
.literal_numeric : style {
|
||||
color = violet
|
||||
textmate_scope = constant.numeric
|
||||
pygments_scope = Number.Integer
|
||||
}
|
||||
|
||||
|
||||
.operator : style {
|
||||
color = brown
|
||||
textmate_scope = keyword.operator
|
||||
pygments_scope = Operator
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#################################################
|
||||
## Parse contexts
|
||||
#################################################
|
||||
|
||||
__LOWER_CHARS \= a-zéèàâùîêœç
|
||||
|
||||
__UPPER_CHARS \= A-ZÉÈÀÂÙÎÊŒÇ
|
||||
|
||||
__SC_ID \= [$${__LOWER_CHARS}][$${__LOWER_CHARS}$${__UPPER_CHARS}0-9_\']*
|
||||
|
||||
__SC_ID_COMPOSED \= [$${__LOWER_CHARS}][$${__LOWER_CHARS}$${__UPPER_CHARS}0-9_\'\.]*
|
||||
|
||||
__CC_ID \= [$${__UPPER_CHARS}][$${__LOWER_CHARS}$${__UPPER_CHARS}0-9_\']*
|
||||
|
||||
contexts [] {
|
||||
|
||||
##############################################
|
||||
## Main Context - Entry point context
|
||||
##############################################
|
||||
|
||||
main : context {
|
||||
|
||||
: inline_push {
|
||||
regex \= (@@)
|
||||
styles [] = .law_title;
|
||||
: pop {
|
||||
regex \= (@@[\+]*)
|
||||
styles [] = .law_title;
|
||||
}
|
||||
: pattern {
|
||||
regex \= (.)
|
||||
styles [] = .law_title;
|
||||
}
|
||||
}
|
||||
|
||||
: inline_push {
|
||||
regex \= (@)
|
||||
styles [] = .law_subtitle;
|
||||
: pop {
|
||||
regex \= (@)
|
||||
styles [] = .law_subtitle;
|
||||
}
|
||||
: pattern {
|
||||
regex \= (.)
|
||||
styles [] = .law_subtitle;
|
||||
}
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= ([^\/])
|
||||
styles [] = .law;
|
||||
}
|
||||
|
||||
: push {
|
||||
regex \= (\/\*)
|
||||
styles [] = .code_delimiter;
|
||||
context [] = code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
code : context {
|
||||
|
||||
: pop {
|
||||
regex \= (\*\/)
|
||||
styles [] = .code_delimiter;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (\s*\#.*$)
|
||||
styles [] = .comment ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (contexte)(\s+)($${__SC_ID})
|
||||
styles [] = .keyword_rule, .whitespace, .sc_id_def;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (donnée|condition)(\s+)($${__SC_ID})
|
||||
styles [] = .keyword_rule, .whitespace, .sc_id;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(selon|sous\s+forme|fixé|par|décroissante|croissante|varie|avec|on\s+a|dans|tel\s+que|existe|pour|tout|de|si|alors|sinon)\b
|
||||
styles [] = .keyword_expression ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(champ\s+d'application|si\s+et\s+seulement\s+si|dépend\s+de|déclaration|inclus|collection|contenu|optionnel|structure|énumération|contexte|règle|sous condition|conséquence|rempli|égal\s+à|assertion|définition)\b
|
||||
styles [] = .keyword_rule ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (\|[0-9]+/[0-9]+/[0-9]+\|)
|
||||
styles [] = .literal_numeric ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(vrai|faux)\b
|
||||
styles [] = .literal ;
|
||||
}
|
||||
|
||||
|
||||
: pattern {
|
||||
regex \= \b([0-9]+(,[0.9]*|))\b
|
||||
styles [] = .literal_numeric ;
|
||||
}
|
||||
|
||||
|
||||
: pattern {
|
||||
regex \= (\-\-|\;|\.|\,|\:|\(|\))
|
||||
styles [] = .punctuation;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (\-\>|\+|\-|\*|/|\!|non|ou|et|=|>|<|\u20ac|%|an|mois|jour)
|
||||
styles [] = .operator;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(entier|booléen|date|montant|texte|décimal|décret|loi|nombre|somme|date_aujourd_hui)\b
|
||||
styles [] = .primitive;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b($${__CC_ID})(\.)($${__SC_ID})\b
|
||||
styles [] = .cc_id, .punctuation, .sc_id_def ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b($${__SC_ID})(\.)($${__SC_ID_COMPOSED})\b
|
||||
styles [] = .sc_id_def, .punctuation, .sc_id ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b($${__SC_ID})\b
|
||||
styles [] = .sc_id_def ;
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b($${__CC_ID})\b
|
||||
styles [] = .cc_id ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
ln -s -f ./ ~/.atom/packages/catala_fr
|
||||
ln -s -f $(dirname "$0") ~/.atom/packages/catala_fr
|
||||
|
Loading…
Reference in New Issue
Block a user