X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramparser.cpp;h=83a2879f4feeaa92ba5e947149b45064b134ae44;hp=ca554f427464b8863b03ed8211c0f8598e2c7c03;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=71972b08fd031e177a005eb1924a5c7a15459291 diff --git a/source/programparser.cpp b/source/programparser.cpp index ca554f42..83a2879f 100644 --- a/source/programparser.cpp +++ b/source/programparser.cpp @@ -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(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");