X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramparser.cpp;h=11c9a9fe4060acd391b390cbb36749b82f998d6f;hb=5945ad9b63bbc55c3ed21f0c023d17f73aaac370;hp=16299d20cf157f8281fc2face34d55a21712eee1;hpb=a29cc14162e911b36d18d1d1896216697c7dc0c1;p=libs%2Fgl.git diff --git a/source/programparser.cpp b/source/programparser.cpp index 16299d20..11c9a9fe 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; @@ -656,7 +650,16 @@ InterfaceBlock *ProgramParser::parse_interface_block() iface->name = expect_identifier(); parse_block(iface->members, true); - expect(";"); + if(!check(";")) + { + iface->instance_name = expect_identifier(); + if(check("[")) + { + iface->array = true; + expect("]"); + } + expect(";"); + } return iface.release(); } @@ -724,7 +727,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(); }