/*! Do parse. \return TRUE if parsing was successful, otherwise FALSE */ syx_bool syx_parser_parse (SyxParser *self, syx_bool skip_message_pattern) { SyxToken token; SyxParserScope scope; token = syx_lexer_next_token (self->lexer); if (token.type == SYX_TOKEN_END) return TRUE; if (skip_message_pattern) { scope.start = self->_argument_names_top; scope.end = self->_argument_names_top; self->_argument_scopes.stack[(syx_int32) self->_argument_scopes.top++] = scope; } else _syx_parser_parse_message_pattern (self); if (!self->_in_block) _syx_parser_parse_primitive (self); _syx_parser_parse_temporaries (self); if (self->_in_block) syx_bytecode_push_constant (self->bytecode, SYX_BYTECODE_CONST_NIL); _syx_parser_parse_body (self); syx_bytecode_do_special (self->bytecode, SYX_BYTECODE_SELF_RETURN); SYX_CODE_BYTECODES(self->method) = syx_byte_array_new_ref (self->bytecode->code_top * sizeof (syx_uint16), (syx_uint8 *)self->bytecode->code); SYX_CODE_LITERALS(self->method) = syx_array_new_ref (self->bytecode->literals_top, self->bytecode->literals); if (self->_in_block) SYX_BLOCK_ARGUMENT_STACK_TOP(self->method) = syx_small_integer_new (self->_argument_scopes.stack[self->_argument_scopes.top-1].start); else { SYX_METHOD_ARGUMENT_STACK_SIZE(self->method) = syx_small_integer_new (self->_argument_names_top); SYX_METHOD_TEMPORARY_STACK_SIZE(self->method) = syx_small_integer_new (self->_temporary_names_top); } SYX_CODE_STACK_SIZE(self->method) = syx_small_integer_new (self->bytecode->stack_size + 1); SYX_CODE_TEXT(self->method) = syx_string_new (self->lexer->text + syx_find_first_non_whitespace (self->lexer->text)); SYX_CODE_CLASS(self->method) = self->klass; return TRUE; }
/*! Do parse. \return TRUE if parsing was successful, otherwise FALSE */ syx_bool syx_parser_parse (SyxParser *self, syx_bool skip_message_pattern) { SyxToken token; token = syx_lexer_next_token (self->lexer); if (token.type == SYX_TOKEN_END) return TRUE; self->_temporary_scopes[self->_temporary_scopes_top].top = 0; self->_argument_scopes[self->_argument_scopes_top].top = 0; if (!skip_message_pattern) _syx_parser_parse_message_pattern (self); if (!self->_in_block) _syx_parser_parse_primitive (self); _syx_parser_parse_temporaries (self); if (self->_in_block) syx_bytecode_push_constant (self->bytecode, SYX_BYTECODE_CONST_NIL); _syx_parser_parse_body (self); syx_bytecode_do_special (self->bytecode, SYX_BYTECODE_SELF_RETURN); SYX_CODE_BYTECODES(self->method) = syx_byte_array_new_ref (self->bytecode->code_top * sizeof (syx_uint16), (syx_uint8 *)self->bytecode->code); SYX_CODE_LITERALS(self->method) = syx_array_new_ref (self->bytecode->literals_top, self->bytecode->literals); SYX_CODE_STACK_SIZE(self->method) = syx_small_integer_new (self->bytecode->stack_size + 1); SYX_CODE_TEXT(self->method) = syx_string_new (self->lexer->text + syx_find_first_non_whitespace (self->lexer->text)); SYX_CODE_CLASS(self->method) = self->klass; /* Free arguments and temporaries of this scope */ _syx_parser_free_arguments (self); _syx_parser_free_temporaries (self); return TRUE; }