| 1761 | } |
| 1762 | |
| 1763 | bool ParseArray(Lexeme** str) |
| 1764 | { |
| 1765 | if(!ParseLexem(str, lex_ofigure)) |
| 1766 | return false; |
| 1767 | |
| 1768 | if((*str)->type == lex_for) |
| 1769 | { |
| 1770 | // coroutine auto(){ |
| 1771 | BeginCoroutine(); |
| 1772 | SelectTypeByPointer(NULL); |
| 1773 | |
| 1774 | static int generatorFuncCount = 0; |
| 1775 | char *functionName = (char*)stringPool.Allocate(16); |
| 1776 | sprintf(functionName, "$genl%d", generatorFuncCount); |
| 1777 | generatorFuncCount++; |
| 1778 | FunctionAdd((*str)->pos, functionName); |
| 1779 | FunctionStart((*str)->pos); |
| 1780 | ParseCode(str); |
| 1781 | AddGeneratorReturnData((*str)->pos); |
| 1782 | TypeInfo *retType = GetSelectedType(); |
| 1783 | AddReturnNode((*str)->pos); |
| 1784 | AddTwoExpressionNode(); |
| 1785 | |
| 1786 | FunctionEnd((*str)->pos); |
| 1787 | |
| 1788 | if(!AddFunctionCallNode((*str)->pos, "$gen_list", 1, true)) |
| 1789 | { |
| 1790 | // cannot find generator, create new |
| 1791 | NodeZeroOP *last = CodeInfo::nodeList.back(); |
| 1792 | CodeInfo::nodeList.pop_back(); |
| 1793 | AddListGenerator((*str)->pos, retType); |
| 1794 | CodeInfo::nodeList.push_back(last); |
| 1795 | AddFunctionCallNode((*str)->pos, "$gen_list", 1); |
| 1796 | AddTwoExpressionNode(CodeInfo::GetArrayType((TypeInfo*)retType, TypeInfo::UNSIZED_ARRAY)); |
| 1797 | } |
| 1798 | |
| 1799 | }else{ |
| 1800 | unsigned int arrElementCount = 0; |
| 1801 | if(!ParseTernaryExpr(str)) |
| 1802 | ThrowError((*str)->pos, "ERROR: value not found after '{'"); |
| 1803 | while(ParseLexem(str, lex_comma)) |
| 1804 | { |
| 1805 | if(!ParseTernaryExpr(str)) |
| 1806 | ThrowError((*str)->pos, "ERROR: value not found after ','"); |
| 1807 | arrElementCount++; |
| 1808 | } |
| 1809 | AddArrayConstructor((*str)->pos, arrElementCount); |
| 1810 | } |
| 1811 | if(!ParseLexem(str, lex_cfigure)) |
| 1812 | ThrowError((*str)->pos, "ERROR: '}' not found after inline array"); |
| 1813 | |
| 1814 | return true; |
| 1815 | } |
| 1816 | |
| 1817 | bool ParseVariable(Lexeme** str, bool *lastIsFunctionCall = NULL) |
| 1818 | { |
no test coverage detected