-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a small standalone module for IRJ file validation (#236)
This module uses the Mlang parser to display lexing and parsing errors associated to a test file at DGFiP IRJ format.
- Loading branch information
Showing
6 changed files
with
104 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
version: "1.1.0" | ||
synopsis: "Parser for the IRJ tests" | ||
synopsis: "IRJ test validation tool" | ||
description: | ||
"This parser is aimed for the tests used by la DGFiP to test the calculation of the French income tax" | ||
"This standalone module performs a syntactic validation of the DGFiP IRJ test format" | ||
maintainer: ["[email protected]"] | ||
authors: ["Denis Merigoux" "Raphaël Monat"] | ||
license: "GPL-3.0-or-later" | ||
homepage: "https://gitlab.inria.fr/verifisc/mlang" | ||
bug-reports: "https://gitlab.inria.fr/verifisc/mlang/issues" | ||
homepage: "https://github.com/MLanguage/mlang" | ||
bug-reports: "https://github.com/MLanguage/mlang/issues" | ||
depends: [ | ||
"ocaml" {>= "4.11.2"} | ||
"dune" {build} | ||
|
@@ -29,4 +29,4 @@ build: [ | |
"@doc" {with-doc} | ||
] | ||
] | ||
dev-repo: "git+https://gitlab.inria.fr/verifisc/mlang.git" | ||
dev-repo: "git+https://github.com/MLanguage/mlang.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ before translating it into various backend languages. | |
maintainer: ["[email protected]"] | ||
authors: ["Denis Merigoux" "Raphaël Monat"] | ||
license: "GPL-3.0-or-later" | ||
homepage: "https://gitlab.inria.fr/verifisc/mlang" | ||
bug-reports: "https://gitlab.inria.fr/verifisc/mlang/issues" | ||
homepage: "https://github.com/MLanguage/mlang" | ||
bug-reports: "https://github.com/MLanguage/mlang/issues" | ||
depends: [ | ||
"ocaml" {>= "4.11.2"} | ||
"dune" {build} | ||
|
@@ -42,4 +42,4 @@ build: [ | |
"@doc" {with-doc} | ||
] | ||
] | ||
dev-repo: "git+https://gitlab.inria.fr/verifisc/mlang.git" | ||
dev-repo: "git+https://github.com/MLanguage/mlang.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(env | ||
(dev | ||
(flags | ||
(:standard -warn-error -A)))) | ||
|
||
(executable | ||
(name irj_checker) | ||
(package irj_checker) | ||
(public_name irj_checker) | ||
(libraries mlang)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
(* Copyright (C) 2023-2024 DGFiP, contributor: David Declerck, Mathieu Durero | ||
This program is free software: you can redistribute it and/or modify it under | ||
the terms of the GNU General Public License as published by the Free Software | ||
Foundation, either version 3 of the License, or (at your option) any later | ||
version. | ||
This program is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
details. | ||
You should have received a copy of the GNU General Public License along with | ||
this program. If not, see <https://www.gnu.org/licenses/>. *) | ||
|
||
(** The Irj_checker Module is a simple entry point to use the Mlang IRJ file | ||
parser in order to perform syntactic checks on test files. | ||
Usage: irj_checker.exe <test_file.irj>*) | ||
|
||
let () = | ||
if Array.length Sys.argv <> 2 then ( | ||
Printf.eprintf "This program requires a test file as argument\n"; | ||
exit 1); | ||
let f = Sys.argv.(1) in | ||
let _tf = | ||
try Mlang.Irj_file.parse_file f with | ||
| Mlang.Irj_ast.TestParsingError (s, pos) -> | ||
let pos_1, pos_2 = pos.pos_loc in | ||
Printf.eprintf "%s" (Filename.basename f); | ||
Printf.eprintf ":(%d,%d)-(%d,%d)" pos_1.pos_lnum | ||
(pos_1.pos_cnum - pos_1.pos_bol + 1) | ||
pos_2.pos_lnum | ||
(pos_2.pos_cnum - pos_2.pos_bol + 1); | ||
Printf.eprintf " : %s\n" s; | ||
exit 1 | ||
| _ -> | ||
Printf.eprintf "%s" (Filename.basename f); | ||
Printf.eprintf " : Unknown error\n"; | ||
exit 1 | ||
in | ||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters