Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

const float d[3] = float[](5.0, 7.2, 1.1); #13

Open
dy opened this issue Feb 19, 2016 · 1 comment
Open

const float d[3] = float[](5.0, 7.2, 1.1); #13

dy opened this issue Feb 19, 2016 · 1 comment

Comments

@dy
Copy link
Member

dy commented Feb 19, 2016

var parse = require('glsl-parser/direct');
var tokenize = require('glsl-tokenizer/string');

parse(tokenize(
    'const float d[3] = float[](5.0, 7.2, 1.1);'
));
//Error: unexpected at line 1

Though it is valid GLSL syntax.

@AndrewRayCode
Copy link

AndrewRayCode commented Dec 31, 2018

Hmm, I'm not sure what version of GLSL this parser is supposed to support, but if it's WebGL GLSL, which is glsl 1.0, then this isn't valid syntax. @chrisdickinson do you have a thought on which version of GLSL this parser is built for?

Under the hood, this is happening because:

infix('[', 80, function(left) {
  this.children = [left, expression(0)]
  this.type = 'binary'
  advance(']')
  return this
}
  • The left will be float, and then it expects an expression() inside the parens.

This parser doesn't seem to follow the GLSL language grammar spec, so it's hard to compare the top down operator precedence setup with what the spec expects. For example, is it correct that [ is an infix node in this case (infixed between float and expression)? I'm not sure

I tried making the infix call into a unary type instead, but the printer for the compiler doesn't print the closing [ correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants