]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programparser.cpp
Assorted refactoring and fixes
[libs/gl.git] / source / programparser.cpp
index 16299d20cf157f8281fc2face34d55a21712eee1..36cc6e081b1da26d5ef745b9bd7a66e8ff7099b5 100644 (file)
@@ -218,7 +218,6 @@ bool ProgramParser::skip_comment_and_whitespace()
        unsigned slashes = 0;
        while(iter!=source.end())
        {
-               //IO::print("%d '%c'\n", comment, *iter);
                if(comment==0)
                {
                        if(*iter=='/')
@@ -614,7 +613,18 @@ FunctionDeclaration *ProgramParser::parse_function_declaration()
 
        func->return_type = expect_type();
        func->name = expect_identifier();
-       parse_function_parameter_list(*func);
+       expect("(");
+       while(peek_token()!=")")
+       {
+               if(!func->parameters.empty())
+                       expect(",");
+
+               RefPtr<VariableDeclaration> var = new VariableDeclaration;
+               var->type = expect_type();
+               var->name = expect_identifier();
+               func->parameters.push_back(var.release());
+       }
+       expect(")");
 
        string token = peek_token();
        if(token=="{")
@@ -630,22 +640,6 @@ FunctionDeclaration *ProgramParser::parse_function_declaration()
        return func.release();
 }
 
-void ProgramParser::parse_function_parameter_list(FunctionDeclaration &func)
-{
-       expect("(");
-       while(peek_token()!=")")
-       {
-               if(!func.parameters.empty())
-                       expect(",");
-
-               RefPtr<VariableDeclaration> var = new VariableDeclaration;
-               var->type = expect_type();
-               var->name = expect_identifier();
-               func.parameters.push_back(var.release());
-       }
-       expect(")");
-}
-
 InterfaceBlock *ProgramParser::parse_interface_block()
 {
        RefPtr<InterfaceBlock> iface = new InterfaceBlock;
@@ -724,7 +718,8 @@ Return *ProgramParser::parse_return()
 {
        expect("return");
        RefPtr<Return> ret = new Return;
-       ret->expression = parse_expression();
+       if(peek_token()!=";")
+               ret->expression = parse_expression();
        expect(";");
        return ret.release();
 }