brendan-duncan / wgsl_reflect

A WebGPU Shading Language parser and reflection library for Javascript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for unsized arrays of arrays

greggman opened this issue · comments

This fails to parse

@group(0) @binding(0) var<storage> u: array<array<vec4f, 20>>;

This works (added a space between the two > at the end)

@group(0) @binding(0) var<storage> u: array<array<vec4f, 20> >;

I'm happy to add the space in my own code, I just thought I'd pass on the issue

The lexer tries to disambiguate > vs >> based on looking up a couple tokens and seeing if it's a template type. For some reason I didn't think to add array as a type, even though array was used in my comment describing what the lexer is doing (https://github.com/brendan-duncan/wgsl_reflect/blob/main/src/wgsl_scanner.ts#L608). Clearly I don't listen to myself.

I'll get it fixed up after my day job.

I'll also take a look at other ambiguous parsing cases while I'm poking around in the lexer, like the ones David Neto pointed out in gpuweb/gpuweb#2717.

I pushed the fix for your case. I'll investigate the let v: vec2<i32>= vec2(1,2); case next. Gotta love context sensitive parsing.

It should be handling the let v: vec2<i32>= vec2(1,2); case now too.