]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programparser.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / programparser.cpp
index ca554f427464b8863b03ed8211c0f8598e2c7c03..83a2879f4feeaa92ba5e947149b45064b134ae44 100644 (file)
@@ -343,7 +343,7 @@ bool ProgramParser::is_qualifier(const string &token)
 
 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);
 }
 
@@ -369,8 +369,10 @@ void ProgramParser::preprocess()
        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"));
@@ -378,6 +380,18 @@ void ProgramParser::preprocess()
        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");