-
Notifications
You must be signed in to change notification settings - Fork 290
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 simpler import syntax #2207
Conversation
@@ -1,4 +1,4 @@ | |||
from .path.to. import user, persona | |||
import "path/to/user.zed |
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 an error case test where the string is not closed
// the compiler is being invoked, rather than whether it's local to the source | ||
// folder of the current context. The assumption is that that won't matter | ||
// right now, and we can fix it if we need to. | ||
if !filepath.IsLocal(path) { |
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.
we should also add a check for ..
anywhere in the path; if so, we can also quick-error
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.
Like at the parser level?
@@ -198,6 +198,37 @@ func (p *sourceParser) tryConsumeKeyword(keyword string) bool { | |||
return true | |||
} | |||
|
|||
// consumeString consumes a string token and returns the unwrapped string or adds an error node. | |||
func (p *sourceParser) consumeString() (string, bool) { |
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.
let's name this consumeStringLiteral
@@ -1,4 +1,4 @@ | |||
from .path.to. import user, persona | |||
import 'path/to/user.zed' |
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 one more test which uses ' and " within the other kind of quotes
if !ok { | ||
return "", false | ||
} | ||
wrappedString := wrappedStringToken.Value |
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.
nit: newline before large comments here and above
c517486
to
c1756e6
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
Description
After discussion, we decided to go with an
import "some/path/to/file.zed"
as the syntax and drop the explicit list of imports. This is based on an assumption that users mostly want to decompose a singles schema file into several, and code reuse is not high on the list of priorities.This changes the parser, compiler, and importer behavior to match.
Changes
Testing
Review. See that things are green.