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

Add parseRawCF to use bnfc as library and parse LBNF from another application #484

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

chaserhkj
Copy link
Contributor

This PR decouples the CF parsing process of LBNF file from unused back end options and checks, thus providing a new function parseRawCF that can be called from third party applications.

I wrote this mainly because I am building another project and wishes to use LBNF format as my project's input. I want to call BNFC parsing processes directly to parse LBNF in my application but found out that was impossible due to parseCF requiring SharedOptions. My project performs analysis and manipulation of the input grammar, rather than converting it to an output target format, thus will not use any part of the back end of BNFC.

Ideally we would want to separate ShareOptions to front end and back end options and just use front end options for parsing the raw CF. But for now it seems that the parsing process only uses lbnfFile option and so I separated this specific field and created the parseRawCF function.

Also, I will be implementing a few utilities to work on a parsed LBNF grammar in my project, most significant ones should be the formatter to print CF back to LBNF format, and the Chomsky normalization to convert any CF to Chomsky Normal Form. I am not sure if these are appropriate to be merged into BNFC as well, let me know you guys' thoughts on them, thank you!

@andreasabel andreasabel merged commit a722de9 into BNFC:master Oct 30, 2024
27 checks passed
@andreasabel andreasabel added the API Concerning the BNFC library label Oct 30, 2024
@andreasabel andreasabel added this to the 2.9.6 milestone Oct 30, 2024
@andreasabel
Copy link
Member

Thanks for the PR and apologies for the long wait.
I have not a lot of time for BNFC as I am mainly developing Agda.

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

Successfully merging this pull request may close these issues.

2 participants