+exp : exp OBJC_LBRAC exp1 ']'
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
+ ;
+
+/*
+ * The rules below parse ObjC message calls of the form:
+ * '[' target selector {':' argument}* ']'
+ */
+
+exp : OBJC_LBRAC TYPENAME
+ {
+ CORE_ADDR theclass;
+
+ theclass = lookup_objc_class (parse_gdbarch (pstate),
+ copy_name ($2.stoken));
+ if (theclass == 0)
+ error (_("%s is not an ObjC Class"),
+ copy_name ($2.stoken));
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate, (LONGEST) theclass);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ start_msglist();
+ }
+ msglist ']'
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ }
+ ;
+
+exp : OBJC_LBRAC CLASSNAME
+ {
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate, (LONGEST) $2.theclass);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ start_msglist();
+ }
+ msglist ']'
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ }
+ ;
+
+exp : OBJC_LBRAC exp
+ { start_msglist(); }
+ msglist ']'
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ }
+ ;
+
+msglist : name
+ { add_msglist(&$1, 0); }
+ | msgarglist
+ ;
+
+msgarglist : msgarg
+ | msgarglist msgarg
+ ;
+
+msgarg : name ':' exp
+ { add_msglist(&$1, 1); }
+ | ':' exp /* Unnamed arg. */
+ { add_msglist(0, 1); }
+ | ',' exp /* Variable number of args. */
+ { add_msglist(0, 0); }
+ ;
+
+exp : exp '('