Skip to content

Can't parse user defined structs in fn args #24

@AndrewRayCode

Description

@AndrewRayCode

Here's a line from a Three.js shader which fails parsing:

const str = `vec3 BRDF_Specular_GGX( const in IncidentLight incidentLight ) {;}`;
const t = tokenize(str);
const p = parse(t);

Error:

expected user defined type, struct or keyword, gotIncidentLight at line 1

It's failing in struct_or_type on this line

return unexpected('expected user defined type, struct or keyword, got '+token.data)

It might be failing this check

     if(token.data === 'struct') {
        if(!(stmt.flags & DECL_ALLOW_STRUCT)) {
          return unexpected('cannot nest structs')
        }
        state.unshift(struct())
        return Advance
      }

Because the token.data isn't 'struct' even though it's a user defined struct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions