-
Notifications
You must be signed in to change notification settings - Fork 291
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
Port in expiration parsing into composable schema DSL #2239
Conversation
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.
See comments
// Parking lot for future keywords | ||
"and": {}, | ||
"or": {}, | ||
"not": {}, | ||
"under": {}, | ||
"static": {}, | ||
"if": {}, | ||
"where": {}, | ||
"private": {}, | ||
"public": {}, |
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.
This is one change that wasn't a direct copy.
defer p.mustFinishNode() | ||
|
||
// consume the `use` | ||
p.consumeKeyword("use") |
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.
Making this a keyword is one change from the schemadsl
package.
@@ -35,7 +35,7 @@ NodeTypeFile | |||
caveat-name = somecaveat | |||
end-rune = 67 | |||
input-source = caveats type test | |||
start-rune = 53 | |||
start-rune = 58 |
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.
There's a number of these changes where with
is now on the other side of a node boundary. This results in the start-rune
being incremented by 5, which is consistent with #2141.
@@ -135,8 +141,7 @@ func TestParser(t *testing.T) { | |||
{"partials with malformed partial block", "partials_with_malformed_partial_block"}, | |||
} | |||
|
|||
for _, test := range parserTests { | |||
test := test | |||
for _, test := range parserTests { test := test |
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.
undo this change
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.
Done
a87be96
to
90453da
Compare
90453da
to
726aac4
Compare
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.
See comment
{"use expiration", "use expiration", []Lexeme{ | ||
{TokenTypeKeyword, 0, "use", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeKeyword, 0, "expiration", ""}, | ||
tEOF, | ||
}}, | ||
{"use expiration and", "use expiration and", []Lexeme{ | ||
{TokenTypeKeyword, 0, "use", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeKeyword, 0, "expiration", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeKeyword, 0, "and", ""}, | ||
tEOF, | ||
}}, | ||
{"expiration as non-keyword", "foo expiration", []Lexeme{ | ||
{TokenTypeIdentifier, 0, "foo", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeKeyword, 0, "expiration", ""}, | ||
tEOF, | ||
}}, | ||
{"and as non-keyword", "foo and", []Lexeme{ | ||
{TokenTypeIdentifier, 0, "foo", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeKeyword, 0, "and", ""}, | ||
tEOF, | ||
}}, | ||
{"invalid use flag", "use foobar", []Lexeme{ | ||
{TokenTypeKeyword, 0, "use", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeIdentifier, 0, "foobar", ""}, | ||
tEOF, | ||
}}, | ||
{"use flag after definition", "definition use expiration", []Lexeme{ | ||
{TokenTypeKeyword, 0, "definition", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeKeyword, 0, "use", ""}, | ||
{TokenTypeWhitespace, 0, " ", ""}, | ||
{TokenTypeKeyword, 0, "expiration", ""}, |
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.
Is it worth reworking these tests? use
and expiration
are now keywords, so the semantics of the tests don't completely scan.
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.
Yes, I think so; we should add them in as formal keywords in the lexer tests
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
Description
The first step towards making
use expiration
and theexpiration
trait into the composable schema compiler. This mirrors the changes in #2141 into thecomposableschemadsl
package.Changes
Testing
See that tests pass.