mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Refactor Python dep handling + update cheat-sheet (#419)
This commit is contained in:
commit
57e29f60bd
5
.github/workflows/run-make-all.yml
vendored
5
.github/workflows/run-make-all.yml
vendored
@ -35,8 +35,11 @@ jobs:
|
||||
docker run --rm catalalang/catala-build:${IMAGE_TAG} sh -uexc '
|
||||
opam --cli=2.1 remove z3 >&2
|
||||
opam --cli=2.1 exec -- dune build --profile=release french_law compiler/catala.bc.js >&2
|
||||
opam --cli=2.1 exec -- dune build --profile=release @doc >&2
|
||||
opam --cli=2.1 exec -- make -C doc/syntax >&2
|
||||
mv _build/default/compiler/catala.bc.js catala_'"${RELEASE_TAG}"'_node.js >&2
|
||||
tar c -h catala_'"${RELEASE_TAG}"'_node.js doc/syntax/syntax.pdf french_law --exclude french_law/js/node_modules --exclude french_law/python/env --exclude '"'"'.*'"'"' --exclude '"'"'__*'"'"'
|
||||
mv _build/default/_doc/_html doc/api >&2
|
||||
tar c -h catala_'"${RELEASE_TAG}"'_node.js french_law doc/syntax/syntax.pdf doc/api --exclude french_law/js/node_modules --exclude french_law/python/env --exclude '"'"'.*'"'"' --exclude '"'"'__*'"'"'
|
||||
' | tar vx -C artifacts
|
||||
- name: Build static binaries
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
_build/
|
||||
_opam/
|
||||
_python_venv/
|
||||
dune-workspace*
|
||||
result
|
||||
*.install
|
||||
@ -14,4 +15,4 @@ node_modules/
|
||||
build.ninja
|
||||
|
||||
.envrc
|
||||
.direnv
|
||||
.direnv
|
||||
|
@ -31,8 +31,7 @@ FROM dev-build-context
|
||||
ADD --chown=ocaml:ocaml . .
|
||||
|
||||
# Prepare extra local dependencies
|
||||
RUN opam exec -- make pygments dependencies-js
|
||||
RUN opam exec -- ./french_law/python/setup_env.sh
|
||||
RUN opam exec -- make dependencies-python dependencies-js pygments
|
||||
|
||||
# OCaml backtraces may be useful on failure
|
||||
ENV OCAMLRUNPARAM=b
|
||||
|
100
Makefile
100
Makefile
@ -12,7 +12,7 @@ export
|
||||
# Dependencies
|
||||
##########################################
|
||||
|
||||
EXECUTABLES = groff python3 colordiff node pygmentize node npm ninja pandoc
|
||||
EXECUTABLES = groff python3 colordiff node node npm ninja pandoc
|
||||
K := $(foreach exec,$(EXECUTABLES),\
|
||||
$(if $(shell which $(exec)),some string,$(warning [WARNING] No "$(exec)" executable found. \
|
||||
Please install this executable for everything to work smoothly)))
|
||||
@ -32,10 +32,35 @@ dependencies-ocaml-with-z3:
|
||||
dependencies-js:
|
||||
$(MAKE) -C $(FRENCH_LAW_JS_LIB_DIR) dependencies
|
||||
|
||||
#> dependencies : Install the Catala OCaml, JS and Git dependencies
|
||||
dependencies: dependencies-ocaml dependencies-js
|
||||
PY_VENV_DIR = _python_venv
|
||||
|
||||
dependencies-with-z3: dependencies-ocaml-with-z3 dependencies-js
|
||||
PY_VENV_ACTIVATE = . $(PY_VENV_DIR)/bin/activate;
|
||||
|
||||
# Rebuild when requirements change
|
||||
$(PY_VENV_DIR): $(PY_VENV_DIR)/stamp
|
||||
|
||||
$(PY_VENV_DIR)/stamp: \
|
||||
runtimes/python/catala/pyproject.toml \
|
||||
syntax_highlighting/en/pygments/pyproject.toml \
|
||||
syntax_highlighting/fr/pygments/pyproject.toml \
|
||||
syntax_highlighting/pl/pygments/pyproject.toml
|
||||
test -d $(PY_VENV_DIR) || python3 -m venv $(PY_VENV_DIR)
|
||||
$(PY_VENV_ACTIVATE) python3 -m pip install -U \
|
||||
-e runtimes/python/catala \
|
||||
-e syntax_highlighting/en/pygments \
|
||||
-e syntax_highlighting/fr/pygments \
|
||||
-e syntax_highlighting/pl/pygments
|
||||
touch $@
|
||||
|
||||
# Run sub-make within the Python venv
|
||||
MAKEP = $(PY_VENV_ACTIVATE) $(MAKE)
|
||||
|
||||
dependencies-python: $(PY_VENV_DIR)
|
||||
|
||||
#> dependencies : Install the Catala OCaml, JS and Git dependencies
|
||||
dependencies: dependencies-ocaml dependencies-js dependencies-python
|
||||
|
||||
dependencies-with-z3: dependencies-ocaml-with-z3 dependencies-js dependencies-python
|
||||
|
||||
##########################################
|
||||
# Catala compiler rules
|
||||
@ -104,17 +129,8 @@ SYNTAX_HIGHLIGHTING_FR=${CURDIR}/syntax_highlighting/fr
|
||||
SYNTAX_HIGHLIGHTING_EN=${CURDIR}/syntax_highlighting/en
|
||||
SYNTAX_HIGHLIGHTING_PL=${CURDIR}/syntax_highlighting/pl
|
||||
|
||||
pygmentize_fr: $(SYNTAX_HIGHLIGHTING_FR)/set_up_pygments.sh
|
||||
chmod +x $<
|
||||
$<
|
||||
|
||||
pygmentize_en: $(SYNTAX_HIGHLIGHTING_EN)/set_up_pygments.sh
|
||||
chmod +x $<
|
||||
$<
|
||||
|
||||
pygmentize_pl: $(SYNTAX_HIGHLIGHTING_PL)/set_up_pygments.sh
|
||||
chmod +x $<
|
||||
$<
|
||||
pygmentize_%: $(PY_VENV_DIR)
|
||||
$(PY_VENV_ACTIVATE) python3 -m pip install syntax_highlighting/$*/pygments
|
||||
|
||||
#> pygments : Extends your pygmentize executable with Catala lexers
|
||||
pygments: pygmentize_fr pygmentize_en pygmentize_pl
|
||||
@ -150,6 +166,13 @@ vscode_en: ${CURDIR}/syntax_highlighting/en/setup_vscode.sh
|
||||
#> vscode : Installs Catala syntax highlighting for VSCode
|
||||
vscode: vscode_fr vscode_en
|
||||
|
||||
##########################################
|
||||
# Extra documentation
|
||||
##########################################
|
||||
|
||||
syntax:
|
||||
$(MAKEP) -C doc/syntax
|
||||
|
||||
##########################################
|
||||
# Literate programming and examples
|
||||
##########################################
|
||||
@ -163,33 +186,33 @@ TUTORIAL_EN_DIR=$(EXAMPLES_DIR)/tutorial_en
|
||||
TUTORIEL_FR_DIR=$(EXAMPLES_DIR)/tutoriel_fr
|
||||
POLISH_TAXES_DIR=$(EXAMPLES_DIR)/polish_taxes
|
||||
|
||||
literate_aides_logement: build
|
||||
$(MAKE) -C $(AIDES_LOGEMENT_DIR) aides_logement.tex
|
||||
$(MAKE) -C $(AIDES_LOGEMENT_DIR) aides_logement.html
|
||||
literate_aides_logement: build $(PY_VENV_DIR)
|
||||
$(MAKEP) -C $(AIDES_LOGEMENT_DIR) aides_logement.tex
|
||||
$(MAKEP) -C $(AIDES_LOGEMENT_DIR) aides_logement.html
|
||||
|
||||
literate_allocations_familiales: build
|
||||
$(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.tex
|
||||
$(MAKE) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.html
|
||||
$(MAKEP) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.tex
|
||||
$(MAKEP) -C $(ALLOCATIONS_FAMILIALES_DIR) allocations_familiales.html
|
||||
|
||||
literate_code_general_impots: build
|
||||
$(MAKE) -C $(CODE_GENERAL_IMPOTS_DIR) code_general_impots.tex
|
||||
$(MAKE) -C $(CODE_GENERAL_IMPOTS_DIR) code_general_impots.html
|
||||
$(MAKEP) -C $(CODE_GENERAL_IMPOTS_DIR) code_general_impots.tex
|
||||
$(MAKEP) -C $(CODE_GENERAL_IMPOTS_DIR) code_general_impots.html
|
||||
|
||||
literate_us_tax_code: build
|
||||
$(MAKE) -C $(US_TAX_CODE_DIR) us_tax_code.tex
|
||||
$(MAKE) -C $(US_TAX_CODE_DIR) us_tax_code.html
|
||||
$(MAKEP) -C $(US_TAX_CODE_DIR) us_tax_code.tex
|
||||
$(MAKEP) -C $(US_TAX_CODE_DIR) us_tax_code.html
|
||||
|
||||
literate_tutorial_en: build
|
||||
$(MAKE) -C $(TUTORIAL_EN_DIR) tutorial_en.tex
|
||||
$(MAKE) -C $(TUTORIAL_EN_DIR) tutorial_en.html
|
||||
$(MAKEP) -C $(TUTORIAL_EN_DIR) tutorial_en.tex
|
||||
$(MAKEP) -C $(TUTORIAL_EN_DIR) tutorial_en.html
|
||||
|
||||
literate_tutoriel_fr: build
|
||||
$(MAKE) -C $(TUTORIEL_FR_DIR) tutoriel_fr.tex
|
||||
$(MAKE) -C $(TUTORIEL_FR_DIR) tutoriel_fr.html
|
||||
$(MAKEP) -C $(TUTORIEL_FR_DIR) tutoriel_fr.tex
|
||||
$(MAKEP) -C $(TUTORIEL_FR_DIR) tutoriel_fr.html
|
||||
|
||||
literate_polish_taxes: build
|
||||
$(MAKE) -C $(POLISH_TAXES_DIR) polish_taxes.tex
|
||||
$(MAKE) -C $(POLISH_TAXES_DIR) polish_taxes.html
|
||||
$(MAKEP) -C $(POLISH_TAXES_DIR) polish_taxes.tex
|
||||
$(MAKEP) -C $(POLISH_TAXES_DIR) polish_taxes.html
|
||||
|
||||
#> literate_examples : Builds the .tex and .html versions of the examples code. Needs pygments to be installed and patched with Catala.
|
||||
literate_examples: literate_allocations_familiales literate_code_general_impots \
|
||||
@ -269,11 +292,6 @@ FRENCH_LAW_LIBRARY_PYTHON = \
|
||||
$(FRENCH_LAW_PYTHON_LIB_DIR)/src/allocations_familiales.py \
|
||||
$(FRENCH_LAW_PYTHON_LIB_DIR)/src/aides_logement.py
|
||||
|
||||
PY_VIRTUALENV = $(FRENCH_LAW_PYTHON_LIB_DIR)/env/bin/activate
|
||||
|
||||
$(PY_VIRTUALENV):
|
||||
@$(if $(wildcard $(PY_VIRTUALENV)),,$(error "Python virtualenv not initialised, you need to run $(FRENCH_LAW_PYTHON_LIB_DIR)/setup_env.sh"))
|
||||
|
||||
$(FRENCH_LAW_LIBRARY_PYTHON):
|
||||
dune build $@
|
||||
|
||||
@ -282,15 +300,11 @@ generate_french_law_library_python:
|
||||
dune build $(FRENCH_LAW_LIBRARY_PYTHON)
|
||||
|
||||
#> type_french_law_library_python : Types the French law library Python sources with mypy
|
||||
type_french_law_library_python: $(PY_VIRTUALENV) \
|
||||
generate_french_law_library_python
|
||||
. $(PY_VIRTUALENV) ;\
|
||||
$(MAKE) -C $(FRENCH_LAW_PYTHON_LIB_DIR) type
|
||||
type_french_law_library_python: $(PY_VENV_DIR) generate_french_law_library_python
|
||||
$(MAKEP) -C $(FRENCH_LAW_PYTHON_LIB_DIR) type
|
||||
|
||||
run_french_law_library_benchmark_python: $(PY_VIRTUALENV) \
|
||||
type_french_law_library_python
|
||||
. $(PY_VIRTUALENV) ;\
|
||||
$(MAKE) -C $(FRENCH_LAW_PYTHON_LIB_DIR) bench
|
||||
run_french_law_library_benchmark_python: $(PY_ENV_DIR) type_french_law_library_python
|
||||
$(MAKEP) -C $(FRENCH_LAW_PYTHON_LIB_DIR) bench
|
||||
|
||||
##########################################
|
||||
# High-level test and benchmarks commands
|
||||
|
Binary file not shown.
@ -10,14 +10,17 @@
|
||||
%\usepackage{booktabs}
|
||||
\usepackage{upquote} % Uncurly the quotes
|
||||
\usepackage{etoolbox} % for backquote fix
|
||||
\usepackage[scaled=0.8]{DejaVuSans}
|
||||
\usepackage[scaled=0.8]{DejaVuSansMono}
|
||||
\usepackage[scaled=0.9]{DejaVuSans}
|
||||
\usepackage[scaled=0.9]{DejaVuSansMono}
|
||||
\usepackage{mdframed} % nice frames
|
||||
\usepackage[nobottomtitles]{titlesec} % better titles
|
||||
\usepackage{enumitem}
|
||||
\usepackage{minted}
|
||||
\usepackage[a4paper,landscape,margin=1cm,includehead,headsep=2ex,nofoot]{geometry}
|
||||
\usepackage{fancyhdr}\usepackage{hyperref}
|
||||
\usepackage{array}
|
||||
\usepackage[none]{hyphenat}
|
||||
\usepackage[document]{ragged2e}
|
||||
|
||||
\usemintedstyle{tango}
|
||||
|
||||
@ -157,6 +160,8 @@
|
||||
% Text at right
|
||||
%\raggedright
|
||||
|
||||
\renewcommand{\baselinestretch}{0.9}
|
||||
|
||||
% Set up the interline space in tables
|
||||
\renewcommand{\arraystretch}{0.0}
|
||||
|
||||
@ -169,6 +174,9 @@
|
||||
{\end{minted}}
|
||||
\makeatother
|
||||
|
||||
\setlength{\columnsep}{12pt}
|
||||
\setlength{\columnseprule}{.1pt}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\makeheader{\MakeUppercase{The Catala Syntax} \hspace{2em}\small english version}{v0.8.0}{1}
|
||||
@ -186,244 +194,263 @@
|
||||
\begin{multicols}{3}
|
||||
|
||||
\newlength\cola
|
||||
\setlength\cola{\dimexpr .4\columnwidth -2\tabcolsep}
|
||||
\setlength\cola{\dimexpr .65\columnwidth -2\tabcolsep}
|
||||
\newlength\colb
|
||||
\setlength\colb{\dimexpr .6\columnwidth -2\tabcolsep}
|
||||
|
||||
|
||||
\setlength\colb{\dimexpr .35\columnwidth -2\tabcolsep}
|
||||
|
||||
\section{Literate programming}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
Heading & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
# Title
|
||||
### Sub-subtitle
|
||||
\end{catala}
|
||||
&
|
||||
Heading
|
||||
\\
|
||||
Code block &
|
||||
\begin{catala}
|
||||
```catala
|
||||
```
|
||||
\end{catala}
|
||||
& Code block
|
||||
\\
|
||||
Metadata block & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala-metadata
|
||||
```
|
||||
\end{catala}
|
||||
& Metadata block
|
||||
\\
|
||||
File inclusion & \begin{catala}
|
||||
\begin{catala}
|
||||
> Include: foo.catala_en
|
||||
\end{catala}
|
||||
& File inclusion
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\newcommand*\FancyVerbStartString{\PYG{l+s}{```catala}}
|
||||
\newcommand*\FancyVerbStopString{\PYG{l+s}{```}}
|
||||
|
||||
\section{Types and literals}
|
||||
\section{Literals and types}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
true false
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
boolean
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\begin{catala}
|
||||
```catala
|
||||
true false
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
integer
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\begin{catala}
|
||||
```catala
|
||||
65536
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
integer
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
65536.262144 37%
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
decimal
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
65536.262144 37%
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
money
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\begin{catala}
|
||||
```catala
|
||||
$1,234,567.89
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
date
|
||||
money
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
|2021-01-31|
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
duration
|
||||
date
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
254 day 4 month 1 year
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
collection integer
|
||||
duration
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
[ 12; 24; 36 ]
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
decimal depends on money
|
||||
collection integer
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
f of x equals x / $12.0
|
||||
f of x, y equals
|
||||
x * y / $12.0
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
decimal depends on
|
||||
x content money,
|
||||
y content decimal
|
||||
```
|
||||
\end{catala}
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
Struct1 { -- fld1: 9 -- fld2: 7% }
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
Struct1
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\begin{catala}
|
||||
```catala
|
||||
Struct1 { -- fld1: 9 -- fld2: false }
|
||||
```
|
||||
\end{catala}
|
||||
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
Enum1
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
Case1 content 12 Case2
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
Enum1
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Expressions}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
Local definition & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
let x equals 36 - 5 in ...
|
||||
```
|
||||
\end{catala}
|
||||
& Local definition
|
||||
\\
|
||||
Pattern matching & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
match expr with pattern
|
||||
-- Case1 of x: ...
|
||||
-- Case1 of x : ...
|
||||
-- Case2 : ...
|
||||
-- anything : ...
|
||||
```
|
||||
\end{catala}
|
||||
& Pattern matching
|
||||
\\
|
||||
Pattern test and optional binding & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
expr with pattern Case1
|
||||
expr with pattern Case1 of x
|
||||
and x >= 2
|
||||
and x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Pattern test\newline and optional binding
|
||||
\\
|
||||
Structure field access & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
struc1.fld2
|
||||
```
|
||||
\end{catala}
|
||||
& Field access
|
||||
\\
|
||||
Function call & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
f of $44.50
|
||||
f of $44.50, 1/3
|
||||
```
|
||||
\end{catala}
|
||||
& Function call
|
||||
\\
|
||||
Subscope variable & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
sub1.var0
|
||||
```
|
||||
\end{catala}
|
||||
& Subscope variable
|
||||
\\
|
||||
Direct scope call & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
output of Scope1
|
||||
with { -- fld1: 9 -- fld2: true }
|
||||
output of Scope1 with
|
||||
{ -- fld1: 9 -- fld2: 15% }
|
||||
```
|
||||
\end{catala}
|
||||
& Direct scope call
|
||||
\\
|
||||
Conditional & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
if ... then ... else ...
|
||||
```
|
||||
\end{catala}
|
||||
& Conditional
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Metadata declaration}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
|
||||
Structure declaration &
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
declaration structure Struct1:
|
||||
data fld1 content integer
|
||||
data fld2 content boolean
|
||||
data fld2 content decimal
|
||||
\end{catala}
|
||||
& Structure declaration
|
||||
\\
|
||||
Enumeration declaration & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
declaration enumeration Enum1:
|
||||
-- Case1 content integer
|
||||
-- Case2
|
||||
```
|
||||
\end{catala}
|
||||
& Enumeration declaration
|
||||
\\
|
||||
Scope declaration & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
declaration scope Scope1:
|
||||
internal var1 content integer
|
||||
@ -431,8 +458,9 @@
|
||||
sub1 scope Scope0
|
||||
```
|
||||
\end{catala}
|
||||
& Scope declaration
|
||||
\\
|
||||
Input-output qualifiers & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
internal var1 content ...
|
||||
output var3 content ...
|
||||
@ -442,38 +470,57 @@
|
||||
context output var7 content ...
|
||||
```
|
||||
\end{catala}
|
||||
& Input-output qualifiers
|
||||
\\
|
||||
State transitions declaration & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
internal var1 content ...
|
||||
state before
|
||||
state after
|
||||
```
|
||||
\end{catala}
|
||||
& State transitions declaration
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
declaration const content decimal
|
||||
equals 17.1
|
||||
```
|
||||
\end{catala}
|
||||
& Global definition
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
declaration square content decimal
|
||||
depends on x content decimal
|
||||
equals x * x
|
||||
```
|
||||
\end{catala}
|
||||
& Global function definition
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Operators and built-ins}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
Logical operators & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
not a
|
||||
a and b
|
||||
a or b # "or otherwise"
|
||||
a xor b # exclusive or
|
||||
not a a and b
|
||||
a or b # "or otherwise"
|
||||
a xor b # exclusive or
|
||||
```
|
||||
\end{catala}
|
||||
& Logical operators
|
||||
\\
|
||||
Arithmetic & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
- a
|
||||
a + b a - b
|
||||
- a a + b a - b
|
||||
a * b a / b
|
||||
```
|
||||
\end{catala}
|
||||
& Arithmetic
|
||||
\\
|
||||
Comparison &
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
a = b a != b
|
||||
@ -481,29 +528,32 @@
|
||||
a >= b a <= b
|
||||
```
|
||||
\end{catala}
|
||||
& Comparison
|
||||
\\
|
||||
Conversions & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
decimal of 44
|
||||
money of 23.15
|
||||
```
|
||||
\end{catala}
|
||||
& Conversions
|
||||
\\
|
||||
Rounding & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
round of $9.99
|
||||
```
|
||||
\end{catala}
|
||||
& Rounding
|
||||
\\
|
||||
Date parts & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
get_day of ...
|
||||
get_month of ...
|
||||
get_year of ...
|
||||
```
|
||||
\end{catala}
|
||||
& Date parts
|
||||
\\
|
||||
Explicitly typed operators &
|
||||
\begin{catala}
|
||||
```catala
|
||||
a +! b # integer
|
||||
@ -512,6 +562,7 @@
|
||||
a +^ b # duration
|
||||
```
|
||||
\end{catala}
|
||||
& Explicitly typed operators
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
@ -519,167 +570,190 @@
|
||||
|
||||
\section{Scope definition}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
Scope use & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
scope Scope1: ...
|
||||
```
|
||||
\end{catala}
|
||||
& Scope use
|
||||
\\
|
||||
Use-wide condition & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
scope Scope1
|
||||
under condition var1 >= 2: ...
|
||||
```
|
||||
\end{catala}
|
||||
& Use-wide condition
|
||||
\\
|
||||
Unconditional definition & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
definition var1 equals ...
|
||||
```
|
||||
\end{catala}
|
||||
& Unconditional def.
|
||||
\\
|
||||
Conditional definition & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
definition var1
|
||||
under condition ...
|
||||
consequence equals ...
|
||||
```
|
||||
\end{catala}
|
||||
& Conditional definition
|
||||
\\
|
||||
Rule\newline(definition for conditions) & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
rule var2
|
||||
under condition var1 >= 2
|
||||
consequence fulfilled
|
||||
```
|
||||
\end{catala}
|
||||
& Rule (definition for conditions)
|
||||
\\
|
||||
Negative rule & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
consequence not fulfilled
|
||||
```
|
||||
\end{catala}
|
||||
& Negative rule
|
||||
\\
|
||||
Function definition/rule & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
definition f of x equals ...
|
||||
definition f of x, y equals ...
|
||||
```
|
||||
\end{catala}
|
||||
& Function def. or rule
|
||||
\\
|
||||
Labeled definition or rule & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
label lbl1 definition var1 ...
|
||||
```
|
||||
\end{catala}
|
||||
& Labeled def. or rule
|
||||
\\
|
||||
Exception to label & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
exception lbl1 definition var1 ...
|
||||
```
|
||||
\end{catala}
|
||||
& Exception to label
|
||||
\\
|
||||
Exception to implicit & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
exception definition var1 ...
|
||||
```
|
||||
\end{catala}
|
||||
& Exception to implicit
|
||||
\\
|
||||
State definition & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
definition var1
|
||||
state before
|
||||
equals ...
|
||||
```
|
||||
\end{catala}
|
||||
& State definition
|
||||
\\
|
||||
Assertion & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
assertion ...
|
||||
```
|
||||
\end{catala}
|
||||
& Assertion
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Collection operations}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
|
||||
Presence test & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
coll contains 3
|
||||
```
|
||||
\end{catala}
|
||||
& Presence test
|
||||
\\
|
||||
Cardinal & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
number of coll
|
||||
```
|
||||
\end{catala}
|
||||
& Cardinal
|
||||
\\
|
||||
Existence test & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
exists x among coll such that x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Existence test
|
||||
\\
|
||||
For all test & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
for all x among coll we have x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& For all test
|
||||
\\
|
||||
Mapping & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
(x + 2) for x among coll
|
||||
```
|
||||
\end{catala}
|
||||
& Mapping
|
||||
\\
|
||||
Filter & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
x among coll such that x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Filter
|
||||
\\
|
||||
Filter + map & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
(x - 2) for x among coll
|
||||
such that x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Filter + map
|
||||
\\
|
||||
Merge & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
coll1 ++ coll2
|
||||
```
|
||||
\end{catala}
|
||||
& Merge
|
||||
\\
|
||||
Aggregation & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
sum integer coll
|
||||
```
|
||||
\end{catala}
|
||||
& Aggregation
|
||||
\\
|
||||
Count & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
number of coll
|
||||
```
|
||||
\end{catala}
|
||||
& Count
|
||||
\\
|
||||
Extremum & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
maximum of coll
|
||||
or if collection empty then -1
|
||||
```
|
||||
\end{catala}
|
||||
& Extremum
|
||||
\\
|
||||
Arg-extremum & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
x among coll
|
||||
such that (x * x) is minimum
|
||||
or if collection empty then -1
|
||||
```
|
||||
\end{catala}
|
||||
& Arg-extremum
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
|
@ -10,14 +10,17 @@
|
||||
%\usepackage{booktabs}
|
||||
\usepackage{upquote} % Uncurly the quotes
|
||||
\usepackage{etoolbox} % for backquote fix
|
||||
\usepackage[scaled=0.8]{DejaVuSans}
|
||||
\usepackage[scaled=0.8]{DejaVuSansMono}
|
||||
\usepackage[scaled=0.9]{DejaVuSans}
|
||||
\usepackage[scaled=0.9]{DejaVuSansMono}
|
||||
\usepackage{mdframed} % nice frames
|
||||
\usepackage[nobottomtitles]{titlesec} % better titles
|
||||
\usepackage{enumitem}
|
||||
\usepackage{minted}
|
||||
\usepackage[a4paper,landscape,margin=1cm,includehead,headsep=2ex,nofoot]{geometry}
|
||||
\usepackage{fancyhdr}\usepackage{hyperref}
|
||||
\usepackage{array}
|
||||
\usepackage[none]{hyphenat}
|
||||
\usepackage[document]{ragged2e}
|
||||
|
||||
\usemintedstyle{tango}
|
||||
|
||||
@ -157,6 +160,8 @@
|
||||
% Text at right
|
||||
%\raggedright
|
||||
|
||||
\renewcommand{\baselinestretch}{0.9}
|
||||
|
||||
% Set up the interline space in tables
|
||||
\renewcommand{\arraystretch}{0.0}
|
||||
|
||||
@ -169,6 +174,9 @@
|
||||
{\end{minted}}
|
||||
\makeatother
|
||||
|
||||
\setlength{\columnsep}{12pt}
|
||||
\setlength{\columnseprule}{.1pt}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\makeheader{\MakeUppercase{La syntaxe de Catala} \hspace{2em}\small version française}{v0.8.0}{1}
|
||||
@ -186,259 +194,273 @@
|
||||
\begin{multicols}{3}
|
||||
|
||||
\newlength\cola
|
||||
\setlength\cola{\dimexpr .4\columnwidth -2\tabcolsep}
|
||||
\setlength\cola{\dimexpr .65\columnwidth -2\tabcolsep}
|
||||
\newlength\colb
|
||||
\setlength\colb{\dimexpr .6\columnwidth -2\tabcolsep}
|
||||
|
||||
|
||||
\setlength\colb{\dimexpr .35\columnwidth -2\tabcolsep}
|
||||
|
||||
\section{Programmation littéraire}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
En-têtes & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
# Titre
|
||||
### Sous-sous-titre
|
||||
\end{catala}
|
||||
& En-têtes
|
||||
\\
|
||||
Référence au journal officiel & \begin{catala}
|
||||
\begin{catala}
|
||||
# Article 1 | JORFARTI000012345678
|
||||
# Article 2 | LEGIARTI000012345678
|
||||
# Décision 3 | CETATEXT000012345678
|
||||
\end{catala}
|
||||
& Référence au journal officiel
|
||||
\\
|
||||
Bloc de code &
|
||||
\begin{catala}
|
||||
```catala
|
||||
```
|
||||
```catala ```catala-metadata
|
||||
``` ```
|
||||
\end{catala}
|
||||
& Bloc de code / métadonnées
|
||||
\\
|
||||
Bloc de métadonnées & \begin{catala}
|
||||
```catala-metadata
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
Inclusion de fichier & \begin{catala}
|
||||
\begin{catala}
|
||||
> Inclusion: foo.catala_en
|
||||
\end{catala}
|
||||
& Inclusion de fichier
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\newcommand*\FancyVerbStartString{\PYG{l+s}{```catala}}
|
||||
\newcommand*\FancyVerbStopString{\PYG{l+s}{```}}
|
||||
|
||||
\section{Types et littéraux}
|
||||
\section{Littéraux et types}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
vrai faux
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
booléen
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\begin{catala}
|
||||
```catala
|
||||
vrai faux
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
entier
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\begin{catala}
|
||||
```catala
|
||||
65536
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
décimal
|
||||
entier
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
65536,262144 37%
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
argent
|
||||
décimal
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
1 234 567,89€
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
date
|
||||
argent
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
|2021-01-31|
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
durée
|
||||
date
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
254 jour 4 mois 1 an
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
collection entier
|
||||
durée
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
[ 12; 24; 36 ]
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\begin{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
décimal dépend de argent
|
||||
collection entier
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
f de x égale à x / 12,0€
|
||||
f de x, y égal à
|
||||
x * y / 12,0€
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
décimal dépend de
|
||||
x contenu argent,
|
||||
y contenu décimal
|
||||
```
|
||||
\end{catala}
|
||||
|
||||
\\
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
Struct1 { -- chp1: 9 -- chp2: 7% }
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
Struct1
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
\begin{catala}
|
||||
```catala
|
||||
Struct1 { -- chp1: 9 -- chp2: faux }
|
||||
```
|
||||
\end{catala}
|
||||
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
Énum1
|
||||
```
|
||||
\end{catala}
|
||||
&
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
Cas1 contenu 12 Cas2
|
||||
```
|
||||
\end{catala}
|
||||
& \begin{catala}
|
||||
```catala
|
||||
Énum1
|
||||
```
|
||||
\end{catala}
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Expressions}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
Définition locale & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
soit x égale à 36 - 5 dans ...
|
||||
soit x égal à 36 - 5 dans ...
|
||||
```
|
||||
\end{catala}
|
||||
& Définition locale
|
||||
\\
|
||||
Filtrage par motif & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
selon expr sous forme
|
||||
-- Cas1 de x: ...
|
||||
-- Cas1 de x : ...
|
||||
-- Cas2 : ...
|
||||
-- n'importe quel : ...
|
||||
```
|
||||
\end{catala}
|
||||
& Filtrage par motif
|
||||
\\
|
||||
Test de filtrage\newline avec variable optionnelle & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
expr sous forme Cas1
|
||||
expr sous forme Cas1 de x
|
||||
et x >= 2
|
||||
et x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Test de filtrage\newline avec variable optionnelle
|
||||
\\
|
||||
Champ de structure & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
struc1.chp2
|
||||
```
|
||||
\end{catala}
|
||||
& Champ de structure
|
||||
\\
|
||||
Appel de fonction & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
f de 44,50€
|
||||
f de 44,50€, 1/3
|
||||
```
|
||||
\end{catala}
|
||||
& Appel de fonction
|
||||
\\
|
||||
Var. de sous-ch. d'app. & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
ss_ch1.var0
|
||||
```
|
||||
\end{catala}
|
||||
& Var. de s/s-ch. d'app.
|
||||
\\
|
||||
Appel direct\newline du champ d'application & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
résultat de ChApp1
|
||||
avec { -- chp1: 9 -- chp2: vrai }
|
||||
résultat de Chp1
|
||||
avec { -- chp1: 9 -- chp2: 15% }
|
||||
```
|
||||
\end{catala}
|
||||
& Appel direct de champ d'application
|
||||
\\
|
||||
Branchement conditionnel & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
si ... alors ... sinon ...
|
||||
```
|
||||
\end{catala}
|
||||
& Branchement
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Déclaration des métadonnées}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
|
||||
Déclaration de structure &
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
déclaration structure Struct1:
|
||||
donnée chp1 contenu entier
|
||||
donnée chp2 contenu booléen
|
||||
donnée chp2 contenu décimal
|
||||
\end{catala}
|
||||
& Déclaration de structure
|
||||
\\
|
||||
Déclaration d'énumération & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
déclaration énumération Énum1:
|
||||
-- Cas1 contenu entier
|
||||
-- Cas2
|
||||
```
|
||||
\end{catala}
|
||||
& Déclaration d'énumération
|
||||
\\
|
||||
Déclaration de champ\newline d'application & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
déclaration champ d'application ChApp1:
|
||||
déclaration champ d'application Chp1:
|
||||
interne var1 contenu entier
|
||||
interne var2 condition
|
||||
ss_ch1 champ d'application ChApp0
|
||||
ss_ch1 champ d'application Chp0
|
||||
```
|
||||
\end{catala}
|
||||
& Déclaration de champ d'application
|
||||
\\
|
||||
Qualificateurs d'entrée-\newline sortie & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
interne var1 contenu ...
|
||||
résultat var3 contenu ...
|
||||
@ -448,38 +470,57 @@
|
||||
contexte résultat var7 contenu ...
|
||||
```
|
||||
\end{catala}
|
||||
& Qualificateurs d'entrée-sortie
|
||||
\\
|
||||
Transitions d'état & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
interne var1 contenu ...
|
||||
état avant
|
||||
état après
|
||||
```
|
||||
\end{catala}
|
||||
& Transitions d'état
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
déclaration const contenu décimal
|
||||
égal à 17.1
|
||||
```
|
||||
\end{catala}
|
||||
& Définition globale
|
||||
\\
|
||||
\begin{catala}
|
||||
```catala
|
||||
déclaration carré contenu décimal
|
||||
dépend de x contenu décimal
|
||||
égal à x * x
|
||||
```
|
||||
\end{catala}
|
||||
& Définition de fonction globale
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Opérations}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
Opérateurs logiques & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
non a
|
||||
a et b
|
||||
non a a et b
|
||||
a ou b # "ou à défaut"
|
||||
a ou bien b # ou exclusif
|
||||
```
|
||||
\end{catala}
|
||||
& Opérateurs logiques
|
||||
\\
|
||||
Arithmétique & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
- a
|
||||
a + b a - b
|
||||
- a a + b a - b
|
||||
a * b a / b
|
||||
```
|
||||
\end{catala}
|
||||
& Arithmétique
|
||||
\\
|
||||
Comparaisons &
|
||||
|
||||
\begin{catala}
|
||||
```catala
|
||||
a = b a != b
|
||||
@ -487,29 +528,32 @@
|
||||
a >= b a <= b
|
||||
```
|
||||
\end{catala}
|
||||
& Comparaisons
|
||||
\\
|
||||
Conversions & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
décimal de 44
|
||||
argent de 23,15
|
||||
```
|
||||
\end{catala}
|
||||
& Conversions
|
||||
\\
|
||||
Arrondis & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
arrondi de 9,99€
|
||||
```
|
||||
\end{catala}
|
||||
& Arrondis
|
||||
\\
|
||||
Éléments de dates & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
accès_jour de ...
|
||||
accès_mois de ...
|
||||
accès_année de ...
|
||||
```
|
||||
\end{catala}
|
||||
& Éléments de dates
|
||||
\\
|
||||
Opérateurs à types\newline explicites &
|
||||
\begin{catala}
|
||||
```catala
|
||||
a +! b # entier
|
||||
@ -518,6 +562,7 @@
|
||||
a +^ b # durée
|
||||
```
|
||||
\end{catala}
|
||||
& Opérateurs à types explicites
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
@ -525,167 +570,190 @@
|
||||
|
||||
\section{Définition de champ d'application}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
Utilisation & \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
champ d'application ChApp1: ...
|
||||
champ d'application Chp1: ...
|
||||
```
|
||||
\end{catala}
|
||||
& Utilisation
|
||||
\\
|
||||
Avec condition générale & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
champ d'application ChApp1
|
||||
champ d'application Chp1
|
||||
sous condition var1 >= 2: ...
|
||||
```
|
||||
\end{catala}
|
||||
& Avec condition générale
|
||||
\\
|
||||
Définition inconditionnelle & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
définition var1 égale à ...
|
||||
définition var1 égal à ...
|
||||
```
|
||||
\end{catala}
|
||||
& Déf. inconditionnelle
|
||||
\\
|
||||
Définition conditionnelle& \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
définition var1
|
||||
sous condition ...
|
||||
conséquence égale à ...
|
||||
conséquence égal à ...
|
||||
```
|
||||
\end{catala}
|
||||
& Définition conditionnelle
|
||||
\\
|
||||
Règle\newline(définition de condition) & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
règle var2
|
||||
sous condition var1 >= 2
|
||||
conséquence rempli
|
||||
```
|
||||
\end{catala}
|
||||
& Règle\newline(définition de condition)
|
||||
\\
|
||||
Règle négative & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
conséquence non rempli
|
||||
```
|
||||
\end{catala}
|
||||
& Règle négative
|
||||
\\
|
||||
Définition de fonction/règle & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
définition f de x égale à ...
|
||||
définition f de x égal à ...
|
||||
```
|
||||
\end{catala}
|
||||
& Déf./règle fonction
|
||||
\\
|
||||
Définition/règle étiquetée & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
étiquette étq1 définition var1 ...
|
||||
```
|
||||
\end{catala}
|
||||
& Déf./règle étiquetée
|
||||
\\
|
||||
Exc. à définition étiquetée & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
exception étq1 définition var1 ...
|
||||
```
|
||||
\end{catala}
|
||||
& Exc. à déf. étiquetée
|
||||
\\
|
||||
Exception à implicite & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
exception définition var1 ...
|
||||
```
|
||||
\end{catala}
|
||||
& Exception à implicite
|
||||
\\
|
||||
Définition d'états & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
définition var1
|
||||
état avant
|
||||
égale à ...
|
||||
égal à ...
|
||||
```
|
||||
\end{catala}
|
||||
& Définition d'états
|
||||
\\
|
||||
Assertion & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
assertion ...
|
||||
```
|
||||
\end{catala}
|
||||
& Assertion
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
\section{Opérations sur les collections}
|
||||
|
||||
\begin{tabular}{@{}p{\cola}p{\colb}@{}}
|
||||
|
||||
Test de présence& \begin{catala}
|
||||
\begin{tabular}{@{}p{\cola}>{\slshape}p{\colb}@{}}
|
||||
\begin{catala}
|
||||
```catala
|
||||
coll contient 3
|
||||
```
|
||||
\end{catala}
|
||||
& Test de présence
|
||||
\\
|
||||
Cardinal & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
nombre de coll
|
||||
```
|
||||
\end{catala}
|
||||
& Cardinal
|
||||
\\
|
||||
Test d'existence & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
existe x parmi coll tel que x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Test d'existence
|
||||
\\
|
||||
Test pour tous & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
pour tout x parmi coll on a x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Test pour tout
|
||||
\\
|
||||
Application un-à-un & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
(x + 2) pour x parmi coll
|
||||
```
|
||||
\end{catala}
|
||||
& Application un-à-un
|
||||
\\
|
||||
Filtrage & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
x parmi coll tel que x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Filtrage
|
||||
\\
|
||||
Filtrage + application & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
(x - 2) pour x parmi coll
|
||||
tel que x >= 2
|
||||
```
|
||||
\end{catala}
|
||||
& Filtrage + application
|
||||
\\
|
||||
Réunion & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
coll1 ++ coll2
|
||||
```
|
||||
\end{catala}
|
||||
& Réunion
|
||||
\\
|
||||
Aggrégation & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
somme entier coll
|
||||
```
|
||||
\end{catala}
|
||||
& Aggrégation
|
||||
\\
|
||||
Comptage & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
nombre de coll
|
||||
```
|
||||
\end{catala}
|
||||
& Comptage
|
||||
\\
|
||||
Extremums & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
maximum de coll
|
||||
ou si collection vide alors -1
|
||||
```
|
||||
\end{catala}
|
||||
& Extremums
|
||||
\\
|
||||
Élément selon extremum & \begin{catala}
|
||||
\begin{catala}
|
||||
```catala
|
||||
x parmi coll
|
||||
tel que (x * x) est minimum
|
||||
ou si collection vide alors -1
|
||||
```
|
||||
\end{catala}
|
||||
& Élément selon extremum
|
||||
\\
|
||||
\end{tabular}
|
||||
|
||||
|
@ -869,7 +869,8 @@ declaration scope WorkdaysPerWeek:
|
||||
scope WorkdaysPerWeek:
|
||||
definition value equals 5
|
||||
|
||||
# Requiring to declare the scope with just an output variable is quite cumbersome, and impedes readability
|
||||
# Requiring to declare the scope with just an output variable is quite
|
||||
# cumbersome, and impedes readability
|
||||
```
|
||||
|
||||
b. The General Lunch Allocation is $2 per workday, over the number of work weeks.
|
||||
|
@ -3,9 +3,17 @@
|
||||
This folder contains a ready-to-use Python library featuring French public
|
||||
algorithms coded up in Catala.
|
||||
|
||||
The Python version expected to run the Python code is above 3.6. For the commands
|
||||
noted below to run, you are expected to setup a virtual Python environment with
|
||||
`virtualenv` by running the `setup_env.sh` script.
|
||||
The Python version expected to run the Python code is above 3.6. For the
|
||||
commands noted below to run, you are expected to setup a virtual Python
|
||||
environment: run `make dependencies-python` from the root of the Catala
|
||||
repository.
|
||||
|
||||
Then activate the environment (needs to be done every time you open a new shell
|
||||
session). From the root of the Catala repository, run the following command:
|
||||
|
||||
```
|
||||
. _python_venv/bin/activate
|
||||
```
|
||||
|
||||
## Organization
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
python3 -m venv env
|
||||
. env/bin/activate
|
||||
make dependencies
|
@ -40,19 +40,20 @@ You can now reload VSCode and check that you have syntax highlighting on any `.c
|
||||
|
||||
## Pygments
|
||||
|
||||
Pygments is a Python-based versatile lexer for various
|
||||
programming languages. To use a version of Pygments
|
||||
augmented with the Catala plugin, simply enter from the root of the repository
|
||||
Pygments is a Python-based versatile lexer for various programming languages. To
|
||||
use a version of Pygments augmented with the Catala plugin, simply enter from
|
||||
the root of the repository
|
||||
|
||||
sudo make pygments
|
||||
make pygments
|
||||
|
||||
This will execute the
|
||||
script `syntax_highlighting/fr/pygments/set_up_pygments.sh`,
|
||||
`syntax_highlighting/pl/pygments/set_up_pygments.sh` and
|
||||
`syntax_highlighting/en/pygments/set_up_pygments.sh`.
|
||||
This will setup a Python virtual environment ("venv"), and install the syntax
|
||||
highlighting plugins that allow Pygments to handle Catala files. Those are
|
||||
defined in `syntax_highlighting/XX/pygments/`.
|
||||
|
||||
The scripts patch your `pygmentize` executable, used for instance by the `minted` LaTeX package.
|
||||
It will now point to the Catala-enabled version with the appropriate `catala_*` lexer.
|
||||
Pygments is used for instance by the `minted` LaTeX package. To make sure it is
|
||||
available, you need to "activate" the python venv each time using:
|
||||
|
||||
. _python_venv/bin/activate
|
||||
|
||||
## GNU gedit
|
||||
|
||||
|
2
syntax_highlighting/en/pygments/.gitignore
vendored
2
syntax_highlighting/en/pygments/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
catala_en_lexer.egg-info
|
||||
__pycache__
|
||||
|
||||
build
|
||||
|
11
syntax_highlighting/en/pygments/pyproject.toml
Normal file
11
syntax_highlighting/en/pygments/pyproject.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "catala_en_lexer"
|
||||
version = "0.8"
|
||||
dependencies = ["pygments"]
|
||||
|
||||
[project.entry-points."pygments.lexers"]
|
||||
catala-en-lexer = "catala_en_lexer.lexer:CatalaEnLexer"
|
@ -1,10 +1,3 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='catala_en_lexer',
|
||||
packages=find_packages(),
|
||||
entry_points="""
|
||||
[pygments.lexers]
|
||||
catala_en_lexer = catala_en_lexer.lexer:CatalaEnLexer
|
||||
""",
|
||||
)
|
||||
setup()
|
||||
|
@ -1,6 +0,0 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
cd pygments && python3 setup.py develop --user
|
@ -216,7 +216,7 @@ code : context {
|
||||
}
|
||||
|
||||
: pattern {
|
||||
regex \= \b(selon|sous\s+forme|fixé|par|décroissante|croissante|varie|avec|on\s+a|soit|dans|champ\s+d'application|dépend\s+de|déclaration|inclusion|contenu|règle|sous\s+condition|condition|donnée|conséquence|rempli|égale\s+à|assertion|définition|état|étiquette|exception)\b
|
||||
regex \= \b(selon|sous\s+forme|fixé|par|décroissante|croissante|varie|avec|on\s+a|soit|dans|champ\s+d'application|dépend\s+de|déclaration|inclusion|contenu|règle|sous\s+condition|condition|donnée|conséquence|rempli|égal\s+à|assertion|définition|état|étiquette|exception)\b
|
||||
styles [] = .keyword_expression ;
|
||||
}
|
||||
|
||||
|
2
syntax_highlighting/fr/pygments/.gitignore
vendored
2
syntax_highlighting/fr/pygments/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
catala_fr_lexer.egg-info
|
||||
__pycache__
|
||||
|
||||
build
|
||||
|
@ -26,7 +26,7 @@ class CatalaFrLexer(RegexLexer):
|
||||
(u'(^```$)', bygroups(String), 'root'),
|
||||
(u'(\\s*\\#.*$)', bygroups(Comment.Single)),
|
||||
(u'(contexte|entr\xe9e|r\xe9sultat|interne)(\\s*)(|r\xe9sultat)(\\s+)([a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7][a-z\xe9\xe8\xe0\xe2\xf9\xee\xf4\xea\u0153\xe7A-Z\xc9\xc8\xc0\xc2\xd9\xce\xd4\xca\u0152\xc70-9_\\\']*)', bygroups(Keyword.Declaration, String, Keyword.Declaration, String, Name.Variable)),
|
||||
(u'\\b(selon|sous\\s+forme|fix\xe9|par|d\xe9croissante|croissante|varie|avec|on\\s+a|soit|dans|champ\\s+d\'application|d\xe9pend\\s+de|d\xe9claration|inclusion|contenu|r\xe8gle|sous\\s+condition|condition|donn\xe9e|cons\xe9quence|rempli|\xe9gale\\s+\xe0|assertion|d\xe9finition|\xe9tat|\xe9tiquette|exception)\\b', bygroups(Keyword.Reserved)),
|
||||
(u'\\b(selon|sous\\s+forme|fix\xe9|par|d\xe9croissante|croissante|varie|avec|on\\s+a|soit|dans|champ\\s+d\'application|d\xe9pend\\s+de|d\xe9claration|inclusion|contenu|r\xe8gle|sous\\s+condition|condition|donn\xe9e|cons\xe9quence|rempli|\xe9gal\\s+\xe0|assertion|d\xe9finition|\xe9tat|\xe9tiquette|exception)\\b', bygroups(Keyword.Reserved)),
|
||||
(u'\\b(contient|nombre|somme|tel\\s+que|existe|pour|tout|de|si|alors|sinon|est|vide|parmi|maximum|minimum|arrondi)\\b', bygroups(Keyword.Declaration)),
|
||||
(u'(\\|[0-9]+\\-[0-9]+\\-[0-9]+\\|)', bygroups(Number.Integer)),
|
||||
(u'\\b(vrai|faux)\\b', bygroups(Keyword.Constant)),
|
||||
|
11
syntax_highlighting/fr/pygments/pyproject.toml
Normal file
11
syntax_highlighting/fr/pygments/pyproject.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "catala_fr_lexer"
|
||||
version = "0.8"
|
||||
dependencies = ["pygments"]
|
||||
|
||||
[project.entry-points."pygments.lexers"]
|
||||
catala-fr-lexer = "catala_fr_lexer.lexer:CatalaFrLexer"
|
@ -1,10 +1,3 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='catala_fr_lexer',
|
||||
packages=find_packages(),
|
||||
entry_points="""
|
||||
[pygments.lexers]
|
||||
catala_fr_lexer = catala_fr_lexer.lexer:CatalaFrLexer
|
||||
""",
|
||||
)
|
||||
setup()
|
||||
|
@ -1,6 +0,0 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
set -ue
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
cd pygments && python3 setup.py develop --user
|
2
syntax_highlighting/pl/pygments/.gitignore
vendored
2
syntax_highlighting/pl/pygments/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
catala_pl_lexer.egg-info
|
||||
__pycache__
|
||||
|
||||
build
|
||||
|
11
syntax_highlighting/pl/pygments/pyproject.toml
Normal file
11
syntax_highlighting/pl/pygments/pyproject.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "catala_pl_lexer"
|
||||
version = "0.8"
|
||||
dependencies = ["pygments"]
|
||||
|
||||
[project.entry-points."pygments.lexers"]
|
||||
catala-pl-lexer = "catala_pl_lexer.lexer:CatalaPlLexer"
|
@ -1,10 +1,3 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='catala_pl_lexer',
|
||||
packages=find_packages(),
|
||||
entry_points="""
|
||||
[pygments.lexers]
|
||||
catala_pl_lexer = catala_pl_lexer.lexer:CatalaPlLexer
|
||||
""",
|
||||
)
|
||||
setup()
|
||||
|
@ -1,6 +0,0 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
cd pygments && python3 setup.py develop --user
|
Loading…
Reference in New Issue
Block a user