]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programparser.cpp
Rearrange GLSL qualifier parsing
[libs/gl.git] / source / programparser.cpp
index e7343547da1f5f736da555d68a1f4edeeef76a42..80917ba39834720b7711810b0844d3f4800e0e01 100644 (file)
@@ -449,7 +449,7 @@ RefPtr<Node> ProgramParser::parse_global_declaration()
        else if(is_interface_qualifier(token))
        {
                string next = peek_token(1);
-               if(is_type(next) || is_precision_qualifier(next))
+               if(is_type(next) || is_qualifier(next))
                        return parse_variable_declaration();
                else
                        return parse_interface_block();
@@ -718,25 +718,20 @@ RefPtr<VariableDeclaration> ProgramParser::parse_variable_declaration()
        RefPtr<VariableDeclaration> var = new VariableDeclaration;
 
        string token = peek_token();
-       if(is_sampling_qualifier(token))
+       while(is_qualifier(token))
        {
-               var->sampling = parse_token();
-               token = peek_token();
-               if(!is_interface_qualifier(token))
-                       throw runtime_error(format_syntax_error("an interface qualifier"));
-       }
-
-       if(is_interface_qualifier(token))
-               var->interface = parse_token();
-       else if(token=="const")
-       {
-               var->constant = true;
                parse_token();
+               if(is_interface_qualifier(token))
+                       var->interface = token;
+               else if(is_sampling_qualifier(token))
+                       var->sampling = token;
+               else if(is_precision_qualifier(token))
+                       var->precision = token;
+               else if(token=="const")
+                       var->constant = true;
+               token = peek_token();
        }
 
-       if(is_precision_qualifier(token))
-               var->precision = parse_token();
-
        var->type = expect_type();
        var->name = expect_identifier();
 
@@ -770,6 +765,9 @@ RefPtr<FunctionDeclaration> ProgramParser::parse_function_declaration()
                        expect(",");
 
                RefPtr<VariableDeclaration> var = new VariableDeclaration;
+               string token = peek_token();
+               if(token=="in" || token=="out" || token=="inout")
+                       var->interface = parse_token();
                var->type = expect_type();
                var->name = expect_identifier();
                func->parameters.push_back(var);