wgsl_reflect icon indicating copy to clipboard operation
wgsl_reflect copied to clipboard

Add strict mode

Open clickingbuttons opened this issue 2 years ago • 2 comments
trafficstars

Currently invalid syntax will silently fail. I'd like an error returned or an exception thrown instead of the results up until the invalid syntax.

Example:

import wgsl_reflect from "@feng3d/wgsl_reflect";
const { WgslReflect } = wgsl_reflect;

const reflect = new WgslReflect(`
const valid_not_skipped: u32 = 0u;
some invalid syntax;
const valid_but_skipped: u32 = 0u;
`);
console.log(reflect);
/*
_WgslReflect2 {
  structs: [],
  overrides: [],
  uniforms: [],
  storages: [],
  textures: [],
  samplers: [],
  functions: [],
  aliases: [],
  ast: [
    Const {
      name: 'valid_not_skipped',
      type: [Type],
      storage: '',
      access: '',
      value: [LiteralExpr],
      attributes: null
    }
  ],
  entry: EntryFunctions { vertex: [], fragment: [], compute: [] }
}
*/

clickingbuttons avatar Oct 25 '23 20:10 clickingbuttons

I'll look into adding better error exceptions.

brendan-duncan avatar Nov 03 '23 04:11 brendan-duncan

For me, I just compile with WebGPU, if it fails then don't call wgsl_reflect.

greggman avatar Dec 30 '23 21:12 greggman