+/**
+ * Parse a microsoft __try { } __finally { } or
+ * __try{ } __except() { }
+ */
+static statement_t *parse_ms_try_statment(void) {
+ statement_t *statement = allocate_statement_zero(STATEMENT_MS_TRY);
+
+ statement->base.source_position = token.source_position;
+ eat(T___try);
+
+ ms_try_statement_t *rem = current_try;
+ current_try = &statement->ms_try;
+ statement->ms_try.try_statement = parse_compound_statement(false);
+ current_try = rem;
+
+ if(token.type == T___except) {
+ eat(T___except);
+ expect('(');
+ add_anchor_token(')');
+ expression_t *const expr = parse_expression();
+ type_t * type = skip_typeref(expr->base.type);
+ if (is_type_integer(type)) {
+ type = promote_integer(type);
+ } else if (is_type_valid(type)) {
+ errorf(&expr->base.source_position,
+ "__expect expression is not an integer, but '%T'", type);
+ type = type_error_type;
+ }
+ statement->ms_try.except_expression = create_implicit_cast(expr, type);
+ rem_anchor_token(')');
+ expect(')');
+ statement->ms_try.final_statement = parse_compound_statement(false);
+ } else if(token.type == T__finally) {
+ eat(T___finally);
+ statement->ms_try.final_statement = parse_compound_statement(false);
+ } else {
+ parse_error_expected("while parsing __try statement", T___except, T___finally, NULL);
+ return create_invalid_statement();
+ }
+ return statement;
+end_error:
+ return create_invalid_statement();
+}
+