pomsky icon indicating copy to clipboard operation
pomsky copied to clipboard

How are you using (or would like to use) Pomsky?

Open Aloso opened this issue 3 years ago • 6 comments

And if you would like to use Pomsky but can't, why?

Aloso avatar Jul 04 '22 18:07 Aloso

I would like Pomsky to output, not the raw regular expression, but the delimited version of the string so the process of copy-pasting it into to the programming language becomes more convenient. Please consider such a flag that outputs different programming language flavours of the delimited regular expression.

For example, have a js option that produces /<regex>/g as an output, and for rust, produces the string that you would need to copy into your regex library, and so on. I imagine that with the expertise that you have with the different programming language flavours, that producing output suitable for incorporating into that particular programming language wouldn't be too difficult. What do you think?

wmstack avatar Jul 18 '22 11:07 wmstack

@wmstack IIUC, you want that slashes are already escaped in the output, right?

What language are you using Pomsky for?

Aloso avatar Jul 18 '22 13:07 Aloso

I wanted to use it for rust, to experiment with the regex for tokens in https://github.com/maciejhirsz/logos

Having to write a regular expression that matches something like a string literal quickly becomes unreadable, and as far as I can see, your DSL language is pretty fit to make it an easier process. So cheers!

I have realized that this encoding into a string is not super important, since I can just pipe it into to json of Nushell and it will create the string literal that encodes that regular expression. It is actually pretty convenient to use in the shell, especially with the -n option, where multiple calls can actually be chained. So yeah, it would be totally acceptable to leave that to a different tool for the job.

Having to encode a regular expression into a string literal is not a fun or error-free process, so yeah. Not super critical though.

wmstack avatar Jul 18 '22 22:07 wmstack

I use it in several projects, notably a Cron replacement utility and it's incredibly helpful to write simple regexes that would otherwise be overly complicated, like:

        let sep = ^ | ' ';
        let every = '*' | [digit]+ (',' [digit]+)*;

        Start
        (sep "M=" :months(every))?
        (sep "D=" :days(every))?
        (sep "h=" :hours(every))?
        (sep "m=" :minutes(every))?
        (sep "s=" :seconds(every))?
        End

ClementNerma avatar Nov 07 '22 08:11 ClementNerma

@ClementNerma I've used your example to showcase syntax highlight in IntelliJ IDEA, hope it's not an issue, in case let me know.

lppedd avatar Dec 30 '22 18:12 lppedd

@ClementNerma I've used your example to showcase syntax highlight in IntelliJ IDEA, hope it's not an issue, in case let me know.

No problem, glad if it was useful to you :)

ClementNerma avatar Dec 30 '22 18:12 ClementNerma