The upcoming revamp of Lkt modules will make it impossible to have
multiple Lkt source files share common declarations (`common_*.lkt`)
with bi-directional references: the individual sources can import
entities from the definite `common_*` modules, but the common modules
do not have a specific module for their own imports.
To overcome this, extend the `lkt_compile.py` script so that it
considers `test.lkt` sources in test subdirectories, and arrange for the
Lkt source path to make the top-level directory available: this will
allow test files to all have the same name (they will be in separate
directories), and so the common files will have a specific module name
to use for imports.
Also rework lkt_compile and lkt_build_and_run test drivers so that the
language spec configuration bits are stored in the testcase's test.yaml
file directly: no need to add glue code in various places (test driver,
lkt_compile.py/lkt_build_and_run.py scripts) to support a new kind of
language spec configuration.
Replace the messy collection of arguments for CompileCtx.__init__ and
CompileCtx.create_all_passes with better organized dataclasses in the
new langkit.config module. Update the codebase to use these data
structures.
Rework the formatting for the listing of optional passes, refactor the
handling of --pass-on/--pass-off (to enable/disable optional passes), fix
a couple of crashes and add a testcase to exercise this little used part
of Langkit.
Whether unparsers are generated or not has implications on legality
checks for the grammar, so it makes sense for this to be a property of
the grammar itself: introduce an Lkt annotation as well as a
langkit.parsers.Grammar argument for it, and remove the corresponding
CompileCtx argument.
Also rename "generate_unparser" to "generate_unparsers" for consistency
across the codebase.
When debugging a testcase that contains multiple "*.lkt" files, it is
sometimes convenient to run the "lkt_compile.py" script on a single
source file. This commit extends this script to accept "lkt entry
points" as command line arguments.
All tests which just check the presence/absence of errors when compiling
Lkt language specs have the same "test.py" script: put a reference
script in "python_support", create a new test driver to let tests use
it easily and migrate relevant tests to it.
For GitHub issue #622