tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Migrate: louise migrate — old syntax in, new syntax out (ADR 0061, issue #314)

Phase 5a (pulled ahead of 2-4 so the repository migrates early and the
language phases keep their test coverage):

- crates/louise_syntax/src/legacy/: the pre-ADR-0061 lexer, grammar and
  AST, frozen (the parser is shared, parameterized on the lex function).
- crates/louise_syntax/src/migrate.rs: the translator. Old CST to new
  text, then the formatter for canonical layout. Definitions gain `::`
  and space-separated parameters (complex patterns keep parentheses;
  `label c: T` becomes `~label:(c: T)`); calls juxtapose (`f(a, b)` is
  `f a b`, `f()` is `f ()`, `f(label: x)` is `f ~label: x`,
  punned to `f ~label`); non-atom arguments are parenthesised
  (`f (a + b)`, `f (g x)`); constructor calls and record updates keep
  their parentheses with `~` labels (keyed on the callee path's case,
  the rule patterns already use); constructor patterns and attributes
  follow (`@derive(Eq, Show)` is `@derive Eq Show`,
  `blocking(io)` is `(blocking io)`).
- The token check, like the formatter's: old and new significant tokens
  must be equal up to the migration's edits — dropped list parentheses
  and commas (recorded by range), added `::`/`~`, parentheses added
  around single arguments (never containing a top-level comma, so no
  tuple appears or vanishes). Comments must match in order; a comment
  inside a rewritten list is lifted out after the head (a zero-argument
  call's comment has nowhere to go and refuses the file).
- `louise migrate <paths>` rewrites .lse files in place and the
  ```louise blocks of Markdown files (fragments are migrated wrapped
  in a function body and unwrapped after); `--check` only reports.

Known limit (for the ADR's open-for-review list): an old call-site label
matched a function parameter's *name*; a new one needs the definition to
declare `~name`. The tool cannot know which parameters were used as
labels, so those definitions are labelled by hand after the run (the type
checker lists them: no parameter named ..).

olivier · il y a 1 mois · dbd829fd05252511bfb0c202a79a00fc09b0820d

Parents bf8401d

14 fichiers modifiés, 3962 ajouts, 8 suppressions

Mcrates/louise_syntax/src/format.rs+39−7
Acrates/louise_syntax/src/legacy/ast.rs+1123−0
Acrates/louise_syntax/src/legacy/expr.rs+576−0
Acrates/louise_syntax/src/legacy/html.rs+144−0
Acrates/louise_syntax/src/legacy/lexer.rs+402−0
Acrates/louise_syntax/src/legacy/mod.rs+500−0
Acrates/louise_syntax/src/legacy/pat.rs+145−0
Acrates/louise_syntax/src/legacy/types.rs+148−0
Acrates/louise_syntax/src/migrate.rs+625−0
Mcrates/louise_syntax/src/parser.rs+9−1
Acrates/louise_syntax/tests/migrate.rs+102−0