-
Notifications
You must be signed in to change notification settings - Fork 278
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
Implement parsing of local imports #2103
Conversation
@@ -485,6 +488,7 @@ func (p *sourceParser) tryConsumeArrowExpression() (AstNode, bool) { | |||
return nil, false | |||
} | |||
|
|||
// TODO: is this the time to do this? |
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.
yep!
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.
I'm gonna do that in a follow-on PR
return importNode | ||
} | ||
|
||
segmentNode, ok := p.tryConsumeIdentifierLiteral() |
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 isn't a try consume; it should be a consume, because a missing identifier here should be an error. Please add a test case for this
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.
I was going off of the implementation of this function, which does seem to use consume
:
identifier, _ := p.consumeIdentifier() |
I'll add a test case, though.
} | ||
} | ||
|
||
p.consumeKeyword("import") |
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.
Return here if the keyword was not found
|
||
// Consume alternating identifiers and commas until we reach the end of the import statement | ||
for { | ||
definitionNode, ok := p.tryConsumeIdentifierLiteral() |
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.
Similarly, not a try consume because it is required
@@ -122,6 +122,7 @@ func TestParser(t *testing.T) { | |||
{"arrow illegal operations test", "arrowillegalops"}, | |||
{"arrow illegal function test", "arrowillegalfunc"}, | |||
{"caveat with keyword parameter test", "caveatwithkeywordparam"}, | |||
{"local imports test", "localimport"}, |
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.
add a bunch of error cases as well
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 questions
child-node => | ||
NodeTypeError | ||
end-rune = 30 | ||
error-message = Expected one of: [TokenTypeComma], found: TokenTypeKeyword | ||
error-source = caveat | ||
input-source = local imports with keyword in identifiers test | ||
start-rune = 32 |
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.
Why doesn't this line up with the error below?
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 typically is a result of missing a finishNode call somewhere, but I don't see it. You'll need to trace to see why that is
NodeTypeError | ||
end-rune = 30 | ||
error-message = Expected one of: [TokenTypeComma], found: TokenTypeKeyword | ||
error-source = definition | ||
input-source = local imports with malformed identifiers set test | ||
start-rune = 33 |
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.
Same question here. Is this expected?
03139e3
to
7e9a35b
Compare
// NodeTypeImport | ||
// | ||
// TODO: still need to figure out what form this should take - full path? relative path? | ||
NodeImportPredicateSource = "import-source" |
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.
Match whatever we do for definition name paths
child-node => | ||
NodeTypeError | ||
end-rune = 30 | ||
error-message = Expected one of: [TokenTypeComma], found: TokenTypeKeyword | ||
error-source = caveat | ||
input-source = local imports with keyword in identifiers test | ||
start-rune = 32 |
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 typically is a result of missing a finishNode call somewhere, but I don't see it. You'll need to trace to see why that is
Add import consumption gofumpt Add import and from keywords Add some new nodes Fix node connection Add new test to list Generate output associated with new test Get rid of unused node types Shift nodes to predicates Gofumpt Add github token to trivy command Add comment note Get rid of unnecessary flag' Add more test cases Make updates to consumption Add test cases Add boolean return to consumeIdentiferLiteral Get rid of child node issue Apply suggestions from code review
31b30f7
to
f54b2c3
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.
LGTM
Part of #1437
Description
A first step in implementing the composable schema proposal. This implements the relative import syntax in the parser.
Changes
from
andimport
as keywordsTesting
Review. See that tests are green.