| 588 | } |
| 589 | |
| 590 | void ParseClassBody(Lexeme** str) |
| 591 | { |
| 592 | if(!ParseLexem(str, lex_ofigure)) |
| 593 | ThrowError((*str)->pos, "ERROR: '{' not found after class name"); |
| 594 | while((*str)->type != lex_cfigure) |
| 595 | { |
| 596 | if(ParseTypedefExpr(str)) |
| 597 | continue; |
| 598 | if(ParseLexem(str, lex_const)) |
| 599 | { |
| 600 | if(!ParseSelectType(str)) |
| 601 | ThrowError((*str)->pos, "ERROR: type name expected after const"); |
| 602 | if(GetSelectedType() && (GetSelectedType()->type == TypeInfo::TYPE_COMPLEX || GetSelectedType()->refLevel || GetSelectedType()->type == TypeInfo::TYPE_VOID)) |
| 603 | ThrowError((*str)->pos, "ERROR: only basic numeric types can be used as constants"); |
| 604 | TypeInfo *constType = GetSelectedType(); |
| 605 | TypeInfo::MemberVariable *prevConst = NULL; |
| 606 | do |
| 607 | { |
| 608 | if((*str)->type != lex_string) |
| 609 | ThrowError((*str)->pos, "ERROR: constant name expected after %s", prevConst ? "','" : "type"); |
| 610 | if((*str)->length >= NULLC_MAX_VARIABLE_NAME_LENGTH) |
| 611 | ThrowError((*str)->pos, "ERROR: member name length is limited to 2048 symbols"); |
| 612 | unsigned int memberNameLength = (*str)->length; |
| 613 | char *memberName = (char*)stringPool.Allocate(memberNameLength + 2); |
| 614 | memcpy(memberName, (*str)->pos, memberNameLength); |
| 615 | memberName[memberNameLength] = 0; |
| 616 | (*str)++; |
| 617 | if(!ParseLexem(str, lex_set)) |
| 618 | { |
| 619 | if(!prevConst) |
| 620 | ThrowError((*str)->pos, "ERROR: '=' not found after constant name"); |
| 621 | if(prevConst->type != typeChar && prevConst->type != typeShort && prevConst->type != typeInt && prevConst->type != typeLong) |
| 622 | ThrowError((*str)->pos, "ERROR: only integer constant list gets automatically incremented by 1"); |
| 623 | |
| 624 | CodeInfo::nodeList.push_back(prevConst->defaultValue); |
| 625 | CodeInfo::nodeList.push_back(new NodeNumber(1, typeInt)); |
| 626 | AddBinaryCommandNode((*str)->pos, cmdAdd); |
| 627 | }else{ |
| 628 | if(!ParseTernaryExpr(str)) |
| 629 | ThrowError((*str)->pos, "ERROR: expression not found after '='"); |
| 630 | } |
| 631 | SelectTypeByPointer(constType); |
| 632 | TypeAddConstant((*str)->pos, memberName); |
| 633 | prevConst = GetDefinedType()->lastVariable; |
| 634 | }while(ParseLexem(str, lex_comma)); |
| 635 | if(!ParseLexem(str, lex_semicolon)) |
| 636 | ThrowError((*str)->pos, "ERROR: ';' not found after constants"); |
| 637 | continue; |
| 638 | } |
| 639 | if(!ParseSelectType(str)) |
| 640 | { |
| 641 | if((*str)->type == lex_string) |
| 642 | ThrowError((*str)->pos, "ERROR: '%.*s' is not a known type name", (*str)->length, (*str)->pos); |
| 643 | break; |
| 644 | } |
| 645 | bool isVarDef = ((*str)->type == lex_string) && ((*str + 1)->type == lex_comma || (*str + 1)->type == lex_semicolon || (*str + 1)->type == lex_set); |
| 646 | if(isVarDef || !ParseFunctionDefinition(str)) |
| 647 | { |
no test coverage detected