/* YACC grammar for Chill expressions, for GDB.
- Copyright 1992, 1993 Free Software Foundation, Inc.
+ Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GDB.
%{
#include "defs.h"
+#include <string.h>
#include <ctype.h>
#include "expression.h"
#include "language.h"
#include "value.h"
#include "parser-defs.h"
#include "ch-lang.h"
+#include "bfd.h" /* Required by objfiles.h. */
+#include "symfile.h" /* Required by objfiles.h. */
+#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
%type <voidval> lower_element
%type <voidval> upper_element
%type <voidval> first_element
-%type <voidval> mode_argument
+%type <tval> mode_argument
%type <voidval> upper_lower_argument
%type <voidval> length_argument
%type <voidval> array_mode_name
}
| operand_2 IN operand_3
{
- $$ = 0; /* FIXME */
+ write_exp_elt_opcode (BINOP_IN);
}
;
{
$$ = 0; /* FIXME */
}
- | SIZE '(' location ')'
- {
- $$ = 0; /* FIXME */
- }
+ | SIZE '(' expression ')'
+ { write_exp_elt_opcode (UNOP_SIZEOF); }
| SIZE '(' mode_argument ')'
- {
- $$ = 0; /* FIXME */
- }
+ { write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_type (builtin_type_int);
+ write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (OP_LONG); }
| UPPER '(' upper_lower_argument ')'
{
$$ = 0; /* FIXME */
mode_argument : mode_name
{
- $$ = 0; /* FIXME */
+ $$ = $1.type;
}
| array_mode_name '(' expression ')'
{
{
char *tokptr = lexptr;
- if (isalpha (*tokptr))
+ if (isalpha (*tokptr) || *tokptr == '_')
{
char *result;
do {
while (*tokptr != '\0')
{
- temp = tolower (*tokptr);
+ temp = *tokptr;
+ if (isupper (temp))
+ temp = tolower (temp);
tokptr++;
switch (temp)
{
return (0);
}
-/* Recognize a string literal. A string literal is a nonzero sequence
+/* Recognize a string literal. A string literal is a sequence
of characters enclosed in matching single or double quotes, except that
a single character inside single quotes is a character literal, which
we reject as a string literal. To embed the terminator character inside
tempbuf[tempbufindex++] = *tokptr;
}
if (*tokptr == '\0' /* no terminator */
- || tempbufindex == 0 /* no string */
|| (tempbufindex == 1 && *tokptr == '\'')) /* char literal */
{
return (0);
char *tokptr = lexptr;
int ival = 0;
- if ((tolower (*tokptr) == 'c') && (*(tokptr + 1) == '\''))
+ if ((*tokptr == 'c' || *tokptr == 'C') && (*(tokptr + 1) == '\''))
{
/* We have a GNU chill extension form, so skip the leading "C'",
decode the hex value, and then ensure that we have a trailing
while (*tokptr != '\0' && *tokptr != '\'')
{
- digit = tolower (*tokptr);
+ digit = *tokptr;
+ if (isupper (digit))
+ digit = tolower (digit);
tokptr++;
switch (digit)
{
&& !isalnum (tokptr[namelength]))
{
yylval.lval = regno;
- lexptr += namelength + 1;
+ lexptr += namelength;
return (GDB_REGNAME);
}
}
{
case '\'':
case '\"':
- /* First try to match a string literal, which is any nonzero
+ /* First try to match a string literal, which is any
sequence of characters enclosed in matching single or double
quotes, except that a single character inside single quotes
is a character literal, so we have to catch that case also. */
yyerror (msg)
char *msg; /* unused */
{
- printf ("Parsing: %s\n", lexptr);
+ printf_unfiltered ("Parsing: %s\n", lexptr);
if (yychar < 256)
{
error ("Invalid syntax in expression near character '%c'.", yychar);