Commit Graph

360 Commits

Author SHA1 Message Date
Pierre-Marie de Rodat
ca0f8eb315 Transition Libpythonlang to Lkt/lkm
Also stop building it in `manage.py`` (it is no longer needed for common
Langkit operations). Rename and repurpose `contrib/python_grammar` to
generate+build Libpythonlang, in an attempt to ensure it does not bit
rot.
2025-02-06 09:31:49 +00:00
Pierre-Marie de Rodat
863be42475 Self-host Lkt (i.e. transition Liblktlang to Lkt)
Add pre-generated sources for Liblktlang in `contrib/lkt/bootstrap` so
that it is possible to build one version of Liblktlang in order to
compile Liblktlang's Lkt sources.

Adjust `manage.py` to build that bootstrap version of Liblktlang
automatically, and add a `manage.py bootstrap` command to genererate
sources for the bootstrap Liblktlang.
2025-02-06 09:31:49 +00:00
Pierre-Marie de Rodat
152ae5c1fe lkt/language/parser.py: rename "enum" identifiers
"enum" is a Lkt keyword, so another identifier is needed to prepare the
transition to Lkt.
2025-01-27 15:20:56 +00:00
Pierre-Marie de Rodat
3f2e40ae2e lkt/language/parser.py: add missing call to Var() 2025-01-27 15:20:56 +00:00
Pierre-Marie de Rodat
3897983cce Lkt: rename GrammarDecl.lexer to referenced_lexer
`lexer` is a keyword in Lkt, so having a property called `lexer` in Lkt
is an obstacle from the self-hosting of Lkt itself. Rename that property
to avoid this issue.
2025-01-27 15:20:56 +00:00
Pierre-Marie de Rodat
ee702fcc37 Lkt: rename ValDecl.val to ValDecl.expr
`val` is a keyword in Lkt, so having a field called `val` in Lkt is an
obstacle from the self-hosting of Lkt itself. Rename that field to avoid
this issue.
2025-01-27 15:20:56 +00:00
Pierre-Marie de Rodat
29278577d1 Lkt: turn pattern names to lower case 2025-01-27 15:20:56 +00:00
Pierre-Marie de Rodat
ab30efda52 Lkt unparsing: fix handing of token literals in GrammarRuleDecl 2025-01-27 15:19:13 +00:00
Pierre-Marie de Rodat
aa125c258e liblktlang-implementation-extensions.adb: fix memory leaks
After a function has unwrapped the `Text_Type` stored in a `String_Type`
value, it must release its ownership share for that `String_Type` value.
2025-01-27 15:02:25 +00:00
Remi SEGARD
73a58df455 Implement a new typer for Lkt using the Logic DSL 2025-01-24 14:23:57 +00:00
Pierre-Marie de Rodat
3fbb1c38b7 langkit.config: rename "lkt" to "lkt_spec" 2025-01-09 19:59:12 +00:00
Pierre-Marie de Rodat
f9465ae01f langkit.libmanage: initialize verbosity in __init__ rather than setattr
Minor refactoring: pass the right verbosity level to CompileCtx.__init__
constructor instead of patching it after the instance has been created
(cleaner).
2025-01-07 15:09:51 +00:00
Pierre-Marie de Rodat
109fd493c7 Introduce separate data structure to hold the language spec config
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.
2025-01-07 09:54:56 +00:00
Pierre-Marie de Rodat
8508b1c701 Lkt: accept concatenation in pattern declarations and tok. pattern rules 2024-12-17 15:40:08 +00:00
Joao Azevedo
fce1003f54 Unparsing: replace ifKind null matcher by absent
For the ifKind template, replace "null" matcher by an "absent" matcher.
The "absent" matcher besides matching null nodes will also match empty
lists.
2024-12-04 12:17:39 +00:00
Pierre-Marie de Rodat
c9d984bfe1 Unparsing: allow unparsing configuration to tune bubbling up behavior 2024-11-27 10:01:11 +00:00
Pierre-Marie de Rodat
40a8eb68aa Lkt unparsing: fix non-idempotency in TryExpr
Emit a group for the f_or_expr field only if that field is actually
present, so that we add a "line" only when the "else" keyword is
present. Before this change, that "line" document used to expand to a
hardline because of line length, which Langkit cannot anticipate, so
trivia propagation inserted another line break.

As a nice side effect, the "else" clause is on its own line if its expr
breaks the group (subjectively more readable).
2024-11-27 09:27:42 +00:00
Pierre-Marie de Rodat
8cc3313c72 Lkt default config: add explicit default config for all nodes
Also reorder existing entries.
2024-11-20 09:31:16 +00:00
Remi Segard
e306393cc3 Lkt: fix LogicPropagateCall docstring 2024-11-19 15:54:14 +01:00
Raphaël AMIARD
91308ae4c5 Refactor CallExpr like Lkt nodes
To have the following structure:

    class BaseCallExpr : Expr
    class LogicCallExpr : CallExpr
    class CallExpr : BaseCallExpr
    class LogicPredicate : LogicCallExpr
    class LogicPropagateCall : LogicCallExpr

This will allow easier unparsing, and easier typing
2024-11-19 15:15:34 +01:00
Pierre-Marie de Rodat
210d61db7b Lkt: add unparsing configuration for generic declarations 2024-11-12 15:31:52 +00:00
Pierre-Marie de Rodat
14943204de Unify the handling of plugin passes
Replace ManageScript.extra_code_emission_passes property by a
plugin_passes CompileCtx constructor argument to unify plugin passes
that come from the language specification and from the manage script
command line.
2024-11-05 08:58:12 +00:00
Pierre-Marie de Rodat
9514b56cf6 Let language specs enable unparsers with a grammar annotation
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.
2024-11-05 08:58:12 +00:00
Pierre-Marie de Rodat
8a5771940e Refactor computation of main programs
Let manage.py scripts give the set of extra mains (instead of computing
the whole set), and delay the computation of all mains to the emit step:
this needs to know if unparsers are enabled.

Future work will introduce a grammar annotation to enable unparsers, so
computing the set of mains will be possible only once the grammar has
been lowered.
2024-11-05 08:58:12 +00:00
Pierre-Marie de Rodat
22366abead Lkt unparsing config: merge identical ifKind matchers 2024-10-09 15:00:56 +02:00