Open hhirtz opened 3 days ago
Using lexer-v2-full on 0.5.2 and 0.7.1 glsl-lang throws an InvalidFloatLitteral error on float litteral followed by a swizzle:
lexer-v2-full
use glsl_lang::ast; use glsl_lang::parse::DefaultParse; use std::error::Error; const GLSL: &str = " void main() { FragColor = 1.0.xxxx; // same as vec4(1.0) } "; fn main() -> Result<(), Box<dyn Error>> { let frag = ast::TranslationUnit::parse(GLSL)?; Ok(()) }
https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling
Code in the wild i wanted to parse: https://github.com/libretro/slang-shaders/blob/cc84cf9ac3c6004ad248216f47906fd33bf087d8/crt/shaders/guest/advanced/pre-shaders-afterglow.slang#L226
Not sure if it's because i'm using the wrong crate features or i need a subparser, but it only throws an error when the scalar is a literal.
This is an interesting way of constructing a vec4 for sure. It's definitely a bug, this should parse correctly. Thanks for bringing this up and providing an example of it in the wild, I'll look into it!
Using
lexer-v2-full
on 0.5.2 and 0.7.1 glsl-lang throws an InvalidFloatLitteral error on float litteral followed by a swizzle:https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling
Code in the wild i wanted to parse: https://github.com/libretro/slang-shaders/blob/cc84cf9ac3c6004ad248216f47906fd33bf087d8/crt/shaders/guest/advanced/pre-shaders-afterglow.slang#L226
Not sure if it's because i'm using the wrong crate features or i need a subparser, but it only throws an error when the scalar is a literal.