nolanderc / glasgow

Language Server for WGSL (WebGPU Shading Language)
MIT License
36 stars 1 forks source link

support for wgsl syntax extensions? #3

Open mighdoll opened 3 weeks ago

mighdoll commented 3 weeks ago

Would you be game to support an extended wgsl syntax in glasgow?

We've been working towards defining some community standard syntax extensions for wgsl for rust and typescript linkers like wgsl-linker. Documentation on the extensions coming soon, the first feature out of the gate will be keywords for import / export..

nolanderc commented 3 weeks ago

Sure, if there’s enough demand. However, just my 2 cents to make extensions easier for tooling to handle: if possible, extensions should not introduce additional syntax, and instead opt for using attributes. Unknown attributes are easier to parse, and can easily be ignored.

For example, export/import can use @export and @import directly, and if additional arguments to the attributes are needed (such as linking modes), those can be added as @export(static), without having to extend the syntax further.

k2d222 commented 3 weeks ago

That is an interesting suggestion. We have discussed using attributes in the past for other usecases than imports such as conditional compilation @if or a rusty @cfg that can be placed on function, structs, struct members, maybe statements, ...

But we didn't discuss it for imports. Attributes have to decorate something, so what would imports decorate? The function using the imports? Or do we allow attributes that decorate nothing at the top of the file?

To me It makes a lot of sense for @export.

--->> if you want to be part of the discussion we'd love to have you on board on our fresh discord! https://discord.gg/5UhkaSu4dt we discuss defining a community standard for wgsl language extensions. We'll start with imports.

nolanderc commented 3 weeks ago

For @import you might be able to attach them to an empty override declaration at the top of the file:

@import
override name_of_file_or_module;
mighdoll commented 2 weeks ago

There's now a growing body of docs here, and at least a couple of new linker protoypes in progress.

If you've time, bring your thoughts over to a github or discord to help make sure we're going in the right direction for language servers. For example, do you think it would be feasible to share a wgsl parser between a linker and a language server?