Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Aloso opened this issue Jul 4, 2022 · 6 comments
Open

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

Aloso opened this issue Jul 4, 2022 · 6 comments
Labels
discuss Discussion

Comments

@Aloso
Copy link
Member

Aloso commented Jul 4, 2022

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

@wmstack
Copy link

wmstack commented Jul 18, 2022

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?

@Aloso
Copy link
Member Author

Aloso commented Jul 18, 2022

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

What language are you using Pomsky for?

@wmstack
Copy link

wmstack commented Jul 18, 2022

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.

@Aloso Aloso added the discuss Discussion label Aug 2, 2022
@Aloso Aloso pinned this issue Aug 2, 2022
@ClementNerma
Copy link

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

@lppedd
Copy link

lppedd commented Dec 30, 2022

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

@ClementNerma
Copy link

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Discussion
Projects
None yet
Development

No branches or pull requests

4 participants