Add ogex convert --ogex to Convert Traditional Regex to Ogex Syntax #21

Closed
opened 2026-03-11 18:15:28 +03:00 by NiXTheDev · 0 comments
NiXTheDev commented 2026-03-11 18:15:28 +03:00 (Migrated from github.com)

Goal: Lower the barrier for users switching to Ogex by providing a tool that converts traditional regex patterns to Ogex syntax.

Currently, transpiler.rs only converts Ogex syntax to legacy. Add a reverse conversion that takes a pattern with (?<name>...) and outputs (name:...).

Implementation Steps:

  1. Extend the parser to accept legacy named group syntax (?<name>...) and treat it as NamedGroup in AST.
  2. Modify ast.rs to retain the original syntax information (maybe a flag indicating if it came from legacy).
  3. In transpile_to_ogex, traverse the AST and output Ogex syntax for named groups, leaving other syntax unchanged.
  4. Add a CLI flag --to-ogex or subcommand convert-from-legacy.

Testing:

  • Round-trip tests: Ogex -> legacy -> Ogex should yield the original pattern (modulo formatting).
**Goal**: Lower the barrier for users switching to Ogex by providing a tool that converts traditional regex patterns to Ogex syntax. Currently, `transpiler.rs` only converts Ogex syntax to legacy. Add a reverse conversion that takes a pattern with `(?<name>...)` and outputs `(name:...)`. **Implementation Steps**: 1. Extend the parser to accept legacy named group syntax `(?<name>...)` and treat it as `NamedGroup` in AST. 2. Modify `ast.rs` to retain the original syntax information (maybe a flag indicating if it came from legacy). 3. In `transpile_to_ogex`, traverse the AST and output Ogex syntax for named groups, leaving other syntax unchanged. 4. Add a CLI flag `--to-ogex` or subcommand `convert-from-legacy`. **Testing**: - Round-trip tests: Ogex -> legacy -> Ogex should yield the original pattern (modulo formatting).
Sign in to join this conversation.
No description provided.