Closed bkaradzic closed 8 years ago
I don't think I wrote support for ternaries.
It would be preferable to add support for it since it's supported by GLSL. Or at least syntax error. :)
Yes, adding support would be ideal.
Implemented support in df0e456
I found 2 issues now:
The first one is that code:
void test(float x) {
float y = x >= 0.0 ? 1.0 : 0.0;
}
Gets converted to (it should stay as float):
void test(float x) {
float y = x >= 0 ? 1 : 0;
}
The other issue is also related to this but I don't have simple repro case:
Basically I have to trim .0
from condition, otherwise it crashes in lexer.cpp line 126:
#12 0x0000000000411df3 in glsl::lexer::read (this=0x7fffffffd728, out=...) at ../../../3rdparty/glsl-parser/lexer.cpp:126
121 }
122
123 std::vector<char> numeric = readNumeric(isOctalish, isHexish);
124 if (position() != m_length && at() == '.') {
125 isFloat = true;
126 numeric.push_back('.');
127 m_location.advanceColumn();
128 std::vector<char> others = readNumeric(isOctalish, isHexish);
129 numeric.reserve(numeric.size() + others.size());
130 numeric.insert(numeric.end(), others.begin(), others.end());
Actually ignore the second issue, it was bug in my code, just causing crash here...
Fixed the float printing issue in 61613fe
Need example code that causes the lexer to crash
Pushed some code in fa2e14a to find malformatted floating literals which could get through into the parser and cause some bizzare bugs.
It's non-issue. It was my code that caused corruption, that led to crash...
Anyhow, I'm planning to use your lib as starting point for new bgfx-shaderc compiler (https://bkaradzic.github.io/bgfx/index.html). I'll be adding more test cases from code I have.
Here is simple repro case: