1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586(* This file is part of the Catala compiler, a specification language for tax
and social benefits computation rules. Copyright (C) 2024 Inria,
contributors: Louis Gesbert <louis.gesbert@inria.fr>
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License. *)typefile=stringtyperaw_file=filetypebackend_lang=En|Fr|Pltypewhen_enum=Auto|Always|Nevertypemessage_format_enum=Human|GNUtype'fileinput_src=|FileNameof'file|Contentsofstring*'file|Stdinof'file(* ['file] is expected to be [file] or [raw_file] *)typeoptions={mutableinput_src:fileinput_src;mutablelanguage:backend_langoption;mutabledebug:bool;mutablecolor:when_enum;mutablemessage_format:message_format_enum;mutabletrace:bool;mutableplugins_dirs:filelist;mutabledisable_warnings:bool;mutablemax_prec_digits:int;mutablepath_rewrite:raw_file->file;}(* Note: we force that the global options (ie options common to all commands)
and the options available through global refs are the same. While this is a
bit arbitrary, it makes some sense code-wise and provides some safeguard
against explosion of the number of global references. Reducing the number of
globals further would be nice though. *)letoptions={input_src=Stdin"-stdin-";language=None;debug=false;color=Auto;message_format=Human;trace=false;plugins_dirs=[];disable_warnings=false;max_prec_digits=20;path_rewrite=(fun_->assertfalse);}letenforce_options?input_src?language?debug?color?message_format?trace?plugins_dirs?disable_warnings?max_prec_digits?path_rewrite()=Option.iter(funx->options.input_src<-x)input_src;Option.iter(funx->options.language<-x)language;Option.iter(funx->options.debug<-x)debug;Option.iter(funx->options.color<-x)color;Option.iter(funx->options.message_format<-x)message_format;Option.iter(funx->options.trace<-x)trace;Option.iter(funx->options.plugins_dirs<-x)plugins_dirs;Option.iter(funx->options.disable_warnings<-x)disable_warnings;Option.iter(funx->options.max_prec_digits<-x)max_prec_digits;Option.iter(funx->options.path_rewrite<-x)path_rewrite;optionsletinput_src_file=functionFileNamef|Contents(_,f)|Stdinf->fletraw_filef=f