X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramparser.cpp;h=36cc6e081b1da26d5ef745b9bd7a66e8ff7099b5;hb=b3e71de19f35773c22391151ebb02062d6894bc9;hp=16299d20cf157f8281fc2face34d55a21712eee1;hpb=a29cc14162e911b36d18d1d1896216697c7dc0c1;p=libs%2Fgl.git diff --git a/source/programparser.cpp b/source/programparser.cpp index 16299d20..36cc6e08 100644 --- a/source/programparser.cpp +++ b/source/programparser.cpp @@ -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 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 var = new VariableDeclaration; - var->type = expect_type(); - var->name = expect_identifier(); - func.parameters.push_back(var.release()); - } - expect(")"); -} - InterfaceBlock *ProgramParser::parse_interface_block() { RefPtr iface = new InterfaceBlock; @@ -724,7 +718,8 @@ Return *ProgramParser::parse_return() { expect("return"); RefPtr ret = new Return; - ret->expression = parse_expression(); + if(peek_token()!=";") + ret->expression = parse_expression(); expect(";"); return ret.release(); }