[RFA] fix a pascal parsing bug
David Taylor
taylor@cygnus.com
Fri Oct 27 08:11:00 GMT 2000
Date: Fri, 27 Oct 2000 12:57:28 +0200
From: Pierre Muller <muller@cerbere.u-strasbg.fr>
Pascal patch nð7:
The following patch fixes a bug in the pascal parsing.
The problem is due to the fact that some special operators have
ascii names in pascal. For instance && is and in pascal
(in fact it is both the logical and the arithmetical and).
Thus trying to print a var with name starting with and fais with current
CVS tree.
Since you labeled it RFA and cc'ed me, I assume you feel it needs my
approval. However, you are the maintainer for the p-exp.y (part of
the Pascal language support).
I also assume that the formatting / indentation is due to a
combination of how you sent it and how you invoked cvs diff. (If not,
then please fix it before you commit it.)
Approved.
(gdb) p andstate
A parse error in expressiion, near `'.
The error message is not very explicit either.
The patch also allows to recognize 'AND' and 'and' as being
the same operator (pascal is case insensitive).
PS: if the patch is accepted, should I also commit the resulting
p-exp.tab.c file ?
Yes.
ChangeLog entry:
2000-10-27 Pierre Muller <muller@ics.u-strasbg.fr>
* p-exp.y (yylex): avoid problem with symbol name starting as a
operator name.
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.1
diff -b -c -r1.1 p-exp.y
*** p-exp.y 2000/06/14 12:27:59 1.1
--- p-exp.y 2000/10/27 11:02:11
***************
*** 942,957 ****
char *uptokstart;
char *tokptr;
char *p;
! int tempbufindex;
static char *tempbuf;
static int tempbufsize;
retry:
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))
{
lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
--- 942,962 ----
char *uptokstart;
char *tokptr;
char *p;
! int explen,tempbufindex;
static char *tempbuf;
static int tempbufsize;
retry:
tokstart = lexptr;
+ explen = strlen(lexptr);
/* See if it is a special token of length 3. */
+ if (explen > 2)
for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
! if ((strnicmp (tokstart, tokentab3[i].operator, 3) == 0) &&
! (!isalpha (tokentab3[i].operator[0]) || (explen == 3) ||
! (!isalpha (tokstart[3]) && !isdigit (tokstart[3]) &&
(tokstart[3] != '_'))
! ))
{
lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
***************
*** 959,966 ****
}
/* 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))
{
lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
--- 964,975 ----
}
/* See if it is a special token of length 2. */
+ if (explen > 1)
for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
! if ((strnicmp (tokstart, tokentab2[i].operator, 2) == 0)
! && (!isalpha (tokentab2[i].operator[0]) || (explen == 2) ||
! (!isalpha (tokstart[2]) && !isdigit (tokstart[2]) &&
(tokstart[2] != '_'))
! ))
{
lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
More information about the Gdb-patches
mailing list