bool ProgramParser::is_builtin_type(const string &token)
{
- static Regex re("^(void|float|int|bool|[ib]?vec[234]|mat[234](x[234])?|sampler((1D|2D)(Array)?(Shadow)?|Cube(Shadow)?|3D))$");
+ static Regex re("^(void|float|int|bool|[ib]?vec[234]|mat[234](x[234])?|sampler((1D|2D|Cube)(Array)?(Shadow)?|3D))$");
return re.match(token);
}
string token = peek_token();
if(token=="pragma")
preprocess_pragma();
+ else if(token=="version")
+ preprocess_version();
else if(token=="define" || token=="undef" || token=="if" || token=="ifdef" || token=="ifndef" || token=="else" ||
- token=="elif" || token=="endif" || token=="error" || token=="extension" || token=="version" || token=="line")
+ token=="elif" || token=="endif" || token=="error" || token=="extension" || token=="line")
throw runtime_error(format_error(format("Unsupported preprocessor directive '%s'", token)));
else if(!token.empty())
throw runtime_error(format_syntax_error("a preprocessor directive"));
iter = line_end;
}
+void ProgramParser::preprocess_version()
+{
+ expect("version");
+ string token = parse_token();
+ unsigned version = lexical_cast<unsigned>(token);
+ cur_stage->required_version = Version(version/100, version%100);
+
+ token = parse_token();
+ if(!token.empty())
+ throw runtime_error(format_syntax_error("end of line"));
+}
+
void ProgramParser::preprocess_pragma()
{
expect("pragma");