mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
amount -> money
This commit is contained in:
parent
159901b993
commit
a4916208ba
@ -87,7 +87,7 @@ While all the code sections are equivalent in terms of execution, you can mark s
|
||||
/*
|
||||
declaration structure FooBar:
|
||||
data foo content boolean
|
||||
data bar content amount
|
||||
data bar content money
|
||||
|
||||
<your structure/enumeration/scope declarations goes here>
|
||||
*/
|
||||
|
@ -157,7 +157,7 @@ Current proposal : "amount".
|
||||
The base data type for representing amounts of money.
|
||||
|
||||
```
|
||||
data foo content amount
|
||||
data foo content money
|
||||
```
|
||||
|
||||
## TEXT
|
||||
|
@ -17,7 +17,7 @@ déclaration énumération PriseEnCharge :
|
||||
déclaration structure Enfant :
|
||||
donnée fin_obligation_scolaire contenu date
|
||||
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
|
||||
condition confié_service_social
|
||||
|
||||
@ -99,8 +99,8 @@ déclaration énumération Prestation:
|
||||
déclaration structure PrestationsFamiliales :
|
||||
condition conditions_hors_âge dépend de Enfant
|
||||
condition droits_ouverts dépend de Enfant
|
||||
donnée base_mensuelle contenu montant
|
||||
donnée base_mensuelle_dom contenu montant
|
||||
donnée base_mensuelle contenu argent
|
||||
donnée base_mensuelle_dom contenu argent
|
||||
|
||||
déclaration énumération ChargeAllocation :
|
||||
-- Complète
|
||||
@ -110,21 +110,21 @@ déclaration structure AllocationsFamiliales :
|
||||
condition droits_ouverts
|
||||
donnée date_ouverture_droits contenu date
|
||||
condition conditions_hors_âge dépend de Enfant
|
||||
donnée base contenu montant
|
||||
donnée avec_garde_alternée contenu montant
|
||||
donnée montant_versé contenu montant
|
||||
donnée base contenu argent
|
||||
donnée avec_garde_alternée contenu argent
|
||||
donnée montant_versé contenu argent
|
||||
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 rapport_enfants_total_moyen contenu décimal
|
||||
donnée nombre_total_enfants contenu entier
|
||||
donnée nombre_moyen_enfants contenu décimal
|
||||
donnée montant_premier_enfant contenu montant
|
||||
donnée montant_deuxieme_enfant contenu montant
|
||||
donnée montant_troisième_enfant_et_plus contenu montant
|
||||
donnée montant_premier_enfant contenu argent
|
||||
donnée montant_deuxieme_enfant contenu argent
|
||||
donnée montant_troisième_enfant_et_plus contenu argent
|
||||
|
||||
déclaration structure AllocationForfaitaire :
|
||||
condition droits_ouverts dépend de Enfant
|
||||
donnée montant_versé contenu montant
|
||||
donnée montant_versé contenu argent
|
||||
|
||||
déclaration énumération ChoixParentAllocataire :
|
||||
-- UnParent contenu Personne
|
||||
@ -140,16 +140,16 @@ déclaration structure AllocationsGardeAlternée :
|
||||
|
||||
déclaration structure MajorationsAllocationsFamiliales :
|
||||
condition droits_ouverts dépend de Enfant
|
||||
donnée base_par_enfant contenu montant dépend de Enfant
|
||||
donnée avec_garde_alternée contenu montant dépend de Enfant
|
||||
donnée montant_versé contenu montant
|
||||
donnée base_par_enfant contenu argent dépend de Enfant
|
||||
donnée avec_garde_alternée contenu argent dépend de Enfant
|
||||
donnée montant_versé contenu argent
|
||||
|
||||
déclaration structure ComplémentDégressif :
|
||||
condition droits_ouverts dépend de montant
|
||||
donnée dépassement contenu montant dépend de montant
|
||||
donnée pour_allocation_forfaitaire contenu montant
|
||||
donnée pour_allocations_familiales_et_majorations contenu montant
|
||||
donnée montant_versé contenu montant
|
||||
donnée dépassement contenu argent dépend de montant
|
||||
donnée pour_allocation_forfaitaire contenu argent
|
||||
donnée pour_allocations_familiales_et_majorations contenu argent
|
||||
donnée montant_versé contenu argent
|
||||
|
||||
déclaration structure TitreI:
|
||||
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_alternatif contenu entier
|
||||
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 :
|
||||
donnée nombre_minimum_enfants contenu montant
|
||||
donnée ressources_ménage contenu montant
|
||||
donnée nombre_minimum_enfants contenu argent
|
||||
donnée ressources_ménage contenu argent
|
||||
|
||||
déclaration structure L521_3 :
|
||||
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 :
|
||||
condition régime_outre_mer
|
||||
|
||||
déclaration structure D521_3 :
|
||||
donnée plafond_I contenu montant
|
||||
donnée plafond_II contenu montant
|
||||
donnée plafond_I contenu argent
|
||||
donnée plafond_II contenu argent
|
||||
|
||||
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 :
|
||||
# Les règles déclarées dans PrestationsFamiliales pourront utiliser
|
||||
|
@ -36,15 +36,15 @@ total dont sont retranchées les charges énumérées à l'article 156.
|
||||
|
||||
/*
|
||||
déclaration structure RevenuNetGlobal:
|
||||
donnée revenus_fonciers contenu montant
|
||||
donnée bénéfices_industriels_commerciaux contenu montant
|
||||
donnée rémunérations_dirigeants contenu montant
|
||||
donnée bénéfices_agricoles contenu montant
|
||||
donnée traitements_salaires contenu montant
|
||||
donnée bénéfices_non_commerciaux contenu montant
|
||||
donnée revenus_capitaux_mobiliers contenu montant
|
||||
donnée plus_values contenu montant
|
||||
donnée total contenu montant
|
||||
donnée revenus_fonciers contenu argent
|
||||
donnée bénéfices_industriels_commerciaux contenu argent
|
||||
donnée rémunérations_dirigeants contenu argent
|
||||
donnée bénéfices_agricoles contenu argent
|
||||
donnée traitements_salaires contenu argent
|
||||
donnée bénéfices_non_commerciaux contenu argent
|
||||
donnée revenus_capitaux_mobiliers contenu argent
|
||||
donnée plus_values contenu argent
|
||||
donnée total contenu argent
|
||||
|
||||
déclaration champ d'application CalculImpotSurLeRevenu :
|
||||
contexte revenu_net_global contenu RevenuNetGlobal
|
||||
|
@ -46,11 +46,11 @@ individual and the income tax computation:
|
||||
@@Begin metadata@@
|
||||
/*
|
||||
declaration structure Individual:
|
||||
data income content amount
|
||||
data income content money
|
||||
|
||||
declaration structure Article1:
|
||||
data fixed_percentage content decimal
|
||||
data income_tax content amount
|
||||
data income_tax content money
|
||||
*/
|
||||
@@End metadata@@
|
||||
|
||||
@ -158,13 +158,13 @@ computation:
|
||||
@@Begin metadata@@
|
||||
/*
|
||||
declaration structure TwoBrackets:
|
||||
data breakpoint content amount
|
||||
data breakpoint content money
|
||||
data rate1 content decimal
|
||||
data rate2 content decimal
|
||||
|
||||
declaration scope TwoBracketsTaxComputation :
|
||||
context brackets content TwoBrackets
|
||||
context tax_formula content amount depends on amount
|
||||
context tax_formula content money depends on amount
|
||||
*/
|
||||
@@End metadata@@
|
||||
|
||||
|
@ -13,23 +13,23 @@ declaration structure Acquisition:
|
||||
data no_sale_or_exchange_before content boolean
|
||||
|
||||
declaration structure Value:
|
||||
data fair_market content amount depends on date
|
||||
data last_acquisition content amount
|
||||
data net_appreciation content amount
|
||||
data fair_market content money depends on date
|
||||
data last_acquisition content money
|
||||
data net_appreciation content money
|
||||
|
||||
declaration structure Transferor:
|
||||
data basis content amount
|
||||
data basis content money
|
||||
data basis_known content optional amount
|
||||
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:
|
||||
context acquisition content Acquisition
|
||||
context basis_subsection_a content amount
|
||||
context basis content amount
|
||||
context basis_bonus_after_1976 content amount
|
||||
context basis_subsection_a content money
|
||||
context basis content money
|
||||
context basis_bonus_after_1976 content money
|
||||
context transferor content Transferor
|
||||
context gift_tax_paid content amount
|
||||
context gift_tax_paid content money
|
||||
*/
|
||||
@@End metadata@@
|
||||
|
||||
|
@ -13,14 +13,14 @@ declaration structure Property:
|
||||
|
||||
declaration structure SaleOrExchange:
|
||||
data property content Property
|
||||
data gain content amount
|
||||
data gain content money
|
||||
data date_of_sale_or_exchange content date
|
||||
|
||||
declaration scope Section121:
|
||||
context taxpayer content Person
|
||||
context applicable condition
|
||||
context maximum_gain_excluded content amount
|
||||
context gain_considered_for_exclusion content amount
|
||||
context maximum_gain_excluded content money
|
||||
context gain_considered_for_exclusion content money
|
||||
context sale_or_exchange content SaleOrExchange
|
||||
context included_in_gross_income condition
|
||||
context ownage_considered_for_gain_inclusion condition
|
||||
|
@ -8,12 +8,12 @@ declaration enumeration DiscountType:
|
||||
-- Services
|
||||
|
||||
declaration scope QualifiedEmployeeDiscount:
|
||||
context customer_price content amount
|
||||
context employee_price content amount
|
||||
context customer_price content money
|
||||
context employee_price content money
|
||||
context gross_profit_percentage content decimal
|
||||
context qualified_employee_discount content amount
|
||||
context employee_discount content amount
|
||||
context aggregate_cost content amount
|
||||
context qualified_employee_discount content money
|
||||
context employee_discount content money
|
||||
context aggregate_cost content money
|
||||
context discount_type content DiscountType
|
||||
*/
|
||||
@@End metadata@@
|
||||
|
@ -65,7 +65,7 @@ let token_list : (string * token) list =
|
||||
("set", COLLECTION);
|
||||
("enum", ENUM);
|
||||
("int", INTEGER);
|
||||
("amount", MONEY);
|
||||
("money", MONEY);
|
||||
("text", TEXT);
|
||||
("decimal", DECIMAL);
|
||||
("date", DATE);
|
||||
@ -155,7 +155,7 @@ let rec lex_code (lexbuf : lexbuf) : token =
|
||||
| "int" ->
|
||||
update_acc lexbuf;
|
||||
INTEGER
|
||||
| "amount" ->
|
||||
| "money" ->
|
||||
update_acc lexbuf;
|
||||
MONEY
|
||||
| "text" ->
|
||||
|
@ -33,7 +33,7 @@ let token_list_en : (string * token) list =
|
||||
("collection", COLLECTION);
|
||||
("enumeration", ENUM);
|
||||
("integer", INTEGER);
|
||||
("amount", MONEY);
|
||||
("money", MONEY);
|
||||
("text", TEXT);
|
||||
("decimal", DECIMAL);
|
||||
("date", DATE);
|
||||
@ -123,7 +123,7 @@ let rec lex_code_en (lexbuf : lexbuf) : token =
|
||||
| "integer" ->
|
||||
L.update_acc lexbuf;
|
||||
INTEGER
|
||||
| "amount" ->
|
||||
| "money" ->
|
||||
L.update_acc lexbuf;
|
||||
MONEY
|
||||
| "text" ->
|
||||
|
@ -33,7 +33,7 @@ let token_list_fr : (string * token) list =
|
||||
("collection", COLLECTION);
|
||||
("énumération", ENUM);
|
||||
("entier", INTEGER);
|
||||
("montant", MONEY);
|
||||
("argent", MONEY);
|
||||
("texte", TEXT);
|
||||
("decimal", DECIMAL);
|
||||
("date", DATE);
|
||||
@ -124,7 +124,7 @@ let rec lex_code_fr (lexbuf : lexbuf) : token =
|
||||
| "entier" ->
|
||||
L.update_acc lexbuf;
|
||||
INTEGER
|
||||
| "montant" ->
|
||||
| "argent" ->
|
||||
L.update_acc lexbuf;
|
||||
MONEY
|
||||
| "texte" ->
|
||||
|
@ -25,9 +25,9 @@ let rec format_typ (fmt : Format.formatter) (typ : typ Pos.marked) : unit =
|
||||
in
|
||||
match Pos.unmark typ with
|
||||
| TLit TUnit -> Format.fprintf fmt "unit"
|
||||
| TLit TBool -> Format.fprintf fmt "bool"
|
||||
| TLit TInt -> Format.fprintf fmt "int"
|
||||
| TLit TRat -> Format.fprintf fmt "dec"
|
||||
| TLit TBool -> Format.fprintf fmt "boolean"
|
||||
| TLit TInt -> Format.fprintf fmt "integer"
|
||||
| TLit TRat -> Format.fprintf fmt "decimal"
|
||||
| TLit TMoney -> Format.fprintf fmt "money"
|
||||
| TTuple ts ->
|
||||
Format.fprintf fmt "(%a)"
|
||||
|
@ -38,9 +38,9 @@ let rec format_typ (fmt : Format.formatter) (typ : typ Pos.marked) : unit =
|
||||
in
|
||||
match Pos.unmark typ with
|
||||
| TLit TUnit -> Format.fprintf fmt "unit"
|
||||
| TLit TBool -> Format.fprintf fmt "bool"
|
||||
| TLit TInt -> Format.fprintf fmt "int"
|
||||
| TLit TRat -> Format.fprintf fmt "dec"
|
||||
| TLit TBool -> Format.fprintf fmt "boolean"
|
||||
| TLit TInt -> Format.fprintf fmt "integer"
|
||||
| TLit TRat -> Format.fprintf fmt "decimal"
|
||||
| TLit TMoney -> Format.fprintf fmt "money"
|
||||
| TStruct s -> Format.fprintf fmt "%a" Ast.StructName.format_t s
|
||||
| TEnum e -> Format.fprintf fmt "%a" Ast.EnumName.format_t e
|
||||
|
@ -120,11 +120,11 @@
|
||||
'name' : 'punctuation.catala_en'
|
||||
}
|
||||
{
|
||||
'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)'
|
||||
'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\$|%|year|month|day)'
|
||||
'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'
|
||||
}
|
||||
{
|
||||
|
@ -240,12 +240,12 @@ code : context {
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\\$|%|year|month|day)
|
||||
regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\$|%|year|month|day)
|
||||
styles [] = .operator;
|
||||
}
|
||||
|
||||
: 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;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,8 @@ from pygments.token import *
|
||||
|
||||
import re
|
||||
|
||||
__all__=['CatalaEnLexer']
|
||||
__all__ = ['CatalaEnLexer']
|
||||
|
||||
|
||||
class CatalaEnLexer(RegexLexer):
|
||||
name = 'CatalaEn'
|
||||
@ -12,7 +13,7 @@ class CatalaEnLexer(RegexLexer):
|
||||
flags = re.MULTILINE | re.UNICODE
|
||||
|
||||
tokens = {
|
||||
'root' : [
|
||||
'root': [
|
||||
(u'(@@)', bygroups(Generic.Heading), 'main__1'),
|
||||
(u'(@)', bygroups(Generic.Heading), 'main__2'),
|
||||
(u'([^\\/\\n\\r])', bygroups(Text)),
|
||||
@ -20,18 +21,21 @@ class CatalaEnLexer(RegexLexer):
|
||||
('(\n|\r|\r\n)', Text),
|
||||
('.', Text),
|
||||
],
|
||||
'code' : [
|
||||
'code': [
|
||||
(u'(\\*\\/)', bygroups(Text), 'root'),
|
||||
(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(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'\\b(true|false)\\b', bygroups(Keyword.Constant)),
|
||||
(u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)),
|
||||
(u'(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))', bygroups(Operator)),
|
||||
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)', bygroups(Operator)),
|
||||
(u'\\b(integer|boolean|date|amount|text|decimal|number|sum|now)\\b', bygroups(Keyword.Type)),
|
||||
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\$|%|year|month|day)',
|
||||
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\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)),
|
||||
@ -39,13 +43,13 @@ class CatalaEnLexer(RegexLexer):
|
||||
('(\n|\r|\r\n)', Text),
|
||||
('.', Text),
|
||||
],
|
||||
'main__1' : [
|
||||
'main__1': [
|
||||
(u'(@@)', bygroups(Generic.Heading), 'root'),
|
||||
(u'(.)', bygroups(Generic.Heading)),
|
||||
('(\n|\r|\r\n)', Text),
|
||||
('.', Text),
|
||||
],
|
||||
'main__2' : [
|
||||
'main__2': [
|
||||
(u'(@)', bygroups(Generic.Heading), 'root'),
|
||||
(u'(.)', bygroups(Generic.Heading)),
|
||||
('(\n|\r|\r\n)', Text),
|
||||
|
@ -191,13 +191,13 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\\$|%|year|month|day)</string>
|
||||
<string>(\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\$|%|year|month|day)</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.catala_en</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<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>
|
||||
<string>support.type.catala_en</string>
|
||||
</dict>
|
||||
|
@ -124,7 +124,7 @@
|
||||
'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'
|
||||
}
|
||||
{
|
||||
|
@ -245,7 +245,7 @@ code : context {
|
||||
}
|
||||
|
||||
: 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;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,8 @@ from pygments.token import *
|
||||
|
||||
import re
|
||||
|
||||
__all__=['CatalaFrLexer']
|
||||
__all__ = ['CatalaFrLexer']
|
||||
|
||||
|
||||
class CatalaFrLexer(RegexLexer):
|
||||
name = 'CatalaFr'
|
||||
@ -12,7 +13,7 @@ class CatalaFrLexer(RegexLexer):
|
||||
flags = re.MULTILINE | re.UNICODE
|
||||
|
||||
tokens = {
|
||||
'root' : [
|
||||
'root': [
|
||||
(u'(@@)', bygroups(Generic.Heading), 'main__1'),
|
||||
(u'(@)', bygroups(Generic.Heading), 'main__2'),
|
||||
(u'([^\\/\\n\\r])', bygroups(Text)),
|
||||
@ -20,18 +21,21 @@ class CatalaFrLexer(RegexLexer):
|
||||
('(\n|\r|\r\n)', Text),
|
||||
('.', Text),
|
||||
],
|
||||
'code' : [
|
||||
'code': [
|
||||
(u'(\\*\\/)', bygroups(Text), 'root'),
|
||||
(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(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'\\b(vrai|faux)\\b', bygroups(Keyword.Constant)),
|
||||
(u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)),
|
||||
(u'(\\-\\-|\\;|\\.|\\,|\\:|\\(|\\))', bygroups(Operator)),
|
||||
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|non|ou|et|=|>|<|\u20ac|%|an|mois|jour)', bygroups(Operator)),
|
||||
(u'\\b(entier|bool\xe9en|date|montant|texte|d\xe9cimal|d\xe9cret|loi|nombre|somme|date_aujourd_hui)\\b', bygroups(Keyword.Type)),
|
||||
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|non|ou|et|=|>|<|\u20ac|%|an|mois|jour)',
|
||||
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\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)),
|
||||
@ -39,13 +43,13 @@ class CatalaFrLexer(RegexLexer):
|
||||
('(\n|\r|\r\n)', Text),
|
||||
('.', Text),
|
||||
],
|
||||
'main__1' : [
|
||||
'main__1': [
|
||||
(u'(@@)', bygroups(Generic.Heading), 'root'),
|
||||
(u'(.)', bygroups(Generic.Heading)),
|
||||
('(\n|\r|\r\n)', Text),
|
||||
('.', Text),
|
||||
],
|
||||
'main__2' : [
|
||||
'main__2': [
|
||||
(u'(@)', bygroups(Generic.Heading), 'root'),
|
||||
(u'(.)', bygroups(Generic.Heading)),
|
||||
('(\n|\r|\r\n)', Text),
|
||||
|
@ -197,7 +197,7 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<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>
|
||||
<string>support.type.catala_fr</string>
|
||||
</dict>
|
||||
|
@ -120,11 +120,11 @@
|
||||
'name' : 'punctuation.catala_nv'
|
||||
}
|
||||
{
|
||||
'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\\\$|%|year|month|day)'
|
||||
'match' : '(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)'
|
||||
'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'
|
||||
}
|
||||
{
|
||||
|
@ -240,12 +240,12 @@ code : context {
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\\$|%|year|month|day)
|
||||
regex \= (\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\$|%|year|month|day)
|
||||
styles [] = .operator;
|
||||
}
|
||||
|
||||
: 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;
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,9 @@ class CatalaNvLexer(RegexLexer):
|
||||
(u'\\b([0-9]+(,[0.9]*|))\\b', bygroups(Number.Integer)),
|
||||
(u'(\\-\\-|\\;|\\.|\\,|\\:=|\\:|\\(|\\)|\\[|\\])',
|
||||
bygroups(Operator)),
|
||||
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\\\$|%|year|month|day)',
|
||||
(u'(\\-\\>|\\+|\\-|\\*|/|\\!|not|or|and|=|>|<|\\$|%|year|month|day)',
|
||||
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)),
|
||||
(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)),
|
||||
|
@ -191,13 +191,13 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\\$|%|year|month|day)</string>
|
||||
<string>(\-\>|\+|\-|\*|/|\!|not|or|and|=|>|<|\$|%|year|month|day)</string>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.catala_nv</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<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>
|
||||
<string>support.type.catala_nv</string>
|
||||
</dict>
|
||||
|
@ -6,7 +6,9 @@ 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
|
||||
.FORCE:
|
||||
|
13
tests/test_money/no_mingle.catala
Normal file
13
tests/test_money/no_mingle.catala
Normal 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)
|
||||
*/
|
13
tests/test_money/no_mingle.catala.A.out
Normal file
13
tests/test_money/no_mingle.catala.A.out
Normal 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] | ^
|
@ -2,9 +2,9 @@
|
||||
|
||||
/*
|
||||
new scope A:
|
||||
param x content amount
|
||||
param y content amount
|
||||
param z content amount
|
||||
param x content money
|
||||
param y content money
|
||||
param z content money
|
||||
|
||||
scope A:
|
||||
def x := $123.54
|
||||
|
Loading…
Reference in New Issue
Block a user