Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout du mot-clé "evenement" #248

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cf541fe
Ajout du mot-clé "evenement"
david-michel1 Dec 10, 2024
8d2cee7
Déclaration des événements
david-michel1 Dec 12, 2024
9812acd
Événements pour l'interpréteur
david-michel1 Dec 12, 2024
d9d85eb
Événements pour le backend C
david-michel1 Dec 17, 2024
ad51e69
Itérateurs numérique (instable).
david-michel1 Jan 13, 2025
1a8fea0
Taille des piles d'exécution (instable)
david-michel1 Jan 14, 2025
655b2f7
Dimensionnement des piles d'exécution des variables.
david-michel1 Jan 15, 2025
6aea338
Itérateur sur les valeurs.
david-michel1 Jan 16, 2025
2ed57c8
Fonction nb_evenements pour l'interpréteur
david-michel1 Jan 20, 2025
297bfed
Accesseurs pour les événements.
david-michel1 Jan 21, 2025
2621cc0
Assignation dynamique des champs des événements.
david-michel1 Jan 21, 2025
c85d473
Amélioration de la gestion des événements.
david-michel1 Jan 22, 2025
e26fd33
Arrangement des événements (en cours).
david-michel1 Jan 23, 2025
6cbc4ba
Intruction d'arrangement des exceptions (en cours).
david-michel1 Jan 23, 2025
ad82995
Arrangement des événements, suite.
david-michel1 Jan 24, 2025
14cbd60
Arrange événements
david-michel1 Jan 28, 2025
443b0b9
Arrange événements (correction)
david-michel1 Jan 28, 2025
4521c45
Restauration des événements (listes).
david-michel1 Jan 28, 2025
286150f
Restauration des événements (prédicats).
david-michel1 Jan 30, 2025
1e016c2
Amélioration de la lisibilité du code C
david-michel1 Jan 30, 2025
3bbc9bf
Ajout d'événements (instable)
david-michel1 Jan 30, 2025
7fdd458
Ajouter des événements.
david-michel1 Jan 30, 2025
8ebd944
Mise à jour des références de variables dans les événements.
david-michel1 Jan 31, 2025
8fbab01
Extension des variables avec des références (partiel)
david-michel1 Feb 3, 2025
044f798
Accès aux références de variables dans les champs des événements (par…
david-michel1 Feb 4, 2025
eeb5e27
Gestion des événements
david-michel1 Feb 6, 2025
8eb7e7f
Lecture des fichers de test correctifs
david-michel1 Feb 11, 2025
21b45ca
Pseudo-rebase à la main
david-michel1 Feb 13, 2025
8c0680f
Suppression de "#define BATCH"
david-michel1 Feb 17, 2025
ba41a1d
Merge commit '4797c03c0c37322c1f01dee98b0783afb1b7905d' into extensio…
david-michel1 Feb 18, 2025
ba61112
Merge remote-tracking branch 'origin/master' into extension_correctif
david-michel1 Feb 18, 2025
fad33d3
Correction de l'accès aux tableaux en C.
david-michel1 Feb 18, 2025
770b746
Corrections syntaxiques.
david-michel1 Feb 18, 2025
389fae4
Adaptations pour 2024.
david-michel1 Feb 18, 2025
60cd65f
Racourcissement des noms des fichiers "varinfo_*.c"
david-michel1 Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/binary-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ jobs:

linux-build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
needs: create-release

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Opam modules cache
uses: actions/cache@v1
uses: actions/cache@v4
env:
cache-name: cache-opam-modules
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check_correctness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Opam modules cache
uses: actions/cache@v1
uses: actions/cache@v4
env:
cache-name: cache-opam-modules
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Opam modules cache
uses: actions/cache@v1
uses: actions/cache@v4
env:
cache-name: cache-opam-modules
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ default: FORCE build

all: FORCE quick_test tests test_dgfip_c_backend

clean: FORCE
clean: FORCE remise_a_zero_versionnage
$(call make_in,$(DGFIP_DIR),clean_backend_all)
rm -f doc/doc.html
dune clean
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(name mlang)

(version 1.1.0)
(version %%VERSION%%)

(generate_opam_files true)

Expand Down
11 changes: 11 additions & 0 deletions examples/dgfip_c/ml_primitif/ml_driver/common.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
module StrSet = Set.Make(String)
module StrMap = Map.Make(String)

type rappel =
float
* float
* string
* float
* float
* float option
* float option
* float
* float option

15 changes: 15 additions & 0 deletions examples/dgfip_c/ml_primitif/ml_driver/m.ml
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,19 @@ external get_err_list : TGV.t -> string list = "ml_get_err_list"
external annee_calc : unit -> int = "ml_annee_calc"
external export_errs : TGV.t -> unit = "ml_export_errs"
external enchainement_primitif : TGV.t -> unit = "ml_enchainement_primitif"
external set_evt_list :
TGV.t
-> (
float
* float
* string
* float
* float
* float option
* float option
* float
* float option
) list
-> unit
= "ml_set_evt_list"

135 changes: 94 additions & 41 deletions examples/dgfip_c/ml_primitif/ml_driver/main.ml
Original file line number Diff line number Diff line change
@@ -1,31 +1,72 @@
open Common

type instance = {
nom : string;
label : string;
vars : float StrMap.t;
events : rappel list;
expectedVars : float StrMap.t;
expectedAnos : StrSet.t;
}

let new_instance nom = {
nom;
label = "";
vars = StrMap.empty;
events = [];
expectedVars = StrMap.empty;
expectedAnos = StrSet.empty;
}

let read_test filename =
let test = Read_test.read_test filename in
let tgv = M.TGV.alloc_tgv () in
let res_prim, ctl_prim =
let fold_prim (res_prim, ctl_prim) s =
match s with
| `EntreesPrimitif pl ->
List.iter (fun (code, montant) -> M.TGV.set tgv code montant) pl;
res_prim, ctl_prim
| `ResultatsPrimitif pl ->
let res_prim =
let fold res (code, montant) = StrMap.add code montant res in
List.fold_left fold res_prim pl
in
res_prim, ctl_prim
| `ControlesPrimitif el ->
let ctl_prim =
let fold err e = StrSet.add e err in
List.fold_left fold ctl_prim el
in
res_prim, ctl_prim
| _ -> res_prim, ctl_prim
in
List.fold_left fold_prim (StrMap.empty, StrSet.empty) test
let fold_prim (nom, inst, insts) s =
match s with
| `Nom noms ->
let nom = String.concat " " noms in
let inst = {inst with nom} in
let insts = List.map (fun i -> {i with nom}) insts in
(nom, inst, insts)
| `EntreesPrimitif pl ->
let vars =
let fold res (code, montant) = StrMap.add code montant res in
List.fold_left fold StrMap.empty pl
in
(nom, {inst with vars}, insts)
| `ControlesPrimitif el ->
let expectedAnos =
let fold err e = StrSet.add e err in
List.fold_left fold StrSet.empty el
in
(nom, {inst with expectedAnos}, insts)
| `ResultatsPrimitif pl ->
let expectedVars =
let fold res (code, montant) = StrMap.add code montant res in
List.fold_left fold StrMap.empty pl
in
let inst = {inst with label = "primitif"; expectedVars} in
(nom, new_instance nom, inst :: insts)
| `EntreesCorrectif _
| `ControlesCorrectif _
| `ResultatsCorrectif _ -> (nom, inst, insts)
| `EntreesRappels events -> (nom, {inst with events}, insts)
| `ControlesRappels el ->
let expectedAnos =
let fold err e = StrSet.add e err in
List.fold_left fold StrSet.empty el
in
(nom, {inst with expectedAnos}, insts)
| `ResultatsRappels pl ->
let expectedVars =
let fold res (code, montant) = StrMap.add code montant res in
List.fold_left fold StrMap.empty pl
in
let inst = {inst with label = "correctif"; expectedVars} in
(nom, new_instance nom, inst :: insts)
| `Skip -> (nom, inst, insts)
in
tgv, res_prim, ctl_prim
let _, _, insts = List.fold_left fold_prim ("", new_instance "", []) test in
insts

let check_result tgv err expected_tgv expected_err =
let result = ref true in
Expand Down Expand Up @@ -130,24 +171,36 @@ let compare_dump out outexp =
let run_test test_file annee_exec =
Printf.printf "Testing %s...\n%!" test_file;
let annee_calc = M.annee_calc () in
let tgv, res_prim, ctl_prim = read_test test_file in
let annee_revenu = M.TGV.get_int_def tgv "ANREV" annee_calc in
if annee_revenu <> annee_calc then (
Printf.eprintf
"Attention, année calculette (%d) <> année revenu (%d)\n%!"
annee_calc
annee_revenu
);
M.TGV.set_int tgv "IND_TRAIT" 4 (* = primitif *);
M.TGV.set_int tgv "ANCSDED" annee_exec;
M.init_errs tgv;
let _err = M.enchainement_primitif tgv in
M.export_errs tgv;
let err_set =
let add res e = StrSet.add e res in
List.fold_left add StrSet.empty (M.get_err_list tgv)
let insts = read_test test_file in
let rec run_insts res = function
| [] -> res
| inst :: insts ->
Printf.printf " Running %s:%s...\n%!" inst.nom inst.label;
let tgv = M.TGV.alloc_tgv () in
StrMap.iter (M.TGV.set tgv) inst.vars;
M.set_evt_list tgv inst.events;
let annee_revenu = M.TGV.get_int_def tgv "ANREV" annee_calc in
if annee_revenu <> annee_calc then (
Printf.eprintf
"Attention, année calculette (%d) <> année revenu (%d)\n%!"
annee_calc
annee_revenu
);
(match inst.label with
| "primitif" -> M.TGV.set_int tgv "IND_TRAIT" 4
| "correctif" -> M.TGV.set_int tgv "IND_TRAIT" 5
| _ -> M.TGV.set_int tgv "IND_TRAIT" 0);
M.TGV.set_int tgv "ANCSDED" annee_exec;
M.init_errs tgv;
let _err = M.enchainement_primitif tgv in
M.export_errs tgv;
let err_set =
let add res e = StrSet.add e res in
List.fold_left add StrSet.empty (M.get_err_list tgv)
in
res && check_result tgv err_set inst.expectedVars inst.expectedAnos
in
check_result tgv err_set res_prim ctl_prim
run_insts true insts

let main () =
if Array.length Sys.argv < 2 then (
Expand Down Expand Up @@ -175,7 +228,7 @@ let main () =
let rec loop = function
| [] -> true
| test_file :: files ->
run_test test_file annee_exec && ((* Gc.minor ();*) loop files)
run_test test_file annee_exec && (Gc.minor (); loop files)
in
match loop test_files with
| true -> exit 0
Expand Down
36 changes: 29 additions & 7 deletions examples/dgfip_c/ml_primitif/ml_driver/read_test.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Common

type file = {
c: in_channel;
mutable lines: string list;
Expand All @@ -21,14 +23,17 @@ let convert_int s = try int_of_string s with _ -> 0

let convert_float s =
try Float.of_string s
(* with _ -> 0.0 *)
with _ -> (* to cope with badly formatted tests *)
try Float.of_string
(String.sub s 0
(String.index_from s
((String.index s '.') + 1) '.'))
with _ -> 0.0

let convert_float_opt s =
let rec isSpc i = i < 0 || (s.[i] = ' ' && isSpc (i - 1)) in
if isSpc (String.length s - 1) then None else Some (convert_float s)

let parse_generic s =
let sl = String.split_on_char '/' s in
match sl with
Expand All @@ -55,16 +60,33 @@ let parse_entree_corr s =
| _ -> failwith (Printf.sprintf "Ligne entree correctif invalide: '%s'" s)

let parse_entree_rap s =
let err () = failwith (Printf.sprintf "Ligne entree rappel invalide: '%s'" s) in
let sl = String.split_on_char '/' s in
match sl with
| [ num_evt; num_rappel; code; montant; sens;
penalite; base_tl; date_evt; ind20 ] ->
let date_evt = convert_int date_evt in
(convert_int num_evt, convert_int num_rappel,
code, convert_float montant, sens.[0],
convert_int penalite, convert_float base_tl,
(date_evt mod 10000, date_evt / 10000), String.equal ind20 "1") (* TODO: improve *)
| _ -> failwith (Printf.sprintf "Ligne entree rappel invalide: '%s'" s)
if String.length code = 0 then err ();
let sens_float =
if String.length sens = 0 then err ();
match sens.[0] with
| 'R' -> 0.0
| 'C' -> 1.0
| 'M' -> 2.0
| 'P' -> 3.0
| _ -> err ()
in
(
convert_float num_evt,
convert_float num_rappel,
code,
convert_float montant,
sens_float,
convert_float_opt penalite,
convert_float_opt base_tl,
convert_float date_evt,
convert_float_opt ind20
) (* TODO: improve *)
| _ -> err ()

let read_section_contents f parsefun =
let rec aux contents =
Expand Down
Loading