catala/compiler/shared_ast
Louis Gesbert b9156bb60e Implement safe renaming of idents for backend printing
Previously we had some heuristics in the backends trying to achieve this with a
lot of holes ; this should be much more solid, relying on `Bindlib` to do the
correct renamings.

**Note1**: it's not plugged into the backends other than OCaml at the moment.

**Note2**: the related, obsolete heuristics haven't been cleaned out yet

**Note3**: we conservatively suppose a single namespace at the moment. This is
required for e.g. Python, but it forces vars named like struct fields to be
renamed, which is more verbose in e.g. OCaml. The renaming engine could be
improved to support different namespaces, with a way to select how to route the
different kinds of identifiers into them.

Similarly, customisation for what needs to be uppercase or lowercase is not
available yet.

**Note4**: besides excluding keywords, we should also be careful to exclude (or
namespace):
- the idents used in the runtime (e.g. `o_add_int_int`)
- the dynamically generated idents (e.g. `embed_*`)

**Note5**: module names themselves aren't handled yet. The reason is that they
must be discoverable by the user, and even need to match the filenames, etc. In
other words, imagine that `Mod` is a keyword in the target language. You can't
rename a module called `Mod` to `Mod1` without knowing the whole module context,
because that would destroy the mapping for a module already called `Mod1`.

A reliable solution would be to translate all module names to e.g.
`CatalaModule_*`, which we can assume will never conflict with any built-in, and
forbid idents starting with that prefix. We may also want to restrict their
names to ASCII ? Currently we use a projection, but what if I have two modules
called `Là` and `La` ?
2024-08-28 17:18:26 +02:00
..
boundList.ml Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
boundList.mli Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
definitions.ml Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
dune Fix most doc errors 2023-06-02 17:17:45 +02:00
expr.ml Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
expr.mli Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
interpreter.ml Remove RaiseEmpty and CatchEmpty from the AST 2024-07-04 15:08:13 +02:00
interpreter.mli Remove RaiseEmpty and CatchEmpty from the AST 2024-07-04 15:08:13 +02:00
operator.ml Replace HandleDefault* internal operators by HandleExceptions 2024-07-04 15:08:13 +02:00
operator.mli More precise positions for operators throughout 2024-04-30 16:35:08 +02:00
optimizations.ml Remove RaiseEmpty and CatchEmpty from the AST 2024-07-04 15:08:13 +02:00
optimizations.mli Remove RaiseEmpty and CatchEmpty from the AST 2024-07-04 15:08:13 +02:00
print.ml Small printer fix 2024-07-05 18:03:01 +02:00
print.mli Remove obsolete "except" type from the interpreter 2024-04-29 13:42:40 +02:00
program.ml Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
program.mli Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
qident.ml Add some helper functions in a wrapper Map module 2023-07-12 11:51:15 +02:00
qident.mli Some commented code cleanup and clarifications 2023-06-19 16:36:09 +02:00
scope.ml Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
scope.mli Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
shared_ast.ml Generalise the definition of lists of nested binders 2024-02-09 18:33:41 +01:00
shared_ast.mld Fix most doc errors 2023-06-02 17:17:45 +02:00
type.ml Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
type.mli Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
typing.ml Implement safe renaming of idents for backend printing 2024-08-28 17:18:26 +02:00
typing.mli Reformat 2024-06-21 12:23:01 +02:00
var.ml Preserve and propagate types through closure conversion 2024-05-30 17:00:07 +02:00
var.mli Preserve and propagate types through closure conversion 2024-05-30 17:00:07 +02:00