Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 hard would it be to creating a custom parser based on an existing shell language? #1005

Closed
hwittenborn opened this issue May 30, 2023 · 1 comment

Comments

@hwittenborn
Copy link

I was looking into making some sort-of custom syntax for a project I'm working on:

It would be sort of like the Bats @test syntax, but would ommit the @test part and change the string part after it to have no quotes like so:

package {
    # Anything in here is normal shell syntax again, until the closing `}` is found.
    a_function() { true; }
    echo "Run commands, and do any normal shell stuff in here"
}

It's also like just defining a package() { ... } function, I'm just wanting to omit the () for stylistic purposes in my program.

Does the public API expose anything to do the things I'm looking for? If not, would there be anywhere in the codebase you'd recommend I'd look at if a fork would be necessary?

@mvdan
Copy link
Owner

mvdan commented May 30, 2023

There is no easy API for you to do this, no - you would have to modify the recursive descent parser to allow for it. Looking at how the Bats syntax is implemented would be a good start. I don't think we want to have API for supporting arbitrary syntax like this, because I'm not even sure what the API would look like. A soft fork seems like a good way to experiment.

Repository owner locked and limited conversation to collaborators May 30, 2023
@mvdan mvdan converted this issue into discussion #1006 May 30, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants