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

implement defparser macro #4

Closed
judepayne opened this issue Apr 25, 2023 · 4 comments
Closed

implement defparser macro #4

judepayne opened this issue Apr 25, 2023 · 4 comments

Comments

@judepayne
Copy link
Contributor

Hi, I was thinking about the defparser macro. Of course it couldn't possibly have worked inside the pod as it's defining a var in a different process :)
However, we should be able to implement it in instaparse-bb, perhaps starting with a simple version then moving to one which splits the work appropriately between compile time and runtime as instaparse itself does.

Possibly we could go further and have Parser as a record that implements Ifn (like instaparse) and so remove the limitation that parsers must be called with parse.
@borkdude you must have considered this when you implemented the instaparse pod and instaparse-bb, so it would be good to hear your thoughts.

@borkdude
Copy link
Contributor

My thoughts: I just haven't thought deeply about it yet :)

@judepayne
Copy link
Contributor Author

Lol. I'll investigate more deeply. Knock some code together as time permits. I think it's possible. You'd just have to port or re-implement most of the instaparse.core ns (which is not that big).

@judepayne
Copy link
Contributor Author

Removing the limitation that parsers must be called with parse will be hard without support for implementing IFn on records or types.

A simple defparser macro to get us closer to the instaparse interface is straightforward enough. I'll do a PR

@judepayne
Copy link
Contributor Author

Closing.
instaparse-bb updated with:

  • the defparser macro
  • Parsers can be called directly like they're fns, as per Instaparse. Although currently in babashka, you can't have Records implement IFn, this can be worked around by using reify instead.

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

No branches or pull requests

2 participants