amount -> money

This commit is contained in:
Denis Merigoux 2020-12-10 09:27:51 +01:00
parent 159901b993
commit a4916208ba
34 changed files with 148 additions and 112 deletions

View File

@ -87,7 +87,7 @@ While all the code sections are equivalent in terms of execution, you can mark s
/* /*
declaration structure FooBar: declaration structure FooBar:
data foo content boolean data foo content boolean
data bar content amount data bar content money
<your structure/enumeration/scope declarations goes here> <your structure/enumeration/scope declarations goes here>
*/ */

View File

@ -157,7 +157,7 @@ Current proposal : "amount".
The base data type for representing amounts of money. The base data type for representing amounts of money.
``` ```
data foo content amount data foo content money
``` ```
## TEXT ## TEXT

View File

@ -17,7 +17,7 @@ déclaration énumération PriseEnCharge :
déclaration structure Enfant : déclaration structure Enfant :
donnée fin_obligation_scolaire contenu date donnée fin_obligation_scolaire contenu date
donnée âge contenu entier donnée âge contenu entier
donnée rémuneration_mensuelle contenu montant donnée rémuneration_mensuelle contenu argent
donnée prise_en_charge contenu PriseEnCharge donnée prise_en_charge contenu PriseEnCharge
condition confié_service_social condition confié_service_social
@ -99,8 +99,8 @@ déclaration énumération Prestation:
déclaration structure PrestationsFamiliales : déclaration structure PrestationsFamiliales :
condition conditions_hors_âge dépend de Enfant condition conditions_hors_âge dépend de Enfant
condition droits_ouverts dépend de Enfant condition droits_ouverts dépend de Enfant
donnée base_mensuelle contenu montant donnée base_mensuelle contenu argent
donnée base_mensuelle_dom contenu montant donnée base_mensuelle_dom contenu argent
déclaration énumération ChargeAllocation : déclaration énumération ChargeAllocation :
-- Complète -- Complète
@ -110,21 +110,21 @@ déclaration structure AllocationsFamiliales :
condition droits_ouverts condition droits_ouverts
donnée date_ouverture_droits contenu date donnée date_ouverture_droits contenu date
condition conditions_hors_âge dépend de Enfant condition conditions_hors_âge dépend de Enfant
donnée base contenu montant donnée base contenu argent
donnée avec_garde_alternée contenu montant donnée avec_garde_alternée contenu argent
donnée montant_versé contenu montant donnée montant_versé contenu argent
donnée récipiendaire_par_enfant contenu Personne dépend de Enfant donnée récipiendaire_par_enfant contenu Personne dépend de Enfant
donnée charge_par_enfant contenu ChargeAllocation dépend de Enfant donnée charge_par_enfant contenu ChargeAllocation dépend de Enfant
donnée rapport_enfants_total_moyen contenu décimal donnée rapport_enfants_total_moyen contenu décimal
donnée nombre_total_enfants contenu entier donnée nombre_total_enfants contenu entier
donnée nombre_moyen_enfants contenu décimal donnée nombre_moyen_enfants contenu décimal
donnée montant_premier_enfant contenu montant donnée montant_premier_enfant contenu argent
donnée montant_deuxieme_enfant contenu montant donnée montant_deuxieme_enfant contenu argent
donnée montant_troisième_enfant_et_plus contenu montant donnée montant_troisième_enfant_et_plus contenu argent
déclaration structure AllocationForfaitaire : déclaration structure AllocationForfaitaire :
condition droits_ouverts dépend de Enfant condition droits_ouverts dépend de Enfant
donnée montant_versé contenu montant donnée montant_versé contenu argent
déclaration énumération ChoixParentAllocataire : déclaration énumération ChoixParentAllocataire :
-- UnParent contenu Personne -- UnParent contenu Personne
@ -140,16 +140,16 @@ déclaration structure AllocationsGardeAlternée :
déclaration structure MajorationsAllocationsFamiliales : déclaration structure MajorationsAllocationsFamiliales :
condition droits_ouverts dépend de Enfant condition droits_ouverts dépend de Enfant
donnée base_par_enfant contenu montant dépend de Enfant donnée base_par_enfant contenu argent dépend de Enfant
donnée avec_garde_alternée contenu montant dépend de Enfant donnée avec_garde_alternée contenu argent dépend de Enfant
donnée montant_versé contenu montant donnée montant_versé contenu argent
déclaration structure ComplémentDégressif : déclaration structure ComplémentDégressif :
condition droits_ouverts dépend de montant condition droits_ouverts dépend de montant
donnée dépassement contenu montant dépend de montant donnée dépassement contenu argent dépend de montant
donnée pour_allocation_forfaitaire contenu montant donnée pour_allocation_forfaitaire contenu argent
donnée pour_allocations_familiales_et_majorations contenu montant donnée pour_allocations_familiales_et_majorations contenu argent
donnée montant_versé contenu montant donnée montant_versé contenu argent
déclaration structure TitreI: déclaration structure TitreI:
condition droits_ouverts_allocations_familiales dépend de Personne condition droits_ouverts_allocations_familiales dépend de Personne
@ -161,25 +161,25 @@ déclaration structure L512_3 :
donnée âge_limite_alinéa_2 contenu entier donnée âge_limite_alinéa_2 contenu entier
donnée âge_limite_alinéa_2_alternatif contenu entier donnée âge_limite_alinéa_2_alternatif contenu entier
condition âge_limite_alinéa_2_alternatif_utilisé condition âge_limite_alinéa_2_alternatif_utilisé
donnée plafond_rémunération_mensuelle_alinéa_2 contenu montant donnée plafond_rémunération_mensuelle_alinéa_2 contenu argent
déclaration structure L521_1 : déclaration structure L521_1 :
donnée nombre_minimum_enfants contenu montant donnée nombre_minimum_enfants contenu argent
donnée ressources_ménage contenu montant donnée ressources_ménage contenu argent
déclaration structure L521_3 : déclaration structure L521_3 :
donnée âge_limite_alinéa_1 contenu entier dépend de Enfant donnée âge_limite_alinéa_1 contenu entier dépend de Enfant
donnée minimum_alinéa_2 contenu montant donnée minimum_alinéa_2 contenu argent
déclaration structure L751_1 : déclaration structure L751_1 :
condition régime_outre_mer condition régime_outre_mer
déclaration structure D521_3 : déclaration structure D521_3 :
donnée plafond_I contenu montant donnée plafond_I contenu argent
donnée plafond_II contenu montant donnée plafond_II contenu argent
déclaration structure SMIC : déclaration structure SMIC :
donnée brut_horaire contenu montant dépend de Collectivité donnée brut_horaire contenu argent dépend de Collectivité
déclaration champ d'application CalculPrestationsFamiliales : déclaration champ d'application CalculPrestationsFamiliales :
# Les règles déclarées dans PrestationsFamiliales pourront utiliser # Les règles déclarées dans PrestationsFamiliales pourront utiliser

View File

@ -36,15 +36,15 @@ total dont sont retranchées les charges énumérées à l'article 156.
/* /*
déclaration structure RevenuNetGlobal: déclaration structure RevenuNetGlobal:
donnée revenus_fonciers contenu montant donnée revenus_fonciers contenu argent
donnée bénéfices_industriels_commerciaux contenu montant donnée bénéfices_industriels_commerciaux contenu argent
donnée rémunérations_dirigeants contenu montant donnée rémunérations_dirigeants contenu argent
donnée bénéfices_agricoles contenu montant donnée bénéfices_agricoles contenu argent
donnée traitements_salaires contenu montant donnée traitements_salaires contenu argent
donnée bénéfices_non_commerciaux contenu montant donnée bénéfices_non_commerciaux contenu argent
donnée revenus_capitaux_mobiliers contenu montant donnée revenus_capitaux_mobiliers contenu argent
donnée plus_values contenu montant donnée plus_values contenu argent
donnée total contenu montant donnée total contenu argent
déclaration champ d'application CalculImpotSurLeRevenu : déclaration champ d'application CalculImpotSurLeRevenu :
contexte revenu_net_global contenu RevenuNetGlobal contexte revenu_net_global contenu RevenuNetGlobal

View File

@ -46,11 +46,11 @@ individual and the income tax computation:
@@Begin metadata@@ @@Begin metadata@@
/* /*
declaration structure Individual: declaration structure Individual:
data income content amount data income content money
declaration structure Article1: declaration structure Article1:
data fixed_percentage content decimal data fixed_percentage content decimal
data income_tax content amount data income_tax content money
*/ */
@@End metadata@@ @@End metadata@@
@ -158,13 +158,13 @@ computation:
@@Begin metadata@@ @@Begin metadata@@
/* /*
declaration structure TwoBrackets: declaration structure TwoBrackets:
data breakpoint content amount data breakpoint content money
data rate1 content decimal data rate1 content decimal
data rate2 content decimal data rate2 content decimal
declaration scope TwoBracketsTaxComputation : declaration scope TwoBracketsTaxComputation :
context brackets content TwoBrackets context brackets content TwoBrackets
context tax_formula content amount depends on amount context tax_formula content money depends on amount
*/ */
@@End metadata@@ @@End metadata@@

View File

@ -13,23 +13,23 @@ declaration structure Acquisition:
data no_sale_or_exchange_before content boolean data no_sale_or_exchange_before content boolean
declaration structure Value: declaration structure Value:
data fair_market content amount depends on date data fair_market content money depends on date
data last_acquisition content amount data last_acquisition content money
data net_appreciation content amount data net_appreciation content money
declaration structure Transferor: declaration structure Transferor:
data basis content amount data basis content money
data basis_known content optional amount data basis_known content optional amount
data acquisition content Acquisition data acquisition content Acquisition
data gain_or_loss content amount depends on date data gain_or_loss content money depends on date
declaration scope BasisOfGift: declaration scope BasisOfGift:
context acquisition content Acquisition context acquisition content Acquisition
context basis_subsection_a content amount context basis_subsection_a content money
context basis content amount context basis content money
context basis_bonus_after_1976 content amount context basis_bonus_after_1976 content money
context transferor content Transferor context transferor content Transferor
context gift_tax_paid content amount context gift_tax_paid content money
*/ */
@@End metadata@@ @@End metadata@@

View File

@ -13,14 +13,14 @@ declaration structure Property:
declaration structure SaleOrExchange: declaration structure SaleOrExchange:
data property content Property data property content Property
data gain content amount data gain content money
data date_of_sale_or_exchange content date data date_of_sale_or_exchange content date
declaration scope Section121: declaration scope Section121:
context taxpayer content Person context taxpayer content Person
context applicable condition context applicable condition
context maximum_gain_excluded content amount context maximum_gain_excluded content money
context gain_considered_for_exclusion content amount context gain_considered_for_exclusion content money
context sale_or_exchange content SaleOrExchange context sale_or_exchange content SaleOrExchange
context included_in_gross_income condition context included_in_gross_income condition
context ownage_considered_for_gain_inclusion condition context ownage_considered_for_gain_inclusion condition

View File

@ -8,12 +8,12 @@ declaration enumeration DiscountType:
-- Services -- Services
declaration scope QualifiedEmployeeDiscount: declaration scope QualifiedEmployeeDiscount:
context customer_price content amount context customer_price content money
context employee_price content amount context employee_price content money
context gross_profit_percentage content decimal context gross_profit_percentage content decimal
context qualified_employee_discount content amount context qualified_employee_discount content money
context employee_discount content amount context employee_discount content money
context aggregate_cost content amount context aggregate_cost content money
context discount_type content DiscountType context discount_type content DiscountType
*/ */
@@End metadata@@ @@End metadata@@

View File

@ -65,7 +65,7 @@ let token_list : (string * token) list =
("set", COLLECTION); ("set", COLLECTION);
("enum", ENUM); ("enum", ENUM);
("int", INTEGER); ("int", INTEGER);
("amount", MONEY); ("money", MONEY);
("text", TEXT); ("text", TEXT);
("decimal", DECIMAL); ("decimal", DECIMAL);
("date", DATE); ("date", DATE);
@ -155,7 +155,7 @@ let rec lex_code (lexbuf : lexbuf) : token =
| "int" -> | "int" ->
update_acc lexbuf; update_acc lexbuf;
INTEGER INTEGER
| "amount" -> | "money" ->
update_acc lexbuf; update_acc lexbuf;
MONEY MONEY
| "text" -> | "text" ->

View File

@ -33,7 +33,7 @@ let token_list_en : (string * token) list =
("collection", COLLECTION); ("collection", COLLECTION);
("enumeration", ENUM); ("enumeration", ENUM);
("integer", INTEGER); ("integer", INTEGER);
("amount", MONEY); ("money", MONEY);
("text", TEXT); ("text", TEXT);
("decimal", DECIMAL); ("decimal", DECIMAL);
("date", DATE); ("date", DATE);
@ -123,7 +123,7 @@ let rec lex_code_en (lexbuf : lexbuf) : token =
| "integer" -> | "integer" ->
L.update_acc lexbuf; L.update_acc lexbuf;
INTEGER INTEGER
| "amount" -> | "money" ->
L.update_acc lexbuf; L.update_acc lexbuf;
MONEY MONEY
| "text" -> | "text" ->

View File

@ -33,7 +33,7 @@ let token_list_fr : (string * token) list =
("collection", COLLECTION); ("collection", COLLECTION);
("énumération", ENUM); ("énumération", ENUM);
("entier", INTEGER); ("entier", INTEGER);
("montant", MONEY); ("argent", MONEY);
("texte", TEXT); ("texte", TEXT);
("decimal", DECIMAL); ("decimal", DECIMAL);
("date", DATE); ("date", DATE);
@ -124,7 +124,7 @@ let rec lex_code_fr (lexbuf : lexbuf) : token =
| "entier" -> | "entier" ->
L.update_acc lexbuf; L.update_acc lexbuf;
INTEGER INTEGER
| "montant" -> | "argent" ->
L.update_acc lexbuf; L.update_acc lexbuf;
MONEY MONEY
| "texte" -> | "texte" ->

View File

@ -25,9 +25,9 @@ let rec format_typ (fmt : Format.formatter) (typ : typ Pos.marked) : unit =
in in
match Pos.unmark typ with match Pos.unmark typ with
| TLit TUnit -> Format.fprintf fmt "unit" | TLit TUnit -> Format.fprintf fmt "unit"
| TLit TBool -> Format.fprintf fmt "bool" | TLit TBool -> Format.fprintf fmt "boolean"
| TLit TInt -> Format.fprintf fmt "int" | TLit TInt -> Format.fprintf fmt "integer"
| TLit TRat -> Format.fprintf fmt "dec" | TLit TRat -> Format.fprintf fmt "decimal"
| TLit TMoney -> Format.fprintf fmt "money" | TLit TMoney -> Format.fprintf fmt "money"
| TTuple ts -> | TTuple ts ->
Format.fprintf fmt "(%a)" Format.fprintf fmt "(%a)"

View File

@ -38,9 +38,9 @@ let rec format_typ (fmt : Format.formatter) (typ : typ Pos.marked) : unit =
in in
match Pos.unmark typ with match Pos.unmark typ with
| TLit TUnit -> Format.fprintf fmt "unit" | TLit TUnit -> Format.fprintf fmt "unit"
| TLit TBool -> Format.fprintf fmt "bool" | TLit TBool -> Format.fprintf fmt "boolean"
| TLit TInt -> Format.fprintf fmt "int" | TLit TInt -> Format.fprintf fmt "integer"
| TLit TRat -> Format.fprintf fmt "dec" | TLit TRat -> Format.fprintf fmt "decimal"
| TLit TMoney -> Format.fprintf fmt "money" | TLit TMoney -> Format.fprintf fmt "money"
| TStruct s -> Format.fprintf fmt "%a" Ast.StructName.format_t s | TStruct s -> Format.fprintf fmt "%a" Ast.StructName.format_t s
| TEnum e -> Format.fprintf fmt "%a" Ast.EnumName.format_t e | TEnum e -> Format.fprintf fmt "%a" Ast.EnumName.format_t e

View File

@ -120,11 +120,11 @@
'name' : 'punctuation.catala_en' 'name' : 'punctuation.catala_en'
} }
{ {
'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)' 'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\$|%|year|month|day)'
'name' : 'keyword.operator.catala_en' 'name' : 'keyword.operator.catala_en'
} }
{ {
'match' : '\\b(integer|boolean|date|amount|text|decimal|number|sum|now)\\b' 'match' : '\\b(integer|boolean|date|money|text|decimal|number|sum|now)\\b'
'name' : 'support.type.catala_en' 'name' : 'support.type.catala_en'
} }
{ {

View File

@ -240,12 +240,12 @@ code : context {
} }
: pattern { : pattern {
regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\\$|%|year|month|day) regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\$|%|year|month|day)
styles [] = .operator; styles [] = .operator;
} }
: pattern { : pattern {
regex \= \b(integer|boolean|date|amount|text|decimal|number|sum|now)\b regex \= \b(integer|boolean|date|money|text|decimal|number|sum|now)\b
styles [] = .primitive; styles [] = .primitive;
} }

View File

@ -3,7 +3,8 @@ from pygments.token import *
import re import re
__all__=['CatalaEnLexer'] __all__ = ['CatalaEnLexer']
class CatalaEnLexer(RegexLexer): class CatalaEnLexer(RegexLexer):
name = 'CatalaEn' name = 'CatalaEn'
@ -12,7 +13,7 @@ class CatalaEnLexer(RegexLexer):
flags = re.MULTILINE | re.UNICODE flags = re.MULTILINE | re.UNICODE
tokens = { tokens = {
'root' : [ 'root': [
(u'(@@)', bygroups(Generic.Heading), 'main__1'), (u'(@@)', bygroups(Generic.Heading), 'main__1'),
(u'(@)', bygroups(Generic.Heading), 'main__2'), (u'(@)', bygroups(Generic.Heading), 'main__2'),
(u'([^\\/\\n\\r])', bygroups(Text)), (u'([^\\/\\n\\r])', bygroups(Text)),
@ -20,18 +21,21 @@ class CatalaEnLexer(RegexLexer):
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),
('.', Text), ('.', Text),
], ],
'code' : [ 'code': [
(u'(\\*\\/)', bygroups(Text), 'root'), (u'(\\*\\/)', bygroups(Text), 'root'),
(u'(\\s*\\#.*$)', bygroups(Comment.Single)), (u'(\\s*\\#.*$)', bygroups(Comment.Single)),
(u'(context)(\\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, Text, Name.Variable)), (u'(context)(\\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, Text, Name.Variable)),
(u'\\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', bygroups(Keyword.Reserved)), (u'\\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', bygroups(Keyword.Reserved)),
(u'\\b(scope|depends\\s+on|declaration|includes|collection|content|optional|structure|enumeration|context|rule|under\\s+condition|condition|data|consequence|fulfilled|equals|assertion|definition)\\b', bygroups(Keyword.Declaration)), (u'\\b(scope|depends\\s+on|declaration|includes|collection|content|optional|structure|enumeration|context|rule|under\\s+condition|condition|data|consequence|fulfilled|equals|assertion|definition)\\b', bygroups(Keyword.Declaration)),
(u'(\\|[0-9]+/[0-9]+/[0-9]+\\|)', bygroups(Number.Integer)), (u'(\\|[0-9]+/[0-9]+/[0-9]+\\|)', bygroups(Number.Integer)),
(u'\\b(true|false)\\b', bygroups(Keyword.Constant)), (u'\\b(true|false)\\b', bygroups(Keyword.Constant)),
(u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)), (u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)),
(u'(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))', bygroups(Operator)), (u'(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))', bygroups(Operator)),
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)', bygroups(Operator)), (u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\$|%|year|month|day)',
(u'\\b(integer|boolean|date|amount|text|decimal|number|sum|now)\\b', bygroups(Keyword.Type)), bygroups(Operator)),
(u'\\b(integer|boolean|date|money|text|decimal|number|sum|now)\\b',
bygroups(Keyword.Type)),
(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_\\\']*)(\\.)([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.Class, Operator, 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_\\\']*)(\\.)([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.Class, Operator, Name.Variable)),
(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_\\\']*)(\\.)([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, Operator, Text)), (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_\\\']*)(\\.)([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, Operator, Text)),
(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\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)),
@ -39,13 +43,13 @@ class CatalaEnLexer(RegexLexer):
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),
('.', Text), ('.', Text),
], ],
'main__1' : [ 'main__1': [
(u'(@@)', bygroups(Generic.Heading), 'root'), (u'(@@)', bygroups(Generic.Heading), 'root'),
(u'(.)', bygroups(Generic.Heading)), (u'(.)', bygroups(Generic.Heading)),
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),
('.', Text), ('.', Text),
], ],
'main__2' : [ 'main__2': [
(u'(@)', bygroups(Generic.Heading), 'root'), (u'(@)', bygroups(Generic.Heading), 'root'),
(u'(.)', bygroups(Generic.Heading)), (u'(.)', bygroups(Generic.Heading)),
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),

View File

@ -191,13 +191,13 @@
</dict> </dict>
<dict> <dict>
<key>match</key> <key>match</key>
<string>(\-\&gt;|\+|\-|\*|/|\!|not|or|and|=|&gt;|&lt;|\\$|%|year|month|day)</string> <string>(\-\&gt;|\+|\-|\*|/|\!|not|or|and|=|&gt;|&lt;|\$|%|year|month|day)</string>
<key>name</key> <key>name</key>
<string>keyword.operator.catala_en</string> <string>keyword.operator.catala_en</string>
</dict> </dict>
<dict> <dict>
<key>match</key> <key>match</key>
<string>\b(integer|boolean|date|amount|text|decimal|number|sum|now)\b</string> <string>\b(integer|boolean|date|money|text|decimal|number|sum|now)\b</string>
<key>name</key> <key>name</key>
<string>support.type.catala_en</string> <string>support.type.catala_en</string>
</dict> </dict>

View File

@ -124,7 +124,7 @@
'name' : 'keyword.operator.catala_fr' 'name' : 'keyword.operator.catala_fr'
} }
{ {
'match' : '\\b(entier|booléen|date|montant|texte|décimal|décret|loi|nombre|somme|date_aujourd_hui)\\b' 'match' : '\\b(entier|booléen|date|argent|texte|décimal|décret|loi|nombre|somme|date_aujourd_hui)\\b'
'name' : 'support.type.catala_fr' 'name' : 'support.type.catala_fr'
} }
{ {

View File

@ -245,7 +245,7 @@ code : context {
} }
: pattern { : pattern {
regex \= \b(entier|booléen|date|montant|texte|décimal|décret|loi|nombre|somme|date_aujourd_hui)\b regex \= \b(entier|booléen|date|argent|texte|décimal|décret|loi|nombre|somme|date_aujourd_hui)\b
styles [] = .primitive; styles [] = .primitive;
} }

View File

@ -3,7 +3,8 @@ from pygments.token import *
import re import re
__all__=['CatalaFrLexer'] __all__ = ['CatalaFrLexer']
class CatalaFrLexer(RegexLexer): class CatalaFrLexer(RegexLexer):
name = 'CatalaFr' name = 'CatalaFr'
@ -12,7 +13,7 @@ class CatalaFrLexer(RegexLexer):
flags = re.MULTILINE | re.UNICODE flags = re.MULTILINE | re.UNICODE
tokens = { tokens = {
'root' : [ 'root': [
(u'(@@)', bygroups(Generic.Heading), 'main__1'), (u'(@@)', bygroups(Generic.Heading), 'main__1'),
(u'(@)', bygroups(Generic.Heading), 'main__2'), (u'(@)', bygroups(Generic.Heading), 'main__2'),
(u'([^\\/\\n\\r])', bygroups(Text)), (u'([^\\/\\n\\r])', bygroups(Text)),
@ -20,18 +21,21 @@ class CatalaFrLexer(RegexLexer):
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),
('.', Text), ('.', Text),
], ],
'code' : [ 'code': [
(u'(\\*\\/)', bygroups(Text), 'root'), (u'(\\*\\/)', bygroups(Text), 'root'),
(u'(\\s*\\#.*$)', bygroups(Comment.Single)), (u'(\\s*\\#.*$)', bygroups(Comment.Single)),
(u'(contexte)(\\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, Text, Name.Variable)), (u'(contexte)(\\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, Text, Name.Variable)),
(u'\\b(selon|sous\\s+forme|fix\xe9|par|d\xe9croissante|croissante|varie|avec|on\\s+a|dans|tel\\s+que|existe|pour|tout|de|si|alors|sinon)\\b', bygroups(Keyword.Reserved)), (u'\\b(selon|sous\\s+forme|fix\xe9|par|d\xe9croissante|croissante|varie|avec|on\\s+a|dans|tel\\s+que|existe|pour|tout|de|si|alors|sinon)\\b', bygroups(Keyword.Reserved)),
(u'\\b(champ\\s+d\'application|si\\s+et\\s+seulement\\s+si|d\xe9pend\\s+de|d\xe9claration|inclus|collection|contenu|optionnel|structure|\xe9num\xe9ration|contexte|r\xe8gle|sous\\s+condition|condition|donn\xe9e|cons\xe9quence|rempli|\xe9gal\\s+\xe0|assertion|d\xe9finition)\\b', bygroups(Keyword.Declaration)), (u'\\b(champ\\s+d\'application|si\\s+et\\s+seulement\\s+si|d\xe9pend\\s+de|d\xe9claration|inclus|collection|contenu|optionnel|structure|\xe9num\xe9ration|contexte|r\xe8gle|sous\\s+condition|condition|donn\xe9e|cons\xe9quence|rempli|\xe9gal\\s+\xe0|assertion|d\xe9finition)\\b', bygroups(Keyword.Declaration)),
(u'(\\|[0-9]+/[0-9]+/[0-9]+\\|)', bygroups(Number.Integer)), (u'(\\|[0-9]+/[0-9]+/[0-9]+\\|)', bygroups(Number.Integer)),
(u'\\b(vrai|faux)\\b', bygroups(Keyword.Constant)), (u'\\b(vrai|faux)\\b', bygroups(Keyword.Constant)),
(u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)), (u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)),
(u'(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))', bygroups(Operator)), (u'(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))', bygroups(Operator)),
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|non|ou|et|=|>|<|\u20ac|%|an|mois|jour)', bygroups(Operator)), (u'(\\-\\>|\\+|\\-|\\*|/|\\!|non|ou|et|=|>|<|\u20ac|%|an|mois|jour)',
(u'\\b(entier|bool\xe9en|date|montant|texte|d\xe9cimal|d\xe9cret|loi|nombre|somme|date_aujourd_hui)\\b', bygroups(Keyword.Type)), bygroups(Operator)),
(u'\\b(entier|bool\xe9en|date|argent|texte|d\xe9cimal|d\xe9cret|loi|nombre|somme|date_aujourd_hui)\\b',
bygroups(Keyword.Type)),
(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_\\\']*)(\\.)([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.Class, Operator, 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_\\\']*)(\\.)([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.Class, Operator, Name.Variable)),
(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_\\\']*)(\\.)([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, Operator, Text)), (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_\\\']*)(\\.)([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, Operator, Text)),
(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\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)),
@ -39,13 +43,13 @@ class CatalaFrLexer(RegexLexer):
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),
('.', Text), ('.', Text),
], ],
'main__1' : [ 'main__1': [
(u'(@@)', bygroups(Generic.Heading), 'root'), (u'(@@)', bygroups(Generic.Heading), 'root'),
(u'(.)', bygroups(Generic.Heading)), (u'(.)', bygroups(Generic.Heading)),
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),
('.', Text), ('.', Text),
], ],
'main__2' : [ 'main__2': [
(u'(@)', bygroups(Generic.Heading), 'root'), (u'(@)', bygroups(Generic.Heading), 'root'),
(u'(.)', bygroups(Generic.Heading)), (u'(.)', bygroups(Generic.Heading)),
('(\n|\r|\r\n)', Text), ('(\n|\r|\r\n)', Text),

View File

@ -197,7 +197,7 @@
</dict> </dict>
<dict> <dict>
<key>match</key> <key>match</key>
<string>\b(entier|booléen|date|montant|texte|décimal|décret|loi|nombre|somme|date_aujourd_hui)\b</string> <string>\b(entier|booléen|date|argent|texte|décimal|décret|loi|nombre|somme|date_aujourd_hui)\b</string>
<key>name</key> <key>name</key>
<string>support.type.catala_fr</string> <string>support.type.catala_fr</string>
</dict> </dict>

View File

@ -120,11 +120,11 @@
'name' : 'punctuation.catala_nv' 'name' : 'punctuation.catala_nv'
} }
{ {
'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\\\$|%|year|month|day)' 'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)'
'name' : 'keyword.operator.catala_nv' 'name' : 'keyword.operator.catala_nv'
} }
{ {
'match' : '\\b(int|bool|date|amount|text|decimal|number|sum|now)\\b' 'match' : '\\b(int|bool|date|money|text|decimal|number|sum|now)\\b'
'name' : 'support.type.catala_nv' 'name' : 'support.type.catala_nv'
} }
{ {

View File

@ -240,12 +240,12 @@ code : context {
} }
: pattern { : pattern {
regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\\$|%|year|month|day) regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\$|%|year|month|day)
styles [] = .operator; styles [] = .operator;
} }
: pattern { : pattern {
regex \= \b(int|bool|date|amount|text|decimal|number|sum|now)\b regex \= \b(int|bool|date|money|text|decimal|number|sum|now)\b
styles [] = .primitive; styles [] = .primitive;
} }

View File

@ -33,9 +33,9 @@ class CatalaNvLexer(RegexLexer):
(u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)), (u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)),
(u'(\\-\\-|\\;|\\.|\\,|\\:=|\\:|\\(|\\)|\\[|\\])', (u'(\\-\\-|\\;|\\.|\\,|\\:=|\\:|\\(|\\)|\\[|\\])',
bygroups(Operator)), bygroups(Operator)),
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\\\$|%|year|month|day)', (u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)',
bygroups(Operator)), bygroups(Operator)),
(u'\\b(int|bool|date|amount|text|decimal|number|sum|now)\\b', (u'\\b(int|bool|date|money|text|decimal|number|sum|now)\\b',
bygroups(Keyword.Type)), bygroups(Keyword.Type)),
(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_\\\']*)(\\.)([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.Class, Operator, 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_\\\']*)(\\.)([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.Class, Operator, Name.Variable)),
(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_\\\']*)(\\.)([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, Operator, Text)), (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_\\\']*)(\\.)([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, Operator, Text)),

View File

@ -191,13 +191,13 @@
</dict> </dict>
<dict> <dict>
<key>match</key> <key>match</key>
<string>(\-\&gt;|\+|\-|\*|/|\!|not|or|and|=|&gt;|&lt;|\\$|%|year|month|day)</string> <string>(\-\&gt;|\+|\-|\*|/|\!|not|or|and|=|&gt;|&lt;|\$|%|year|month|day)</string>
<key>name</key> <key>name</key>
<string>keyword.operator.catala_nv</string> <string>keyword.operator.catala_nv</string>
</dict> </dict>
<dict> <dict>
<key>match</key> <key>match</key>
<string>\b(int|bool|date|amount|text|decimal|number|sum|now)\b</string> <string>\b(int|bool|date|money|text|decimal|number|sum|now)\b</string>
<key>name</key> <key>name</key>
<string>support.type.catala_nv</string> <string>support.type.catala_nv</string>
</dict> </dict>

View File

@ -6,7 +6,9 @@ CATALA_OPTS?=
CATALA=dune exec --no-buffer --no-print-director ../src/catala.exe -- Interpret $(CATALA_OPTS) CATALA=dune exec --no-buffer --no-print-director ../src/catala.exe -- Interpret $(CATALA_OPTS)
tests: $(wildcard */*.out) pass_tests: $(wildcard */*.out)
reset_tests: $(subst .out,.in,$(wildcard */*.out))
# Forces all the tests to be redone # Forces all the tests to be redone
.FORCE: .FORCE:

View File

@ -0,0 +1,13 @@
@Article@
/*
new scope A:
param x content money
param y content money
param z content money
scope A:
def x := $123.54
def y := $8548,650.96
def z := (x *$ y)
*/

View File

@ -0,0 +1,13 @@
[ERROR] Error during typechecking, types dec and money are incompatible
[ERROR]
[ERROR] Type dec coming from expression:
[ERROR] --> test_money/no_mingle.catala
[ERROR] |
[ERROR] 12 | def z := (x *$ y)
[ERROR] | ^^
[ERROR]
[ERROR] Type money coming from expression:
[ERROR] --> test_money/no_mingle.catala
[ERROR] |
[ERROR] 4 | new scope A:
[ERROR] | ^

View File

@ -2,9 +2,9 @@
/* /*
new scope A: new scope A:
param x content amount param x content money
param y content amount param y content money
param z content amount param z content money
scope A: scope A:
def x := $123.54 def x := $123.54

View File

@ -22,7 +22,7 @@
[ERROR] --> test_scope/cycle_in_scope.catala [ERROR] --> test_scope/cycle_in_scope.catala
[ERROR] | [ERROR] |
[ERROR] 13 | def z [y < 1] := y [ERROR] 13 | def z [y < 1] := y
[ERROR] | ^ [ERROR] | ^
[ERROR] [ERROR]
[ERROR] Cycle variable x, declared: [ERROR] Cycle variable x, declared:
[ERROR] --> test_scope/cycle_in_scope.catala [ERROR] --> test_scope/cycle_in_scope.catala
@ -34,4 +34,4 @@
[ERROR] --> test_scope/cycle_in_scope.catala [ERROR] --> test_scope/cycle_in_scope.catala
[ERROR] | [ERROR] |
[ERROR] 11 | def y [x >= 0] := x [ERROR] 11 | def y [x >= 0] := x
[ERROR] | ^ [ERROR] | ^

View File

@ -1,2 +1,2 @@
[RESULT] a -> 42 [RESULT] a -> 42
[RESULT] b -> true [RESULT] b -> true

View File

@ -1 +1 @@
[RESULT] z -> 2 [RESULT] z -> 2

View File

@ -3,4 +3,4 @@
[ERROR] --> test_struct/nested.catala [ERROR] --> test_struct/nested.catala
[ERROR] | [ERROR] |
[ERROR] 5 | data x content S [ERROR] 5 | data x content S
[ERROR] | ^ [ERROR] | ^

View File

@ -3,4 +3,4 @@
[ERROR] --> test_struct/nested2.catala [ERROR] --> test_struct/nested2.catala
[ERROR] | [ERROR] |
[ERROR] 5 | data x content E [ERROR] 5 | data x content E
[ERROR] | ^ [ERROR] | ^