# 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 # # # 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_fr file_extensions [] = catala_fr; ################################################################ ## 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 } .code_delimiter : style { color = grey italic = false textmate_scope = comment.block.documentation pygments_scope = String } .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 \= \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\s+condition|condition|donnée|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 ; } } }