You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GDShader grammar for float literals doesn't seem to match the one from GLSL ES 3.0 spec (section 4.1.4):
// Equivalent ANTLR4 syntax:FLOATING_CONSTANT
: Digit+ ExponentPart FloatingSuffix?
| FractionalConstant ExponentPart? FloatingSuffix?
;
fragment FractionalConstant: Digit* '.' Digit+ | Digit+ '.' ;
fragment ExponentPart: [eE] [+-]? Digit+ ;
fragment Digit: [0-9] ;
fragment FloatingSuffix: [fF] ;
From my interpretation, an equivalent JS regex would be something like this:
/\b(?:\d+[eE][-+]?\d+|(?:\d*[.]\d+|\d+[.])(?:[eE][-+]?\d+)?)[fF]?/
Below is some cases I tested (might not cover all problems).
Godot 4.0.alpha8
It's accepting floats like 0ef, 0e+f, 0.0ef, 0.0e-f, which are invalid in GLSL. Which is strange because invalids like 0e, 0.0e are being rejected correctly. At least in the GLSL grammar above, the digits are always required after the e in exponent notation. But something strange in gdshader grammar is accepting an empty number when f is present.
Godot 3.4.4
This, on the other hand, seems to not allow lowercase e and f together at all, even when the exponent number is present.
It's rejecting valid: 0e0f, 0e+0f, 0.0e0f, 0.0e-0f. When removing either e... or f part, then it's accepting it as normal.
It's also rejecting uppercase E exponents when they have a sign, even though it's fine in lowercase, e.g.: 0E+0, 0.0E-0.
Steps to reproduce
Just create a test.gdshader file in a new Godot project and double click to open it in the internal Shader editor.
Paste text below, and watch it for errors / non-errors.
Also syntax coloring is not exactly matching all tokens, even when compiler accepts them. Uppercase, for example, seems to mess with it.
Minimal reproduction project
This is not to cover all test cases by any means, just to facilitate testing some of the examples above. In a quick estimate, if all test cases were written (using just 0 in numbers), there should be ~81 (?) variations that should be accepted ... not to mention the ones to test rejection. So, it's better to just try to really carefully match the grammar/regex from the spec part by part and in tests try to break it with some edge cases. Multi-cursor feature in editors like VSCode may help with editing this to test other cases.
Godot version
v3.4.4.stable.mono.official [419e713], v4.0.alpha8.official [cc3ed63]
System information
Kubuntu 22.04 x64
Issue description
(from godotengine/godot-vscode-plugin#360)
GDShader grammar for float literals doesn't seem to match the one from GLSL ES 3.0 spec (section 4.1.4):
From my interpretation, an equivalent JS regex would be something like this:
/
\b(?:\d+[eE][-+]?\d+|(?:\d*[.]\d+|\d+[.])(?:[eE][-+]?\d+)?)[fF]?
/Below is some cases I tested (might not cover all problems).
Godot 4.0.alpha8
It's accepting floats like
0ef
,0e+f
,0.0ef
,0.0e-f
, which are invalid in GLSL. Which is strange because invalids like0e
,0.0e
are being rejected correctly. At least in the GLSL grammar above, the digits are always required after thee
in exponent notation. But something strange in gdshader grammar is accepting an empty number whenf
is present.Godot 3.4.4
This, on the other hand, seems to not allow lowercase
e
andf
together at all, even when the exponent number is present.It's rejecting valid:
0e0f
,0e+0f
,0.0e0f
,0.0e-0f
. When removing eithere...
orf
part, then it's accepting it as normal.It's also rejecting uppercase
E
exponents when they have a sign, even though it's fine in lowercase, e.g.:0E+0
,0.0E-0
.Steps to reproduce
Just create a
test.gdshader
file in a new Godot project and double click to open it in the internal Shader editor.Paste text below, and watch it for errors / non-errors.
Also syntax coloring is not exactly matching all tokens, even when compiler accepts them. Uppercase, for example, seems to mess with it.
Minimal reproduction project
This is not to cover all test cases by any means, just to facilitate testing some of the examples above. In a quick estimate, if all test cases were written (using just 0 in numbers), there should be ~81 (?) variations that should be accepted ... not to mention the ones to test rejection. So, it's better to just try to really carefully match the grammar/regex from the spec part by part and in tests try to break it with some edge cases. Multi-cursor feature in editors like VSCode may help with editing this to test other cases.
test.gdshader
The text was updated successfully, but these errors were encountered: