openfga / language

Grammar for the OpenFGA modeling language
https://openfga.dev
Apache License 2.0
15 stars 7 forks source link

feat: support extend keyword to extend a type in a modular model #160

Closed ewanharris closed 4 months ago

ewanharris commented 5 months ago

Description

~This builds on top of #159 so is in draft for now, once that's merged I will rebase.~

Adds support for using extend type <name> in a modular model, the strategy for doing this was to track whether we are processing a modular model (i.e. whether we encountered the module keyword) and then in the typedef handler we check if the extend keyword was used and add an error if the model we're processing is not a modular model.

I had initially investigated attempting to use semantic predicates to achieve this in the lexer but I think that involves larger scale changes such as adding a superClass for the antlr generated lexer to extend so we can write functions like IsModularModel to use in our grammar.

I think there will need to be some metadata added to track this but wanted to get a PR up to make sure I'm treading the right path.

References

Review Checklist