static match match_primary (gfc_expr **result) { match m; gfc_expr *e; m = gfc_match_literal_constant (result, 0); if (m != MATCH_NO) return m; m = gfc_match_array_constructor (result); if (m != MATCH_NO) return m; m = gfc_match_rvalue (result); if (m != MATCH_NO) return m; /* Match an expression in parentheses. */ if (gfc_match_char ('(') != MATCH_YES) return MATCH_NO; m = gfc_match_expr (&e); if (m == MATCH_NO) goto syntax; if (m == MATCH_ERROR) return m; m = gfc_match_char (')'); if (m == MATCH_NO) gfc_error ("Expected a right parenthesis in expression at %C"); /* Now we have the expression inside the parentheses, build the expression pointing to it. By 7.1.7.2, any expression in parentheses shall be treated as a data entity. */ *result = gfc_get_parentheses (e); if (m != MATCH_YES) { gfc_free_expr (*result); return MATCH_ERROR; } return MATCH_YES; syntax: gfc_error (expression_syntax); return MATCH_ERROR; }
static match match_primary (gfc_expr ** result) { match m; m = gfc_match_literal_constant (result, 0); if (m != MATCH_NO) return m; m = gfc_match_array_constructor (result); if (m != MATCH_NO) return m; m = gfc_match_rvalue (result); if (m != MATCH_NO) return m; /* Match an expression in parenthesis. */ if (gfc_match_char ('(') != MATCH_YES) return MATCH_NO; m = gfc_match_expr (result); if (m == MATCH_NO) goto syntax; if (m == MATCH_ERROR) return m; m = gfc_match_char (')'); if (m == MATCH_NO) gfc_error ("Expected a right parenthesis in expression at %C"); if (m != MATCH_YES) { gfc_free_expr (*result); return MATCH_ERROR; } return MATCH_YES; syntax: gfc_error (expression_syntax); return MATCH_ERROR; }
static match match_subscript (gfc_array_ref * ar, int init) { match m; int i; i = ar->dimen; ar->c_where[i] = gfc_current_locus; ar->start[i] = ar->end[i] = ar->stride[i] = NULL; /* We can't be sure of the difference between DIMEN_ELEMENT and DIMEN_VECTOR until we know the type of the element itself at resolution time. */ ar->dimen_type[i] = DIMEN_UNKNOWN; if (gfc_match_char (':') == MATCH_YES) goto end_element; /* Get start element. */ if (init) m = gfc_match_init_expr (&ar->start[i]); else m = gfc_match_expr (&ar->start[i]); if (m == MATCH_NO) gfc_error ("Expected array subscript at %C"); if (m != MATCH_YES) return MATCH_ERROR; if (gfc_match_char (':') == MATCH_NO) return MATCH_YES; /* Get an optional end element. Because we've seen the colon, we definitely have a range along this dimension. */ end_element: ar->dimen_type[i] = DIMEN_RANGE; if (init) m = gfc_match_init_expr (&ar->end[i]); else m = gfc_match_expr (&ar->end[i]); if (m == MATCH_ERROR) return MATCH_ERROR; /* See if we have an optional stride. */ if (gfc_match_char (':') == MATCH_YES) { m = init ? gfc_match_init_expr (&ar->stride[i]) : gfc_match_expr (&ar->stride[i]); if (m == MATCH_NO) gfc_error ("Expected array subscript stride at %C"); if (m != MATCH_YES) return MATCH_ERROR; } return MATCH_YES; }