Exemple #1
0
static void makeFunctionCallNode(ASTNode* result, MemoryStack* stack, char* name, ASTNode left, ASTNode right, int lineNumber = 0)
{
    result->nodeType = AST_FUNCTION_CALL;
    result->functionCall.lineNumber = lineNumber;
    result->functionCall.identifier = makeSlice(name);
    result->functionCall.arguments = {};

    *pushElement(&result->functionCall.arguments, stack) = left;
    *pushElement(&result->functionCall.arguments, stack) = right;
}
void ContextCrumblePath::updateContextPath(const QStringList &path, const QList<int> &debugIds)
{
    Q_ASSERT(path.count() == debugIds.count());

    clear();

    m_isEmpty = path.isEmpty();
    if (m_isEmpty) {
        pushElement(tr("[no context]"),QVariant(-1));
    } else {
        for (int i = 0; i < path.count(); i++)
            pushElement(path[i], QVariant(debugIds[i]));
    }
}
Exemple #3
0
static bool parseNotExpression(MemoryStack* stack, LexerCarriage* carriage, Array<SyntaxError>* errors, ASTNode* result)
{
    if (carriage->topToken.type == TOK_NOT)
    {
        parseNextToken(carriage);

        result->nodeType = AST_FUNCTION_CALL;
        result->functionCall.identifier = makeSlice("opNot");
        result->functionCall.arguments = {};

        ASTNode node;
        if (parseAddSubExpression(stack, carriage, errors, &node))
        {
            *pushElement(&result->functionCall.arguments, stack) = node;

            return true;
        }
        else
            return false;
    }
    else
    {
        return parseAddSubExpression(stack, carriage, errors, result);
    }
}
Exemple #4
0
static T* scopePushToList(Scope* scope, MemoryStack* stack, LinkedList<T>* list)
{
    T* elem = pushElement(list, stack);
    scope->totalMemoryAllocated += sizeof(ListNode<T>);

    return elem;
}
Exemple #5
0
static void parseStatements(MemoryStack* stack, LexerCarriage* carriage, Array<SyntaxError>* errors, LinkedList<ASTNode>* result)
{
    ASTNode statement;
    do
    {
        if (parseStatement(stack, carriage, errors, &statement))
            *pushElement(result, stack) = statement;
        else
            break;
    } while (true);
}
Exemple #6
0
Handle<Value> XML::NewElement(const Arguments& args) {
	HandleScope scope;
	Shell *shell = Shell::Instance();
	Context::Scope context_scope(shell->globalContext);	
	if (args.Length() != 1) {
		return v8::ThrowException(v8::String::New("Need Parameters"));
	}	
	Handle<Value> arg = args[0];
	String::Utf8Value value(arg);
	XMLElement *new_element = new XMLElement(*value);
	pushElement(new_element);
	Handle<Object> newObject = new_element->registerObject();

	return(scope.Close(newObject));
}
Exemple #7
0
static bool parseFunctionCall(MemoryStack* stack, LexerCarriage* carriage, Array<SyntaxError>* errors, ASTNode* result)
{
    LexerCarriage tmpCarriage = *carriage;

    if (tmpCarriage.topToken.type == TOK_IDENTIFIER)
    {
        Token identifier = tmpCarriage.topToken;
        parseNextToken(&tmpCarriage);

        if (tmpCarriage.topToken.type == TOK_OPEN_BRACKET)
        {
            parseNextToken(&tmpCarriage);

            result->nodeType = AST_FUNCTION_CALL;
            result->functionCall.lineNumber = carriage->currentLineNumber;
            result->functionCall.identifier = identifier.identifierValue;
            result->functionCall.arguments = { };

            if (tmpCarriage.topToken.type != TOK_CLOSE_BRACKET)
            {
                ASTNode argument;
                do {
                    if (parseExpression(stack, &tmpCarriage, errors, &argument))
                    {
                        *pushElement(&result->functionCall.arguments, stack) = argument;
    
                        if (tmpCarriage.topToken.type == TOK_COMMA)
                            parseNextToken(&tmpCarriage);
                        else
                            break;
                    }
                    else
                    {
                        pushBack(errors, SyntaxError{ SET_EXPRESSION_EXPECTED });
                        break;
                    }
                } while (true);
            }

            expectAndEat(&tmpCarriage, TOK_CLOSE_BRACKET, errors);
            *carriage = tmpCarriage;

            return true;
        }
    }

    return false;
}
Exemple #8
0
static bool parseStatement(MemoryStack* stack, LexerCarriage* carriage, Array<SyntaxError>* errors, ASTNode* result)
{
    if (parseVariableDefinition(stack, carriage, errors, result)) return true;
    if (parseFunctionCall(stack, carriage, errors, result)) return true;
    if (parseAssignment(stack, carriage, errors, result)) return true;

    if (carriage->topToken.type == TOK_IDENTIFIER)
    {
        Token identifier = carriage->topToken;
        parseNextToken(carriage);

        if (carriage->topToken.type == TOK_DOUBLE_DOT)
        {
            parseNextToken(carriage);

            if (carriage->topToken.type == TOK_OPEN_BRACKET) // function definition
            {
                parseNextToken(carriage);

                result->nodeType = AST_STATEMENT_FUNCTION_DEFINITION;
                result->functionDefinition.lineNumber = carriage->currentLineNumber;
                result->functionDefinition.identifier = identifier.identifierValue;

                ASTNode arg;
                LinkedList<ASTNode> args = {};

                if (carriage->topToken.type != TOK_CLOSE_BRACKET)
                {
                    while (true)
                    {
                        if (parseVariableDefinition(stack, carriage, errors, &arg))
                        {
                            *pushElement(&args, stack) = arg;

                            if (carriage->topToken.type != TOK_COMMA)
                                break;
                            else
                                parseNextToken(carriage); // pop ,
                        }
                        else
                        {
                            pushBack(errors, SyntaxError{ SET_EXPRESSION_EXPECTED });
                            break;
                        }
                    };
                }

                expectAndEat(carriage, TOK_CLOSE_BRACKET, errors);
                result->functionDefinition.arguments = args;

                if (carriage->topToken.type != TOK_VOID)
                {
                    result->functionDefinition.returnType = pushMemory<ASTNode>(stack);
                    if (!parseTypeIdentifier(stack, carriage, errors, result->functionDefinition.returnType))
                    {
                        // TODO: change this
                        SyntaxError error = SyntaxError{ SET_UNEXPECTED_TOKEN };
                        error.unexpectedToken.token = carriage->topToken;
                        error.unexpectedToken.expecting = TOK_IDENTIFIER;

                        pushBack(errors, error);
                    }
                }
                else
                {
                    parseNextToken(carriage);
                    result->functionDefinition.returnType = nullptr;
                }

                result->functionDefinition.body = nullptr;
                if (carriage->topToken.type == TOK_ASSIGN)
                {
                    parseNextToken(carriage);

                    result->functionDefinition.body = pushMemory<ASTNode>(stack);
                    expectAndEatStatement(stack, carriage, errors, result->functionDefinition.body);
                }

                return true;
            }
            else if (carriage->topToken.type == TOK_STRUCT)
            {
                parseNextToken(carriage);
                expectAndEat(carriage, TOK_ASSIGN, errors);
                int bracesOpenedAt = carriage->currentLineNumber;

                expectAndEat(carriage, TOK_OPEN_BRACES, errors);

                result->nodeType = AST_STATEMENT_TYPE_DEFINITION;
                result->typeDefinition.lineNumber = carriage->currentLineNumber;
                result->typeDefinition.identifier = identifier.identifierValue;
                result->typeDefinition.definitions = {};

                ASTNode definition;
                do
                {
                    if (parseVariableDefinition(stack, carriage, errors, &definition))
                        *pushElement(&result->typeDefinition.definitions, stack) = definition;
                    else
                        break;
                } while (true);

                if (carriage->topToken.type == TOK_CLOSE_BRACES)
                    parseNextToken(carriage);
                else
                {
                    SyntaxError error = { SET_UNCLOSED_BRACKETS, bracesOpenedAt };
                    error.unclosedBrackets.closedAt = carriage->currentLineNumber;
                    error.unclosedBrackets.token = carriage->topToken;

                    pushBack(errors, error);
                }

                return true;
            }
            else
            {
                // TODO: error
            }
        }
        else
        {
            // TODO: error
        }
    }
    else if (carriage->topToken.type == TOK_OPEN_BRACES)
    {
        int openedAt = carriage->currentLineNumber;
        parseNextToken(carriage);

        result->nodeType = AST_STATEMENTS_BLOCK;
        result->statementsBlock.statements = { };

        parseStatements(stack, carriage, errors, &result->statementsBlock.statements);
        if (carriage->topToken.type == TOK_CLOSE_BRACES)
            parseNextToken(carriage);
        else
        {
            SyntaxError error = SyntaxError{ SET_UNCLOSED_BRACKETS, openedAt };
            error.unclosedBrackets.closedAt = carriage->currentLineNumber;
            error.unclosedBrackets.token = carriage->topToken;

            pushBack(errors, error);
        }

        return true;
    }
    else if (carriage->topToken.type == TOK_IF)
    {
        parseNextToken(carriage);

        result->nodeType = AST_STATEMENT_IF;
        result->ifStatement.condition = pushMemory<ASTNode>(stack);
        result->ifStatement.ifCase = pushMemory<ASTNode>(stack);

        expectAndEatExpression(stack, carriage, errors, result->ifStatement.condition);
        expectAndEatStatement(stack, carriage, errors, result->ifStatement.ifCase);

        if (carriage->topToken.type == TOK_ELSE)
        {
            parseNextToken(carriage);

            result->ifStatement.elseCase = pushMemory<ASTNode>(stack);
            expectAndEatStatement(stack, carriage, errors, result->ifStatement.elseCase);
        }
        else
            result->ifStatement.elseCase = nullptr;

        return true;
    }
    else if (carriage->topToken.type == TOK_WHILE)
    {
        parseNextToken(carriage);

        result->nodeType = AST_STATEMENT_WHILE;
        result->whileStatement.condition = pushMemory<ASTNode>(stack);
        result->whileStatement.body = pushMemory<ASTNode>(stack);

        expectAndEatExpression(stack, carriage, errors, result->whileStatement.condition);
        expectAndEatStatement(stack, carriage, errors, result->whileStatement.body);

        return true;
    }

    return false;
}
Exemple #9
0
void executeProgram(Program* program) {

	Stack stack;
	int arg_pos;

	initStack(&stack, program->size * 16, MAX_ARG_SIZE);
	if(stack.elements == NULL)
		return;

	program->lineNumber = 0;

	while(program->lineNumber < program->size) {
		char* line;
		
		line = &program->lines[program->lineNumber*MAX_LINE_SIZE];

		if((arg_pos = parseCmd(PUSH_CMD, line)) > 0) {
			pushElement(&stack, line+arg_pos);
			program->lineNumber++;
		}
		else if((arg_pos = parseCmd(POP_CMD, line)) > 0)	{
			char* element;
			int len;

			element = (char *) popElement(&stack);

			len = strnlen(element, MAX_ARG_SIZE);
			memset(element, 0, len);

			program->lineNumber++;
		}
		else if((arg_pos = parseCmd(ADD_CMD, line)) > 0) {
			int a, b, ret;
			char *a_str;
			char *a_element;
			char *b_element;
			int len;

			a_element = popElement(&stack);
			b_element = popElement(&stack);

			a = strn2int(a_element, MAX_ARG_SIZE);
			b = strn2int(b_element, MAX_ARG_SIZE);
			a += b;
			a_str = itoaB10(a); 

			len = strnlen(a_element, MAX_ARG_SIZE);
			memset(a_element, 0, len);

			len = strnlen(b_element, MAX_ARG_SIZE);
			memset(b_element, 0, len);

			len = strlen(a_str);
			pushElement(&stack, a_str);
			
			ret = deallocate(a_str, len); 
			if (ret != 0)
				_terminate(11);

			program->lineNumber++;
		}
		else if((arg_pos = parseCmd(PRINT_CMD, line)) > 0) {
			int ret, len;
			char *element;

			element = (char *) popElement(&stack);
			ret = transmit_all(STDOUT, element, strnlen(element, MAX_ARG_SIZE));
			if (ret != 0)
				_terminate(14);			
			ret = transmit_all(STDOUT, NEWLINE, strnlen(NEWLINE, MAX_ARG_SIZE));
			if (ret != 0)
				_terminate(15);	

			len = strnlen(element, MAX_ARG_SIZE);
			memset(element, 0, len);

			program->lineNumber++;
		}
		else if((arg_pos = parseCmd(COPY_CMD, line)) > 0) {
			int copy_num;
			int ret, i;

			copy_num = strn2int(line+arg_pos, MAX_ARG_SIZE);
			if(copy_num < 1) {
				program->lineNumber++;
				continue;
			}

			char *element;
			element = popElement(&stack);

			for(i=0; i<copy_num; i++) {
				pushElement(&stack, element);
			}

			program->lineNumber++;
		} else
			program->lineNumber++;

	}

	destroyStack(&stack);

}
Exemple #10
0
XMLElement *XML::newElement(std::string name) {
	XMLElement *new_element = new XMLElement(name);
	pushElement(new_element);
	return(new_element);
}	
Exemple #11
0
DMJSON * Parser::parseCode(char* code_char_string, int string_length) {

	indicator_stack_top = 0;
	CodeIndicator * indicator = indicator_stack + indicator_stack_top; //current indicator
	DMJSON * root = this->json_pool->getDMJSON();
	root->type = 34;
	indicator->code = root;
	indicator->parse_status = 14;

	DMString * code_string = newDMString(string_length);
	code_string->copy(code_char_string, string_length);
	char* char_string = code_string->char_string;

	char preChar;
	char localChar = 0;
	char nextChar;
	int last_index = 0;
	int i = -1;

	int line_number = 0;
	while (true) {
		if (i >= string_length) {
			break;
		} else {
			i++;
		}

		if (last_index > i) {
			continue;
		}
		preChar = localChar;
		localChar = char_string[i];
		nextChar = char_string[i + 1];
		if (localChar == '\n') {
			line_number++;
		}

		if (indicator->parse_status == 51) { //@operator@
			if (isOperator(localChar)) {
				continue;
			}

			indicator->end = i;

			DMString * dm_string = parseDMString(char_string, indicator);
			dm_string->type = TYPE_CODE_OPERATOR;

			clearCodeIndicator(indicator);
			indicator_stack_top--;
			indicator = indicator_stack + indicator_stack_top;

			pushMeta((MemorySpace *) dm_string, indicator);

			last_index = i;
		}

		if (indicator->parse_status == 41) { //"string"
			int string_state = checkString(preChar, localChar, nextChar);

			if (string_state == 0 || indicator->flag != string_state || indicator->start + 1 > i) {
				continue;
			}

			if (string_state % 10 == 1) {
				indicator->end = i;
				last_index = i + 1;
			} else if (string_state % 10 == 3) {
				indicator->end = i - 1;
				last_index = i + 2;
			}
			DMString * dm_string = parseDMString(char_string, indicator);

			clearCodeIndicator(indicator);
			indicator_stack_top--;
			indicator = indicator_stack + indicator_stack_top;
			pushMeta((MemorySpace *) dm_string, indicator);
			continue;

		}

		if (indicator->parse_status == 61) { // //comments
			if (isLineEnd(localChar)) {
				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
				last_index = i + 2;
			} else {
				continue;
			}
		}

		if (isLetter(localChar)) {
			if (indicator->isInLine == NOT_IN_LINE) {
				indicator->isInLine = IN_LINE;
			}
			if (indicator->isInWord == NOT_IN_WORD) {
				indicator->isInWord = IN_WORD;
			}
			continue;
		} else {
			if (indicator->isInWord == IN_WORD && indicator->isInLine == IN_LINE) {
				if (last_index < i) {
					MemorySpace * element = parseElement(char_string, last_index, i);
					pushMeta(element, indicator);
				}
				last_index = i + 1;
				indicator->isInWord = NOT_IN_WORD;
			}
		}

		if (indicator->parse_status != 74) {
			if (indicator->includer == NULL) {

			} else if (indicator->includer->type == 80) {
				DMJSON * last_includer = indicator->includer;

				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->parse_status = 74;
				indicator->includer = last_includer;
				indicator->isInLine = IN_LINE;
			} else if (indicator->includer->type == 33) {
				DMJSON * last_includer = indicator->includer;

				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->parse_status = 33;
				indicator->code = last_includer;
				indicator->isInLine = IN_LINE;

			} else {

			}
		}

		if (isLineEnd(localChar)) {
			if (indicator->isInLine == NOT_IN_LINE) {
				last_index = i + 1;
				continue;
			} else {
				indicator->isInLine = NOT_IN_LINE;
			}

			if (indicator->parse_status == 74) {
				DMJSON * last_expression = indicator->includer;

				MemorySpace * last_meta = last_expression->get(-1, NOT_DEL);
				if (last_meta == NULL) {
				} else if (last_meta->type == TYPE_CODE_OPERATOR) {
					continue;
				}

				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;

				MemorySpace * element = resolveExpression(last_expression);
				pushElement(element, indicator);
				indicator->includer = NULL;

			}

			if (indicator->parse_status == 33) {
				DMJSON* functionReturn = indicator->code;

				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;

				pushElement(functionReturn->self, indicator);
				indicator->includer = NULL;
			}

			if (indicator->parse_status == 81) {
				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
			}

			last_index = i + 1;
			continue;
		}

		if (isBlank(localChar)) {
			if (indicator->isInWord == NOT_IN_WORD) {
				last_index = i + 1;
				continue;
			}

			if (indicator->parse_status == 31) {
				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
				last_index = i + 1;
				continue;
			}

			if (indicator->parse_status == 32) {
				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
				last_index = i + 1;
				continue;
			}

			if (indicator->parse_status == 33) {

				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
				last_index = i + 1;
				continue;
			}

			if (indicator->parse_status == 22) {
				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
				last_index = i + 1;
				continue;
			}

			last_index = i + 1;
			continue;
		}

		if (isSeparator(localChar)) {

			if (indicator->parse_status == 74) {
				DMJSON * last_expression = indicator->includer;

				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;

				MemorySpace * element = resolveExpression(last_expression);
				pushElement(element, indicator);
				indicator->includer = NULL;

			}

			if (indicator->parse_status == 81) {
				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
			}

			if (indicator->parse_status == 12) {
				DMJSON * last_function_definition = indicator->includer;

				if (last_function_definition == NULL) {
				} else if (last_function_definition->type == 30) {
					pushElement(last_function_definition->self, indicator);
					indicator->includer = NULL;
				} else {
					//syntax error
				}

			}
			last_index = i + 1;
			continue;
		}
		if (localChar == ':') {

			MemorySpace * key = NULL;

			if (indicator->parse_status == 74) {
				DMJSON * last_expression = indicator->includer;

				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;

				MemorySpace * element = resolveExpression(last_expression);

				if (element->type == TYPE_CODE_NAME) {
					key = element;
					CodeName * key_name = (CodeName *) key;
					key_name->nameType = 0x99;
				} else if (element->type == TYPE_STRING) {
					key = element;
					key->type = TYPE_CODE_NAME;
					CodeName * key_name = (CodeName *) key;
					key_name->nameType = 0x99;
				} else {
					//syntax error
				}

				indicator->includer = NULL;

				last_index = i + 1;
			}

			if (key != NULL && (indicator->parse_status == 11 || indicator->parse_status == 21)) {

				DMKeyValue * key_value = newDMKeyValue();
				key_value->key = key;

				DMJSON * parent = indicator->code;
				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->key_value = key_value;
				indicator->parse_status = 81;

				parent->set(-1, key_value->self, NOT_REPLACE);
			}
			last_index = i + 1;
			continue;
		}

		int string_state = checkString(preChar, localChar, nextChar);
		if (0 != string_state) {
			if (indicator->parse_status != 41) {
				if (string_state == 12 || string_state == 22) {
					DMString * dm_string = newDMString(0);
					pushMeta((MemorySpace *) dm_string, indicator);
					last_index = i + 1;
					continue;
				}
				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->parse_status = 41;
				indicator->flag = string_state;
				if (string_state % 10 == 1) {
					indicator->start = i + 1;
				} else if (string_state % 10 == 3) {
					indicator->start = i + 2;
				}
				continue;
			} else {
				//logic error
			}
		}

		if (localChar == '/' && nextChar == '/') {

			indicator_stack_top++;
			indicator = indicator_stack + indicator_stack_top;
			indicator->parse_status = 61;
			last_index = i + 1;
			continue;
		}

		if (isBracket(localChar)) {
			if (localChar == '{') {
				if (indicator->includer == NULL) {
					DMJSON* includer = this->json_pool->getDMJSON();
					includer->type = 80;
					indicator->includer = includer;
				}

				DMJSON * last_includer = indicator->includer;
				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->start = i;
				if (last_includer != NULL && last_includer->type == 20) {
					indicator->parse_status = 12;
					indicator->code = last_includer;
				} else if (last_includer != NULL && last_includer->type == 30) {
					indicator->parse_status = 13;
					indicator->code = last_includer;
				} else if (last_includer != NULL && last_includer->type / 10 == 4) {
					indicator->parse_status = 14;
					indicator->code = last_includer;
				} else {
					indicator->parse_status = 11;
					DMJSON* json = this->json_pool->getDMJSON();
					json->type = 0;
					indicator->code = json;
					last_includer->set(-1, json->self, NOT_REPLACE);
				}
				last_index = i + 1;
				continue;
			}

			if (localChar == '}') {

				if (indicator->parse_status == 74) {
					DMJSON * last_expression = indicator->includer;

					clearCodeIndicator(indicator);
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;

					MemorySpace * element = resolveExpression(last_expression);
					pushElement(element, indicator);
					indicator->includer = NULL;
				}

				if (indicator->parse_status == 81) {
					clearCodeIndicator(indicator);
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;
					last_index = i + 1;
				}

				if (indicator->parse_status / 10 != 1) {
					//syntax error
					break;
				}
				DMJSON * code = indicator->code;

				clearCodeIndicator(indicator);
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;
				if (indicator->parse_status == 11 && code->type == 0) {
				} else if (indicator->parse_status == 12 || indicator->parse_status == 13 || indicator->parse_status == 14) {
					pushElement(code->self, indicator);
					indicator->includer = NULL;
				} else if (indicator->parse_status == 74) {
					clearCodeIndicator(indicator);
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;
				}
				last_index = i + 1;
				continue;
			}

			if (localChar == '[') {

				if (indicator->includer == NULL) {
					DMJSON* includer = this->json_pool->getDMJSON();
					includer->type = 80;
					indicator->includer = includer;
				}

				CodeIndicator * last_indicator = indicator;
				DMJSON * last_includer = indicator->includer;

				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->start = i;

				MemorySpace * last_meta = last_indicator->last_meta;

				if (last_meta == NULL) {
					if (last_includer != NULL) {
						last_meta = last_includer->get(-1, NOT_DEL);
					}
				}
				if (last_meta == NULL) { //21:[json]
					indicator->parse_status = 21;
					DMJSON* json = this->json_pool->getDMJSON();
					json->type = 0;
					indicator->code = json;
					last_includer->set(-1, json->self, NOT_REPLACE);
				} else if (last_meta->type == TYPE_CODE_KEYWORD) { //has with 22:[enum] in: 21:[json]
					DMString *last_keyword = (DMString *) last_meta;

					if (*last_keyword == "with" || *last_keyword == "has") {
						indicator->parse_status = 22;
						DMJSON* enumDefinition = this->json_pool->getDMJSON();
						enumDefinition->type = 61;
						indicator->code = enumDefinition;
						last_includer->set(-1, enumDefinition->self, NOT_REPLACE);
					} else if (*last_keyword == "in" || *last_keyword == "import") {
						indicator->parse_status = 21;
						DMJSON* json = this->json_pool->getDMJSON();
						json->type = 0;
						indicator->code = json;
						last_includer->set(-1, json->self, NOT_REPLACE);
					} else {
						//syntax error
						break;
					}

				} else if (last_meta->type == TYPE_CODE_NAME) { //23:[key|index|selector],
					indicator->parse_status = 23;
					DMJSON* selector = this->json_pool->getDMJSON();
					selector->type = 71;
					indicator->code = selector;

					last_includer->set(-1, selector->self, NOT_REPLACE);
				} else { //21:[json]
					indicator->parse_status = 21;
					DMJSON* json = this->json_pool->getDMJSON();
					json->type = 0;
					indicator->code = json;
					last_includer->set(-1, json->self, NOT_REPLACE);
				}
				last_index = i + 1;
				continue;
			}

			if (localChar == ']') {

				if (indicator->parse_status == 74) {
					DMJSON * last_expression = indicator->includer;

					clearCodeIndicator(indicator);
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;

					MemorySpace * element = resolveExpression(last_expression);
					pushElement(element, indicator);
					indicator->includer = NULL;
				}

				if (indicator->parse_status == 81) {
					clearCodeIndicator(indicator);
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;
					last_index = i + 1;
				}

				if (indicator->parse_status / 10 != 2) {
					//syntax error
					break;
				}
				DMJSON * code = indicator->code;

				CodeIndicator * last_indicator = indicator;

				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;

				clearCodeIndicator(last_indicator);
				if (indicator->parse_status == 21 && code->type == 0) {
				} else if (indicator->parse_status == 12 || indicator->parse_status == 13 || indicator->parse_status == 14) {
					pushElement(code->self, indicator);
					indicator->includer = NULL;
				} else if (indicator->parse_status == 74) {
					clearCodeIndicator(indicator);
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;
				}

				last_index = i + 1;
				continue;
			}

			if (localChar == '(') {
				if (indicator->includer == NULL) {
					DMJSON* includer = this->json_pool->getDMJSON();
					includer->type = 80;
					indicator->includer = includer;
				}

				CodeIndicator * last_indicator = indicator;
				if (last_indicator->parse_status == 33) {
					last_index = i + 1;
					continue;
				}
				DMJSON * last_includer = indicator->includer;

				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->start = i;
				if (last_includer != NULL && last_includer->type == 30) {
					indicator->parse_status = 31;
					indicator->code = last_includer;
				} else if (last_includer != NULL && last_includer->type / 10 == 4) {
					indicator->parse_status = 35;
					indicator->code = last_includer;
//					last_includer->set(-1, last_includer->self, NOT_REPLACE);

				} else if (last_includer != NULL && last_includer->type == 33) {
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;
					if (indicator->parse_status != 33) {
						//syntax error
						break;
					}
				} else {
					MemorySpace * last_meta = last_includer->get(-1, NOT_DEL);
					if (last_meta != NULL && last_meta->type == TYPE_CODE_NAME) { //function call ()
						if (last_includer->dm_list->length > 0) {
							CodeName * function_name = (CodeName *) last_includer->get(-1, DEL);
							if (function_name->nameType != 0x82 || function_name->nameType != 0x83) {
								function_name->nameType = 0x81;
							}
							DMJSON * functionCall = this->json_pool->getDMJSON();
							functionCall->type = 32;

							functionCall->name = (DMString *) function_name;

							indicator->parse_status = 32;
							indicator->code = functionCall;

							last_includer->set(-1, functionCall->self, NOT_REPLACE);
						} else {
							//syntax error
							break;
						}
					} else if (last_meta != NULL && last_meta->type == TYPE_JSON) { //Anonymous function definition
						if (last_includer->dm_list->length > 0) {
							MemorySpace * function_definition_space = last_includer->get(-1, NOT_DEL);

							DMJSON * functionDefinition = (DMJSON *) function_definition_space->pointer;
							if (functionDefinition->type != 30) {
								//syntax error
								break;
							}

							MemorySpace * name = last_includer->get(-3, NOT_DEL);
							if (name == NULL && indicator_stack_top >= 2) {
								CodeIndicator * last_last_indicator = indicator_stack + indicator_stack_top - 2;
								if (last_last_indicator->parse_status == 81 && last_last_indicator->key_value != NULL) {
									name = last_last_indicator->key_value->key;
								}
							}
							if (name == NULL) {
								functionDefinition->name = this->helper->no_name;
							} else if (name->type == TYPE_JSON) {
								DMJSON * selector = (DMJSON *) name->pointer;
								if (selector->type != 71) {
									//syntax error
								}
								DMString * function_name = (DMString *) selector->get(-1, NOT_DEL);
								if (function_name == NULL) {
									functionDefinition->name = this->helper->no_name;
								} else if (function_name->type == TYPE_CODE_NAME || function_name->type == TYPE_STRING) {
									functionDefinition->name = function_name;
								} else {
									functionDefinition->name = this->helper->no_name;
								}

							} else if (name->type == TYPE_CODE_NAME) {
								DMString * function_name = spliteFunctionName((DMString *) name);
								functionDefinition->name = function_name;

							} else {
								//syntax error
								break;
							}

							indicator->parse_status = 74;
							indicator->includer = functionDefinition;

							indicator_stack_top++;
							indicator = indicator_stack + indicator_stack_top;
							indicator->parse_status = 31;
							indicator->code = functionDefinition;

						} else {
							//syntax error
							break;
						}
					} else { //expression ()
						DMJSON * expression = this->json_pool->getDMJSON();
						expression->type = 10;

						indicator->parse_status = 34;
						indicator->includer = expression;

						last_includer->set(-1, expression->self, NOT_REPLACE);
					}
				}

				last_index = i + 1;
				continue;
			}

			if (localChar == ')') {

				if (indicator->parse_status == 74) {
					DMJSON * last_expression = indicator->includer;

					clearCodeIndicator(indicator);
					indicator_stack_top--;
					indicator = indicator_stack + indicator_stack_top;

					MemorySpace * element = resolveExpression(last_expression);
					pushElement(element, indicator);
					indicator->includer = NULL;
				}

				CodeIndicator * last_indicator = indicator;
				indicator_stack_top--;
				indicator = indicator_stack + indicator_stack_top;

				if (last_indicator->parse_status == 31) {
					last_indicator->code->block_start = last_indicator->code->dm_list->length;
				} else if (last_indicator->parse_status == 32) {
				} else if (last_indicator->parse_status == 33) {
					DMJSON* functionReturn = last_indicator->code;
					pushElement(functionReturn->self, indicator);
					indicator->includer = NULL;
				} else if (last_indicator->parse_status == 34) {
				} else if (last_indicator->parse_status == 35) {
					last_indicator->code->block_start = last_indicator->code->dm_list->length;
				} else {
					//syntax error
					break;
				}

				clearCodeIndicator(last_indicator);

				last_index = i + 1;
				continue;
			}
		}

		if (isOperator(localChar)) {

			if (indicator->parse_status != 51) {

				indicator_stack_top++;
				indicator = indicator_stack + indicator_stack_top;
				indicator->parse_status = 51;
				indicator->start = i;

				last_index = i;
				continue;
			}
		}

	}

	return root;
}