diff --git a/internal/schema/.snapshots/TestLexer-suite=snapshots-import_statement.json b/internal/schema/.snapshots/TestLexer-suite=snapshots-import_statement.json new file mode 100644 index 000000000..4d561cf29 --- /dev/null +++ b/internal/schema/.snapshots/TestLexer-suite=snapshots-import_statement.json @@ -0,0 +1,13 @@ +[ + "'import'", + "{", + "'Foo'", + ",", + "'Bar'", + ",", + "'Baz'", + "}", + "'from'", + "'@ory/keto-...'", + "EOF" +] diff --git a/internal/schema/lexer.go b/internal/schema/lexer.go index 3b55edcc5..76172c712 100644 --- a/internal/schema/lexer.go +++ b/internal/schema/lexer.go @@ -307,7 +307,7 @@ func lexBlockComment(l *lexer) stateFn { func lexStringLiteral(l *lexer) stateFn { r := l.next() l.ignore() - l.acceptRun(digits + letters) + l.acceptRun(digits + letters + "@/-") if l.peek() != r { return l.errorf("unclosed string literal") } diff --git a/internal/schema/lexer_test.go b/internal/schema/lexer_test.go index f9955986b..60087dc54 100644 --- a/internal/schema/lexer_test.go +++ b/internal/schema/lexer_test.go @@ -15,6 +15,7 @@ var lexingErrorTestCases = []struct{ name, input string }{ var lexableTestCases = []struct{ name, input string }{ {"empty", ""}, + {"import statement", "import { Foo, Bar, Baz } from '@ory/keto-namespace-types'"}, {"single class", ` class name implements Namespace { metadata = { @@ -117,7 +118,6 @@ func TestLexer(t *testing.T) { } if item.Typ == itemEOF { t.Fatal("reached EOF, but expected error") - break } } l.next() diff --git a/internal/schema/parser_test.go b/internal/schema/parser_test.go index 781d48edc..6e282aaf2 100644 --- a/internal/schema/parser_test.go +++ b/internal/schema/parser_test.go @@ -17,6 +17,8 @@ var parserTestCases = []struct { name, input string }{ {"full example", ` + import { Namespace, SubjectSet, FooBar, Anything } from '@ory/keto-namespace-types' + class User implements Namespace { related: { manager: User[]