-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2103 from authzed/local-imports
Implement parsing of local imports
- Loading branch information
Showing
20 changed files
with
668 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
pkg/composableschemadsl/dslshape/zz_generated.nodetype_string.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .path.to.user import user, persona | ||
|
||
definition resource { | ||
relation user: user | ||
relation persona: persona | ||
permission view = user + persona | ||
} |
96 changes: 96 additions & 0 deletions
96
pkg/composableschemadsl/parser/tests/localimport.zed.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
NodeTypeFile | ||
end-rune = 155 | ||
input-source = local imports test | ||
start-rune = 0 | ||
child-node => | ||
NodeTypeImport | ||
end-rune = 39 | ||
input-source = local imports test | ||
start-rune = 0 | ||
imported-definition => | ||
NodeTypeIdentifier | ||
end-rune = 29 | ||
identifier-value = user | ||
input-source = local imports test | ||
start-rune = 26 | ||
NodeTypeIdentifier | ||
end-rune = 38 | ||
identifier-value = persona | ||
input-source = local imports test | ||
start-rune = 32 | ||
path-segment => | ||
NodeTypeIdentifier | ||
end-rune = 9 | ||
identifier-value = path | ||
input-source = local imports test | ||
start-rune = 6 | ||
NodeTypeIdentifier | ||
end-rune = 12 | ||
identifier-value = to | ||
input-source = local imports test | ||
start-rune = 11 | ||
NodeTypeIdentifier | ||
end-rune = 17 | ||
identifier-value = user | ||
input-source = local imports test | ||
start-rune = 14 | ||
NodeTypeDefinition | ||
definition-name = resource | ||
end-rune = 154 | ||
input-source = local imports test | ||
start-rune = 41 | ||
child-node => | ||
NodeTypeRelation | ||
end-rune = 85 | ||
input-source = local imports test | ||
relation-name = user | ||
start-rune = 67 | ||
allowed-types => | ||
NodeTypeTypeReference | ||
end-rune = 85 | ||
input-source = local imports test | ||
start-rune = 82 | ||
type-ref-type => | ||
NodeTypeSpecificTypeReference | ||
end-rune = 85 | ||
input-source = local imports test | ||
start-rune = 82 | ||
type-name = user | ||
NodeTypeRelation | ||
end-rune = 115 | ||
input-source = local imports test | ||
relation-name = persona | ||
start-rune = 91 | ||
allowed-types => | ||
NodeTypeTypeReference | ||
end-rune = 115 | ||
input-source = local imports test | ||
start-rune = 109 | ||
type-ref-type => | ||
NodeTypeSpecificTypeReference | ||
end-rune = 115 | ||
input-source = local imports test | ||
start-rune = 109 | ||
type-name = persona | ||
NodeTypePermission | ||
end-rune = 152 | ||
input-source = local imports test | ||
relation-name = view | ||
start-rune = 121 | ||
compute-expression => | ||
NodeTypeUnionExpression | ||
end-rune = 152 | ||
input-source = local imports test | ||
start-rune = 139 | ||
left-expr => | ||
NodeTypeIdentifier | ||
end-rune = 142 | ||
identifier-value = user | ||
input-source = local imports test | ||
start-rune = 139 | ||
right-expr => | ||
NodeTypeIdentifier | ||
end-rune = 152 | ||
identifier-value = persona | ||
input-source = local imports test | ||
start-rune = 146 |
7 changes: 7 additions & 0 deletions
7
pkg/composableschemadsl/parser/tests/localimport_import_path_with_keyword.zed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .path.definition.user import user, persona | ||
|
||
definition resource { | ||
relation user: user | ||
relation persona: persona | ||
permission view = user + persona | ||
} |
50 changes: 50 additions & 0 deletions
50
pkg/composableschemadsl/parser/tests/localimport_import_path_with_keyword.zed.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
NodeTypeFile | ||
end-rune = 20 | ||
input-source = local imports with keyword in import path test | ||
start-rune = 0 | ||
child-node => | ||
NodeTypeImport | ||
end-rune = 10 | ||
input-source = local imports with keyword in import path test | ||
start-rune = 0 | ||
child-node => | ||
NodeTypeError | ||
end-rune = 10 | ||
error-message = Expected keyword import, found token TokenTypeKeyword | ||
error-source = definition | ||
input-source = local imports with keyword in import path test | ||
start-rune = 11 | ||
path-segment => | ||
NodeTypeIdentifier | ||
end-rune = 9 | ||
identifier-value = path | ||
input-source = local imports with keyword in import path test | ||
start-rune = 6 | ||
NodeTypeIdentifier | ||
end-rune = 10 | ||
input-source = local imports with keyword in import path test | ||
start-rune = 11 | ||
child-node => | ||
NodeTypeError | ||
end-rune = 10 | ||
error-message = Expected identifier, found token TokenTypeKeyword | ||
error-source = definition | ||
input-source = local imports with keyword in import path test | ||
start-rune = 11 | ||
NodeTypeDefinition | ||
end-rune = 20 | ||
input-source = local imports with keyword in import path test | ||
start-rune = 11 | ||
child-node => | ||
NodeTypeError | ||
end-rune = 20 | ||
error-message = Expected identifier, found token TokenTypePeriod | ||
error-source = . | ||
input-source = local imports with keyword in import path test | ||
start-rune = 21 | ||
NodeTypeError | ||
end-rune = 20 | ||
error-message = Unexpected token at root level: TokenTypePeriod | ||
error-source = . | ||
input-source = local imports with keyword in import path test | ||
start-rune = 21 |
7 changes: 7 additions & 0 deletions
7
pkg/composableschemadsl/parser/tests/localimport_keyword_in_identifiers.zed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .path.to.user import user, caveat | ||
|
||
definition resource { | ||
relation user: user | ||
relation persona: persona | ||
permission view = user + persona | ||
} |
Oops, something went wrong.