yoav_lavi's comments
yoav_lavi | 4 years ago | on: Babel Plugin Melody
- A Babel plugin - https://www.npmjs.com/package/babel-plugin-melody
- NodeJS bindings via WASM - https://www.npmjs.com/package/melodyc
- A playground - https://melody-playground.vercel.app/
- VSCode and JetBrains extensions - https://marketplace.visualstudio.com/items?itemName=yoavlavi... https://plugins.jetbrains.com/plugin/18693-melody
- A CLI and REPL
- A documentation book - https://yoav-lavi.github.io/melody/book/
The idea behind Melody is to represent regular expressions in a readable, maintainable format that plays nicely with larger projects, multiple people, diffs and so forth, while adding some QOL features.
See the repository here: https://github.com/yoav-lavi/melody
yoav_lavi | 4 years ago | on: Melody – a language that compiles to regular expressions
>If it could be done inline even better
I've been thinking of using a tagged template based mechanism (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...) so no special editor support is needed and then transpile to a normal regex (similar to how htm handles it's syntax with no runtime, https://www.npmjs.com/package/babel-plugin-htm) but I'm not working on that part of the process yet so it may change.
If Melody does end up using the tagged template mechanism it may end up looking something like this:
import melody from "melody";
const batmanRegex = melody`
16 of "na";
2 of match {
<space>;
"batman";
}
`;
That would transpile to: const batmanRegex = /(?:na){16}(?:\sbatman){2}/;
Backticks would need escaping but otherwise it'd be normal Melody syntaxyoav_lavi | 4 years ago | on: Melody – a language that compiles to regular expressions
1. A reverse compiler is one of the 'maybe' features (see the table in the README), it's something I'd like but would essentially be an entire compiler so it's non trivial
2. The plan is to make Melody available as a compile step (like e.g. SASS) with no runtime overhead or as a Rust crate. You could do the compilation at runtime but other than including variables in the pattern I'm not sure if it'd have a benefit over compile time transforming, + it'd have a performance impact.
Thank you!
yoav_lavi | 4 years ago | on: Melody – a language that compiles to regular expressions
yoav_lavi | 4 years ago | on: Melody – a language that compiles to regular expressions
Kidding of course, looks really cool!