/* YACC parser for Java expressions, for GDB.
- Copyright 1997, 1998, 1999, 2000
+ Copyright (C) 1997, 1998, 1999, 2000, 2006, 2007
Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
/* Parse a Java expression from text in a string,
and return the result as a struct expression pointer.
/*| SUPER '.' SimpleName { FIXME } */
;
+FuncStart:
+ Name '('
+ { push_expression_name ($1); }
+;
+
MethodInvocation:
- Name '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ FuncStart
+ { start_arglist(); }
+ ArgumentList_opt ')'
+ { write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_longcst ((LONGEST) end_arglist ());
+ write_exp_elt_opcode (OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
- { error (_("Method invocation not implemented")); }
+ { error (_("Form of method invocation not implemented")); }
;
ArrayAccess:
static int
parse_number (p, len, parsed_float, putithere)
- register char *p;
- register int len;
+ char *p;
+ int len;
int parsed_float;
YYSTYPE *putithere;
{
- register ULONGEST n = 0;
+ ULONGEST n = 0;
ULONGEST limit, limit_div_base;
- register int c;
- register int base = input_radix;
+ int c;
+ int base = input_radix;
struct type *type;
char saved_char = p[len];
p[len] = 0; /* null-terminate the token */
- if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
- num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval, &c);
- else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
- num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval, &c);
- else
- {
-#ifdef SCANF_HAS_LONG_DOUBLE
- num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval, &c);
-#else
- /* Scan it into a double, then assign it to the long double.
- This at least wins with values representable in the range
- of doubles. */
- double temp;
- num = sscanf (p, "%lg%c", &temp, &c);
- putithere->typed_val_float.dval = temp;
-#endif
- }
+ num = sscanf (p, DOUBLEST_SCAN_FORMAT "%c",
+ &putithere->typed_val_float.dval, &c);
p[len] = saved_char; /* restore the input stream */
if (num != 1) /* check scanf found ONLY a float ... */
return ERROR;
tokstart = lexptr;
/* See if it is a special token of length 3. */
for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
- if (STREQN (tokstart, tokentab3[i].operator, 3))
+ if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
{
lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
/* See if it is a special token of length 2. */
for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
- if (STREQN (tokstart, tokentab2[i].operator, 2))
+ if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
{
lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
{
/* It's a number. */
int got_dot = 0, got_e = 0, toktype;
- register char *p = tokstart;
+ char *p = tokstart;
int hex = input_radix > 10;
if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
switch (namelen)
{
case 7:
- if (STREQN (tokstart, "boolean", 7))
+ if (DEPRECATED_STREQN (tokstart, "boolean", 7))
return BOOLEAN;
break;
case 6:
- if (STREQN (tokstart, "double", 6))
+ if (DEPRECATED_STREQN (tokstart, "double", 6))
return DOUBLE;
break;
case 5:
- if (STREQN (tokstart, "short", 5))
+ if (DEPRECATED_STREQN (tokstart, "short", 5))
return SHORT;
- if (STREQN (tokstart, "false", 5))
+ if (DEPRECATED_STREQN (tokstart, "false", 5))
{
yylval.lval = 0;
return BOOLEAN_LITERAL;
}
- if (STREQN (tokstart, "super", 5))
+ if (DEPRECATED_STREQN (tokstart, "super", 5))
return SUPER;
- if (STREQN (tokstart, "float", 5))
+ if (DEPRECATED_STREQN (tokstart, "float", 5))
return FLOAT;
break;
case 4:
- if (STREQN (tokstart, "long", 4))
+ if (DEPRECATED_STREQN (tokstart, "long", 4))
return LONG;
- if (STREQN (tokstart, "byte", 4))
+ if (DEPRECATED_STREQN (tokstart, "byte", 4))
return BYTE;
- if (STREQN (tokstart, "char", 4))
+ if (DEPRECATED_STREQN (tokstart, "char", 4))
return CHAR;
- if (STREQN (tokstart, "true", 4))
+ if (DEPRECATED_STREQN (tokstart, "true", 4))
{
yylval.lval = 1;
return BOOLEAN_LITERAL;
}
break;
case 3:
- if (STREQN (tokstart, "int", 3))
+ if (strncmp (tokstart, "int", 3) == 0)
return INT;
- if (STREQN (tokstart, "new", 3))
+ if (strncmp (tokstart, "new", 3) == 0)
return NEW;
break;
default:
}
/* Assuming a reference expression has been pushed, emit the
- STRUCTOP_STRUCT ops to access the field named NAME. If NAME is a
+ STRUCTOP_PTR ops to access the field named NAME. If NAME is a
qualified name (has '.'), generate a field access for each part. */
static void
{
/* token.ptr is start of current field name. */
token.length = &name.ptr[i] - token.ptr;
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ write_exp_elt_opcode (STRUCTOP_PTR);
write_exp_string (token);
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ write_exp_elt_opcode (STRUCTOP_PTR);
token.ptr += token.length + 1;
}
if (i >= name.length)