352 Commits

Author SHA1 Message Date
Pierre-Marie de Rodat
6e88d6ec25 Lkt: revamp the module system 2026-01-20 16:03:43 +00:00
Romain Beguet
35222957e4 Implement partial reformatting. 2026-01-06 13:50:45 +00:00
Romain Beguet
7fa486f689 Allow defining language-specific format options. 2026-01-06 13:50:45 +00:00
Pierre-Marie de Rodat
0844481e22 Generic API: add accessors for type/member documentation 2026-01-05 10:34:07 +00:00
Pierre-Marie de Rodat
35c8546082 Add missing comparison operators for token references 2026-01-05 10:29:08 +00:00
Romain Beguet
895105b7cc Unparsing: fix the preservation of leading/trailing separators. 2025-10-21 14:22:43 +02:00
Pierre-Marie de Rodat
b385ef9d23 Unparsing: introduce the "independent_lines" setting
Note that this only introduces the setting itself: it is unused during
rewriting for now.
2025-10-03 08:08:07 +00:00
Pierre-Marie de Rodat
be0ff804da Rewriting: rewriting error on unexpected unparsed tree shape
When applying rewriting modifications, stop with an error when the tree
obtained by parsing the unparsed rewriting tree does not have the exact
same shape as the rewriting tree itself.
2025-09-30 13:29:31 +00:00
Pierre-Marie de Rodat
2d724fefce Rewriting: add a debug helper for node rewriting handles 2025-09-30 13:29:31 +00:00
Pierre-Marie de Rodat
ca14bc4b6e Unparsing: fix handling of trailing whitespaces in comments 2025-07-21 12:04:12 +00:00
Pierre-Marie de Rodat
5db4853f97 Unparsing: reject node configs for error nodes and synthetic nodes 2025-07-08 08:52:26 +00:00
Pierre-Marie de Rodat
84f0666890 Rework how token equivalence works
For tokens matched by literals only (like keywords), only compare the
kind. For `@symbol` tokens (generally matched by patterns), also compare
the symbol. For all the other tokens, keep comparing the actual token
text.
2025-07-03 12:49:02 +00:00
Pierre-Marie de Rodat
ab5963d2ca Unparsing: use "recurse_field" templates for all regular nodes
Continue accepting "recurse" templates when loading the "node"
configuration for regular nodes, but convert them to the equivalent
"recurse_field" templates internally.

This allows doing this conversion (expansion to the concrete syntax for
regular nodes) only once per regular node type, versus once per template
insantiation (i.e. one per regular node found in the parse tree). This
is a minor optimization right now, but will later also allow to
pre-compute the Prettier IR for tokens in the configuration directly
rather than during template instantiation.
2025-07-02 14:54:47 +00:00
Pierre-Marie de Rodat
8060438b64 Rewriting: add safety nets to the public API to detect stale handle refs 2025-05-21 08:49:08 +00:00
Pierre-Marie de Rodat
22e61ecc4d Rewriting: add precondition checks for context consistency 2025-05-21 08:49:08 +00:00
Pierre-Marie de Rodat
d3e5ee5b61 ada_api/rewriting: minor refactoring 2025-05-21 08:49:08 +00:00
Pierre-Marie de Rodat
50f50f9f85 Generic API: add bindings for the rewriting features
Move the implementation of the rewriting engine to Langkit_Support and
add bindings to it in the generic API. Rework the C bindings to be
implemented on top of the generic API.

Note that no new testcase is added: the generic API is tested indirectly
by all existing rewriting testcases by the virtue of being the
common implementation behind all the other rewriting APIs. The Ada API
testcase will transition to the generic API once the Ada API is removed.
2025-05-21 08:49:08 +00:00
Pierre-Marie de Rodat
e116416bde ada_api/generic_api: update test baseline 2025-04-16 07:37:06 +00:00
Pierre-Marie de Rodat
b3aa67c8b5 Lkt: reject null parse fields when they contain list/qualifier nodes
Parse fields that contain list nodes or qualifier nodes are never
supposed to contain actual null nodes, but empty lists/absent qualifier
nodes instead. However, declaring null fields removes storage for them,
and thus makes the getters return null nodes in the generated libraries,
which is inconsistent.

Reject these null parse fields to avoid this inconsistency. Rework
Liblktlang and the `ada_api/rewriting` testcase to avoid this.
2025-04-16 06:14:40 +00:00
Pierre-Marie de Rodat
9a80a9a365 Generic API: add defensive code for error cases in unparsing 2025-04-16 06:14:26 +00:00
Pierre-Marie de Rodat
37791c250d Generic API: add converters for concrete node types 2025-04-16 06:14:15 +00:00
Pierre-Marie de Rodat
cfd545d2fa Generic API: add the Is_Error_Node type reference primitive 2025-04-16 06:14:00 +00:00
Pierre-Marie de Rodat
259a1317dc CompiledType.dsl_name: switch to Lkt notations
Also rename `dsl_*` properties, attributes, arguments, ... to `lkt_*`
for consistency.
2025-04-04 09:55:05 +00:00
Pierre-Marie de Rodat
6cefc74c93 Set up pre-commit checks and reformat the Python sources with black 2025-03-26 14:04:20 +00:00
Pierre-Marie de Rodat
c5a89de2bd Remove processings of enum types from CompiledTypeRepo
Note that this fixes the sorting of enum types by name. It used to be
done only during the `CompileTypeRepo -> CompileCtx` transition, and tha
transition used to happen before all enum types were known.
2025-03-24 15:39:29 +00:00