29 Commits

Author SHA1 Message Date
Pierre-Marie de Rodat
7235199b71 lkt_toolbox: hide type info for modules (always null) 2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
d674f8ab4d Liblktlang: override referenced_decl for ImportedId
Also extend lkt_toolbox to exercise it.
2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
5ff4e084d7 Enhance lkt_toolbox to exercise ModuleId.referenced_decl
Also extend lkt_toolbox to exercise it.
2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
c7bc0ca99c Liblktlang: rework properties used to handle prelude entities
Move/rename `LangkitRoot.fetch_prelude` to `LktNode.prelude_unit` so
that this property is easily available from all nodes and so that its
name is more "getter-like".

Also introduce the `LktNode.is_from_prelude` to simplify the codebase.
2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
556e670d30 Liblktlang: make LangkitRoot derive Decl
`LangkitRoot` nodes now define modules, so they must be treated as
declarations for these modules. This is necessary for the semantic
analysis to allow named references to Lkt modules.
2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
58598281ed lkt_toolbox: make it possible to extend Lkt lookup path on the cmd line 2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
09dfe3691c lkt_toolbox: add code completion capabilities
This will make it easier to debug code completion features from
Liblktlang.
2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
967577513e lkt_toolbox: widen use of P_Custom_Image to all identifiers
There is no reason to restrict it to `Ref_Id` nodes, since this property
is defined on `Id` itself.
2026-02-12 11:48:42 +00:00
Pierre-Marie de Rodat
6ce4b119fa lkt_toolbox: minor reformattings/refactorings 2026-02-12 11:48:42 +00:00
Killian Perlin
53a7f2540e lkt: Match liblkqllang parse-tree shape for patterns
This commit is a "backport" of the recent changes in the LKQL pattern
syntax to the lkt pattern syntax.

Unused features, deprecated constructs where removed and the parse-tree
was flattened to simplify lowering.

See langkit-query-language#597 and langkit-query-language#596 for more
details.
2026-01-29 13:33:06 +00:00
Pierre-Marie de Rodat
75309c8a14 Lkt: handle renaming parts in import clauses 2026-01-20 16:03:43 +00:00
Pierre-Marie de Rodat
6e88d6ec25 Lkt: revamp the module system 2026-01-20 16:03:43 +00:00
Pierre-Marie de Rodat
68f1debb86 Liblktlang: introduce module-level doc strings 2026-01-20 16:03:43 +00:00
Pierre-Marie de Rodat
74388746c7 Python API: make it possible to create custom unit providers 2026-01-14 15:03:45 +00:00
Killian Perlin
5e9e82b751 Frontend implementation for query comprehension 2025-11-26 11:08:18 +00:00
Raphaël AMIARD
daf063fee3 Refactor lexer/parser rules grammar
* Make the grammar less ambiguous by changing the syntax of the lexer's
  forward declartion from `Foo` to `Foo <- null`

* This in turn allows the sharing of the `decl` grammar rule in the
  grammar, simplifying the grammar and allowing the production of better
  error messages.

* The lexer_decl rule is simplified (lexer_family_decl occured twice)

* GrammarNull is allowed to not have a type suffix
2025-10-21 13:25:04 +00:00
Pierre-Marie de Rodat
37c69d7f80 Lkt: add error recovery to the parsing of block expression
Introduce a new node (`BlockExprClause`) so that:

1. The `;` token belongs to list items in block expressions rather than
   being a separator for that list.

2. The inner expression in block exprs belongs to that list, so that
   there is no `;` token parser that follows the parser for that list.

The conjunction of both points allows us to introduce `skip`/`dont_skip`
parser for error recovery in the parsing of block expressions. The extra
sources that are accepted by the new parser are rejected by the Lkt
frontend.

Note that, due to a Langkit parser bug (likely
eng/libadalang/langkit#652), sometimes there is no parsing error even
though the parse tree contains an error node. This should be addressed
later.
2025-07-09 09:25:10 +00:00
Remi Segard
4168574f42 Lkt: prevent PLE when getting custom image
``custom_image`` was calling ``full_name``, which was a public property:
this implies that PLE would be called when using simple syntaxic
methods, like ast dumping. This introduces ``full_name_internal`` which
is used internally instead of ``full_name``, which becomes a simple
public wrapper.
2025-06-02 11:00:55 +02:00
Pierre-Marie de Rodat
2ededd7344 Add escape sequences in predicate error message templates 2025-05-26 13:53:21 +00:00
Raphaël AMIARD
fbb68730d8 Extend lkt_toolbox to log errors in name resolution 2025-05-23 07:18:07 +00:00
Raphaël AMIARD
932fb6fb1f Significantly refactor the grammar for patterns.
The first iteration was just a relatively basic copy&paste from the LKQL
grammar, that carries a lot of cruft and legacy at this stage. Following
the comments on the initial review for the merge request, it was decided
to take the opportunity to clean the grammar.

* Rename "BasePattern" into "Pattern"
* Remove every pattern abstract intermediate class (ValuePattern and
  NodePattern). The categorizations they introduce is not very useful,
  and they introduce a lot of complexity.
* Rename pattern details
* Remove mentions of "node" patterns, since we want to make the notion
  of matching on a given type more general than just for node types.
* Rename ExtendedNodePattern -> ExtendedPattern, since we might want to
  generalize the notion, and NodeKindPattern was renamed into
  TypePattern already.
* Rewrite most of the docstrings
* Rename Splat -> Ellipsis
* Unify the naming of sub pattern fields (call them all
  `sub_pattern`/`sub_patterns`.
2025-05-23 07:18:07 +00:00
Raphaël AMIARD
eecd91877d Lktql: Add support for patterns in match expressions 2025-05-23 07:18:07 +00:00
Raphaël AMIARD
00bf1a5964 Lktql: Add patterns to the Lkt grammar
Also add some support for unparsing (not complete but good enough for
now)
2025-05-23 07:18:07 +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
38b1e3a6be Lkt: rework the syntax tree to represent null-conditional expressions
Keep track of whether some expression has null-conditional behavior with
`f_null_cond` fields (to note whether `?` is present) rather than
alternative subclasses (`DotExpr`/`NullCondDotExpr`,
`SubscriptExpr`/`NullCondSubscriptExpr`).
2025-03-26 14:02:49 +00:00