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

Building parsers programmatically (question) #237

Open
catie opened this issue May 7, 2023 · 2 comments
Open

Building parsers programmatically (question) #237

catie opened this issue May 7, 2023 · 2 comments

Comments

@catie
Copy link

catie commented May 7, 2023

I'm new to Node, so please forgive me if I'm missing something obvious here. I'm building a utility to parse binary files based on a Json definition of the file specification, and while I originally implemented it in Java, that solution is clunky and already showing strain so I'm rebuilding in Node.

My Json elements have types that already match your primitives, but I notice the Parser.primitiveN() function is private. It seems a little silly to re-implement mappings that I can see are happening in reverse once I call parse(), but I could do that if needed. I'm also happy to make the changes to expose PrimitiveTypes and primitiveN(), but looking at the git history it seems like they might've been made private for a reason. If someone could shed some light on why and provide guidance on the best path forward it would be greatly appreciated. Thanks!

@keichi
Copy link
Owner

keichi commented Jun 12, 2023

Sorry for not getting back to you sooner. IIRC primitiveN is private simply because there were no use cases to generate the parser definition itself dynamically. Also we wanted to minimize the API surface.

Feel free to open a PR to make it public!

@catie
Copy link
Author

catie commented Jun 12, 2023

Makes sense! I'll try and find some time to clean up my fork and get it submitted. Thanks @keichi!

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