/* FLEX lexer for Ada expressions, for GDB.
- Copyright (C) 1994, 1997-1998, 2000-2003, 2007-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 1994-2014 Free Software Foundation, Inc.
This file is part of GDB.
static struct stoken processId (const char *, int);
static int processAttribute (const char *);
static int find_dot_all (const char *);
+static void rewind_to_char (int);
#undef YY_DECL
#define YY_DECL static int yylex ( void )
if {
- while (*lexptr != 'i' && *lexptr != 'I')
- lexptr -= 1;
- yyrestart(NULL);
+ rewind_to_char ('i');
return 0;
}
-(task|thread) {
+task {
+ rewind_to_char ('t');
+ return 0;
+ }
+
+thread{WHITE}+{DIG} {
/* This keyword signals the end of the expression and
will be processed separately. */
- while (*lexptr != 't' && *lexptr != 'T')
- lexptr--;
- yyrestart(NULL);
+ rewind_to_char ('t');
return 0;
}
"," { if (paren_depth == 0 && comma_terminates)
{
- lexptr -= 1;
- yyrestart(NULL);
+ rewind_to_char (',');
return 0;
}
else
"(" { paren_depth += 1; return '('; }
")" { if (paren_depth == 0)
{
- lexptr -= 1;
- yyrestart(NULL);
+ rewind_to_char (')');
return 0;
}
else
%%
#include <ctype.h>
-#include "gdb_string.h"
+#include <string.h>
/* Initialize the lexer for processing new expression. */
-void
+static void
lexer_init (FILE *inp)
{
BEGIN INITIAL;
ULONGEST result;
long exp;
int base;
-
- char *trailer;
+ const char *trailer;
if (base0 == NULL)
base = 10;
exp = strtol(exp0, (char **) NULL, 10);
errno = 0;
- result = strtoulst (num0, (const char **) &trailer, base);
+ result = strtoulst (num0, &trailer, base);
if (errno == ERANGE)
error (_("Integer literal out of range"));
if (isxdigit(*trailer))
const char *lim = text + len;
struct stoken result;
- q = result.ptr = obstack_alloc (&temp_parse_space, len);
+ q = obstack_alloc (&temp_parse_space, len);
+ result.ptr = q;
p = text;
while (p < lim)
{
find_dot_all (const char *str)
{
int i;
- for (i = 0; str[i] != '\000'; i += 1)
- {
- if (str[i] == '.')
- {
- int i0 = i;
- do
- i += 1;
- while (isspace (str[i]));
- if (strncmp (str+i, "all", 3) == 0
- && ! isalnum (str[i+3]) && str[i+3] != '_')
- return i0;
- }
- }
+
+ for (i = 0; str[i] != '\000'; i++)
+ if (str[i] == '.')
+ {
+ int i0 = i;
+
+ do
+ i += 1;
+ while (isspace (str[i]));
+
+ if (strncasecmp (str + i, "all", 3) == 0
+ && !isalnum (str[i + 3]) && str[i + 3] != '_')
+ return i0;
+ }
return -1;
}
return attributes[k].code;
}
+/* Back up lexptr by yyleng and then to the rightmost occurrence of
+ character CH, case-folded (there must be one). WARNING: since
+ lexptr points to the next input character that Flex has not yet
+ transferred to its internal buffer, the use of this function
+ depends on the assumption that Flex calls YY_INPUT only when it is
+ logically necessary to do so (thus, there is no reading ahead
+ farther than needed to identify the next token.) */
+
+static void
+rewind_to_char (int ch)
+{
+ lexptr -= yyleng;
+ while (toupper (*lexptr) != toupper (ch))
+ lexptr -= 1;
+ yyrestart (NULL);
+}
+
int
yywrap(void)
{