package catala
Module Surface.Parser_driverSource
Wrapping module around parser and lexer that offers the Surface.Parser_driver.parse_source_file API.
val lines :
Catala_utils.File.t ->
Catala_utils.Global.backend_lang ->
(string * Lexer_common.line_token * (Lexing.position * Lexing.position))
Seq.tRaw file parser that doesn't interpret any includes and returns the flat law structure as is
val load_interface :
?default_module_name:string ->
is_stdlib:bool ->
Catala_utils.File.t Catala_utils.Global.input_src ->
Ast.module_contentReads only declarations in metadata in the supplied input file, and only keeps type information. The list of submodules is initialised with names only and empty contents.
val load_interface_and_code :
?default_module_name:string ->
is_stdlib:bool ->
Catala_utils.File.t Catala_utils.Global.input_src ->
Ast.module_contentReads the supplied input file and returns its interface that contains type information as well as scope and topdef definitions. The list of submodules is initialised with names only and empty contents.
val register_included_file_resolver :
filename:string ->
new_content:string Catala_utils.Global.input_src ->
unitRegister an included file dynamic resolver. When the surface's parser encounters an inclusion that correspond to the filename argument, it will dynamically replace it with the given new_content.
type module_loading =
allow_notmodules:bool ->
is_stdlib:bool ->
Catala_utils.Global.options ->
string ->
Ast.module_contentLoad a single module content
type module_candidates =
(Shared_ast.ModuleName.t * Ast.module_content) Lazy.t Catala_utils.File.Map.t
Shared_ast.Ident.Map.tval load_included_modules :
Catala_utils.Global.options ->
includes:Catala_utils.Global.raw_file list ->
stdlib:Catala_utils.Global.raw_file option ->
?more_includes:string list ->
?allow_notmodules:bool ->
?load_module:module_loading ->
unit ->
module_candidatesComputes the lazy module candidate map that are used in the resolution of a module usage to an included file. This map may be re-used with load_modules_with_candidates.
val load_modules :
Catala_utils.Global.options ->
Catala_utils.Global.raw_file list ->
stdlib:Catala_utils.Global.raw_file option ->
?more_includes:string list ->
?allow_notmodules:bool ->
Ast.program ->
Shared_ast.ModuleName.t Shared_ast.Ident.Map.t
* (Ast.module_content * Shared_ast.ModuleName.t Shared_ast.Ident.Map.t)
Shared_ast.ModuleName.Map.tRetrieve and load modules contents necessary to compile the given program
val load_modules_with_candidates :
Catala_utils.Global.options ->
stdlib:Catala_utils.Global.raw_file option ->
module_candidates ->
Ast.program ->
Shared_ast.ModuleName.t Shared_ast.Ident.Map.t
* (Ast.module_content * Shared_ast.ModuleName.t Shared_ast.Ident.Map.t)
Shared_ast.ModuleName.Map.tSame as load_modules but with an existing module_candidates.
val parse_top_level_file :
?resolve_included_file:(string -> string Catala_utils.Global.input_src) ->
Catala_utils.File.t Catala_utils.Global.input_src ->
Ast.programParses a catala file (handling file includes) and returns a program. Interfaces of the used modules are returned empty, use load_interface to fill them. When provided resolve_included_file replaces file includes with an user provided input source. However, it will shadow any existing dynamic resolver registered using register_included_file_resolver.