Add parseRawCF
to use bnfc as library and parse LBNF from another application
#484
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR decouples the
CF
parsing process of LBNF file from unused back end options and checks, thus providing a new functionparseRawCF
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
requiringSharedOptions
. 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 useslbnfFile
option and so I separated this specific field and created theparseRawCF
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 anyCF
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!