-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add indentDSL to improve checkDSL parsing reliability #68
Conversation
@dbrrt : thank you for your contribution! Instead of adding the indentDSL in check-dsl.ts, maybe it will be better to update the grammar file https://github.com/openfga/syntax-transformer/blob/main/src/openfga.ne instead. In this way, the line number parsed by the checkDSL's catch statement (https://github.com/openfga/syntax-transformer/blob/f2b3cc0a0fc53531e4d00b1a55484c32eeb46151/src/check-dsl.ts#L137) will be correct. Please let me know if you need further clarifications. Thanks! |
I don't think changing the grammar is fair here. The purpose of my function is to make sure that any non properly indented input (copy pasted from any IDE / text editor, FGA playground, Zoom etc...) will match 1:1 the grammar and make the parser more resilient. It also natively drops the new lines making nearley's job easier. @adriantam Can you please elaborate on "why adding indenting to the catch statement"? I'm not sure how it could help with raw DSL parsing. @rhamzeh Any thought? |
Apologies for the late reply! First, thanks for your contribution @dbrrt! This is definitely helpful while we decide whether we want to make indentation optional in the grammar or not. A few notes:
TLDR:
|
Co-authored-by: Raghd Hamzeh <raghd@rhamzeh.com>
Thanks @dbrrt . Do you mind running |
Sure! |
@dbrrt : It seems to be failing lint test (https://github.com/openfga/syntax-transformer/actions/runs/3251900056/jobs/5338708365#step:8:44). Can you take a look at it? |
Yes, I missed the inferred type complaint from eslint, I only get warning from other files now, it should be fine. |
Looks like the unit test failed - https://github.com/openfga/syntax-transformer/actions/runs/3252493163/jobs/5340130318#step:9:15 |
The last test I've added wasn't related to the functionality introduced by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@dbrrt : Thank you for your contribution. The changes have been merged into main. |
This PR introduces
indent-dsl
utilities to facilitate friendly DSL parsing.Description
indent-dsl.ts
added with corresponding testsReview Checklist
main