wit-parser: add ItemName type and parser#2529
Conversation
2b3b07b to
67b9f52
Compare
fitzgen
left a comment
There was a problem hiding this comment.
LGTM but I'm not super familiar with this code, so if you feel like having @alexcrichton take a look as well would be good, then feel free to wait to merge this until after that's happened.
alexcrichton
left a comment
There was a problem hiding this comment.
Could this re-use existing parts of the parser to share both syntax and implementation? for example UsePath might be appropriate to parse here and then manual parsing of .{name} happens after that. It would change syntax subtly around the versions but it'd be a bit more consistent with the rest of WIT
|
@alexcrichton when I started this work I made a wrapper around If I misinterpreted your suggestion and you think there's a different concrete syntax that works better, I'm happy to look at that. |
49ff576 to
13a6038
Compare
|
Sounds reasonable to me 👍 |
This adds a new type and parser to the wit-parser crate for
ItemName.The intent is to define a single place where an optionally-qualified path to an item's name is parsed. At its core an item name is:
and the only nontrivial details is that, if the package is provided and that package has a version, the version is the suffix of the entire item name, e.g.
namespace:packagename/interface.funcname@0.1.0.This PR does not add any integration of this type to the
Resolvestruct. That is left for a future PR.My goal in adding this type without yet integrating it with
Resolveis to use this type in other crates that already depend on wit-parser:wasi:cli/run.runcan be looked up without chaining API calls to perform a lookup of wasi:cli/run -> run.wasmtime run --invokewhere, if there happen to be more than one function exported across all interfaces namedrun, its impossible to disambiguate, https://github.com/bytecodealliance/wasmtime/blob/main/src/commands/run.rs#L799-L808