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

feat: allow '/' and '.' in type and relation names #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OpenFGALexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ IDENTIFIER: (LETTER | '_') (LETTER | DIGIT | '_' | MINUS)*;
// NOTE: MINUS is not allowed in CEL, but allowed in FGA, CEL will be revalidated after

// END CEL GRAMMAR
EXTENDED_IDENTIFIER: (LETTER | '_')((SLASH | DOT | MINUS)?(LETTER | DIGIT | '_')+)*;

NEWLINE:
WHITESPACE? ('\r'? '\n' | '\r' | '\f') WHITESPACE? NEWLINE?;
Expand Down
14 changes: 8 additions & 6 deletions OpenFGAParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ moduleHeader: (multiLineComment NEWLINE)? MODULE WHITESPACE moduleName=identifie

// Type Definitions
typeDefs: typeDef*;
typeDef: (NEWLINE multiLineComment)? NEWLINE (EXTEND WHITESPACE)? TYPE WHITESPACE typeName=identifier (NEWLINE RELATIONS relationDeclaration+)?;
typeDef: (NEWLINE multiLineComment)? NEWLINE (EXTEND WHITESPACE)? TYPE WHITESPACE typeName=extended_identifier (NEWLINE RELATIONS relationDeclaration+)?;

// Relation definitions
relationDeclaration: (NEWLINE multiLineComment)? NEWLINE DEFINE WHITESPACE relationName WHITESPACE? COLON WHITESPACE? (relationDef);
relationName: identifier;
relationName: extended_identifier;

relationDef: (relationDefDirectAssignment | relationDefGrouping | relationRecurse) (relationDefPartials)?;
relationDefNoDirect: (relationDefGrouping | relationRecurseNoDirect) (relationDefPartials)?;
Expand All @@ -23,7 +23,7 @@ relationDefPartials:
(WHITESPACE OR WHITESPACE (relationDefGrouping | relationRecurseNoDirect))+
| (WHITESPACE AND WHITESPACE (relationDefGrouping | relationRecurseNoDirect))+
| (WHITESPACE BUT_NOT WHITESPACE (relationDefGrouping | relationRecurseNoDirect));

relationDefGrouping: relationDefRewrite;

relationRecurse:
Expand All @@ -39,15 +39,15 @@ relationRecurseNoDirect:
) WHITESPACE* RPAREN;

relationDefDirectAssignment: LBRACKET WHITESPACE? relationDefTypeRestriction WHITESPACE? (COMMA WHITESPACE? relationDefTypeRestriction WHITESPACE?)* RPRACKET;
relationDefRewrite: rewriteComputedusersetName=identifier (WHITESPACE FROM WHITESPACE rewriteTuplesetName=identifier)?;
relationDefRewrite: rewriteComputedusersetName=extended_identifier (WHITESPACE FROM WHITESPACE rewriteTuplesetName=extended_identifier)?;

relationDefTypeRestriction: NEWLINE? (
relationDefTypeRestrictionBase
| (relationDefTypeRestrictionBase WHITESPACE KEYWORD_WITH WHITESPACE conditionName)
) NEWLINE?;
relationDefTypeRestrictionBase: relationDefTypeRestrictionType=identifier
relationDefTypeRestrictionBase: relationDefTypeRestrictionType=extended_identifier
((COLON relationDefTypeRestrictionWildcard=STAR)
| (HASH relationDefTypeRestrictionRelation=identifier))?;
| (HASH relationDefTypeRestrictionRelation=extended_identifier))?;

// Conditions
conditions: condition*;
Expand All @@ -66,6 +66,8 @@ multiLineComment: HASH (~NEWLINE)* (NEWLINE multiLineComment)?;

identifier: MODEL | SCHEMA | TYPE | RELATION | IDENTIFIER | MODULE | EXTEND;

extended_identifier: identifier | EXTENDED_IDENTIFIER;

conditionExpression: ((
IDENTIFIER |
EQUALS |
Expand Down
5 changes: 4 additions & 1 deletion pkg/go/gen/OpenFGALexer.interp

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pkg/go/gen/OpenFGALexer.tokens

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/go/gen/OpenFGAParser.interp

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pkg/go/gen/OpenFGAParser.tokens

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

645 changes: 330 additions & 315 deletions pkg/go/gen/openfga_lexer.go

Large diffs are not rendered by default.

1,114 changes: 631 additions & 483 deletions pkg/go/gen/openfga_parser.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions pkg/go/gen/openfgaparser_base_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/go/gen/openfgaparser_listener.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading