cpphash.h (struct cpp_buffer): Remove backup_to.
* cpphash.h (struct cpp_buffer): Remove backup_to. * cpplex.c (BACKUP, get_effective_char): Die. (_cpp_skip_block_comment): Assume '*' is location on entry. (continues_identifier_p): Respect -fno-dollars-in-identifiers. (IF_NEXT_IS): Update. (_cpp_lex_direct): Don't use backup_to; look ahead directly. From-SVN: r65819
This commit is contained in:
parent
ced2ad7687
commit
6f572ac229
|
@ -1,3 +1,12 @@
|
||||||
|
2003-04-19 Neil Booth <neil@daikokuya.co.uk>
|
||||||
|
|
||||||
|
* cpphash.h (struct cpp_buffer): Remove backup_to.
|
||||||
|
* cpplex.c (BACKUP, get_effective_char): Die.
|
||||||
|
(_cpp_skip_block_comment): Assume '*' is location on entry.
|
||||||
|
(continues_identifier_p): Respect -fno-dollars-in-identifiers.
|
||||||
|
(IF_NEXT_IS): Update.
|
||||||
|
(_cpp_lex_direct): Don't use backup_to; look ahead directly.
|
||||||
|
|
||||||
2003-04-19 Matt Kraai <kraai@alumni.cmu.edu>
|
2003-04-19 Matt Kraai <kraai@alumni.cmu.edu>
|
||||||
|
|
||||||
* README.Portability: Move to a new section and obsolete K+R
|
* README.Portability: Move to a new section and obsolete K+R
|
||||||
|
|
|
@ -267,8 +267,6 @@ struct cpp_buffer
|
||||||
|
|
||||||
struct cpp_buffer *prev;
|
struct cpp_buffer *prev;
|
||||||
|
|
||||||
const unsigned char *backup_to; /* Soon to die. */
|
|
||||||
|
|
||||||
/* Pointer into the include table; non-NULL if this is a file
|
/* Pointer into the include table; non-NULL if this is a file
|
||||||
buffer. Used for include_next and to record control macros. */
|
buffer. Used for include_next and to record control macros. */
|
||||||
struct include_file *inc;
|
struct include_file *inc;
|
||||||
|
|
260
gcc/cpplex.c
260
gcc/cpplex.c
|
@ -55,11 +55,8 @@ static const struct token_spelling token_spellings[N_TTYPES] = { TTYPE_TABLE };
|
||||||
|
|
||||||
#define TOKEN_SPELL(token) (token_spellings[(token)->type].category)
|
#define TOKEN_SPELL(token) (token_spellings[(token)->type].category)
|
||||||
#define TOKEN_NAME(token) (token_spellings[(token)->type].name)
|
#define TOKEN_NAME(token) (token_spellings[(token)->type].name)
|
||||||
#define BACKUP() do {buffer->cur = buffer->backup_to;} while (0)
|
|
||||||
|
|
||||||
static void add_line_note PARAMS ((cpp_buffer *, const uchar *, unsigned int));
|
static void add_line_note PARAMS ((cpp_buffer *, const uchar *, unsigned int));
|
||||||
static cppchar_t get_effective_char PARAMS ((cpp_reader *));
|
|
||||||
|
|
||||||
static int skip_line_comment PARAMS ((cpp_reader *));
|
static int skip_line_comment PARAMS ((cpp_reader *));
|
||||||
static void skip_whitespace PARAMS ((cpp_reader *, cppchar_t));
|
static void skip_whitespace PARAMS ((cpp_reader *, cppchar_t));
|
||||||
static cpp_hashnode *lex_identifier PARAMS ((cpp_reader *));
|
static cpp_hashnode *lex_identifier PARAMS ((cpp_reader *));
|
||||||
|
@ -246,24 +243,11 @@ _cpp_process_line_notes (pfile, in_comment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Obtain the next character, after trigraph conversion and skipping
|
|
||||||
an arbitrarily long string of escaped newlines. The common case of
|
|
||||||
no trigraphs or escaped newlines falls through quickly. On return,
|
|
||||||
buffer->backup_to points to where to return to if the character is
|
|
||||||
not to be processed. */
|
|
||||||
static cppchar_t
|
|
||||||
get_effective_char (pfile)
|
|
||||||
cpp_reader *pfile;
|
|
||||||
{
|
|
||||||
cpp_buffer *buffer = pfile->buffer;
|
|
||||||
|
|
||||||
buffer->backup_to = buffer->cur;
|
|
||||||
return *buffer->cur++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip a C-style block comment. We find the end of the comment by
|
/* Skip a C-style block comment. We find the end of the comment by
|
||||||
seeing if an asterisk is before every '/' we encounter. Returns
|
seeing if an asterisk is before every '/' we encounter. Returns
|
||||||
nonzero if comment terminated by EOF, zero otherwise. */
|
nonzero if comment terminated by EOF, zero otherwise.
|
||||||
|
|
||||||
|
Buffer->cur points to the initial asterisk of the comment. */
|
||||||
bool
|
bool
|
||||||
_cpp_skip_block_comment (pfile)
|
_cpp_skip_block_comment (pfile)
|
||||||
cpp_reader *pfile;
|
cpp_reader *pfile;
|
||||||
|
@ -271,6 +255,7 @@ _cpp_skip_block_comment (pfile)
|
||||||
cpp_buffer *buffer = pfile->buffer;
|
cpp_buffer *buffer = pfile->buffer;
|
||||||
cppchar_t c;
|
cppchar_t c;
|
||||||
|
|
||||||
|
buffer->cur++;
|
||||||
if (*buffer->cur == '/')
|
if (*buffer->cur == '/')
|
||||||
buffer->cur++;
|
buffer->cur++;
|
||||||
|
|
||||||
|
@ -381,7 +366,7 @@ static bool
|
||||||
continues_identifier_p (pfile)
|
continues_identifier_p (pfile)
|
||||||
cpp_reader *pfile;
|
cpp_reader *pfile;
|
||||||
{
|
{
|
||||||
if (*pfile->buffer->cur != '$')
|
if (*pfile->buffer->cur != '$' || !CPP_OPTION (pfile, dollars_in_ident))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (CPP_PEDANTIC (pfile) && !pfile->state.skipping && !pfile->warned_dollar)
|
if (CPP_PEDANTIC (pfile) && !pfile->state.skipping && !pfile->warned_dollar)
|
||||||
|
@ -492,8 +477,7 @@ lex_string (pfile, token)
|
||||||
{
|
{
|
||||||
cppchar_t c = *buffer->cur++;
|
cppchar_t c = *buffer->cur++;
|
||||||
|
|
||||||
/* In #include-style directives, terminators are not escapable.
|
/* In #include-style directives, terminators are not escapable. */
|
||||||
\n can follow the '\\' if the file's last byte is '\\'. */
|
|
||||||
if (c == '\\' && !pfile->state.angled_headers && *buffer->cur != '\n')
|
if (c == '\\' && !pfile->state.angled_headers && *buffer->cur != '\n')
|
||||||
buffer->cur++;
|
buffer->cur++;
|
||||||
else if (c == terminator || c == '\n')
|
else if (c == terminator || c == '\n')
|
||||||
|
@ -728,16 +712,14 @@ _cpp_get_fresh_line (pfile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IF_NEXT_IS(CHAR, THEN_TYPE, ELSE_TYPE) \
|
#define IF_NEXT_IS(CHAR, THEN_TYPE, ELSE_TYPE) \
|
||||||
do { \
|
do \
|
||||||
if (get_effective_char (pfile) == CHAR) \
|
{ \
|
||||||
result->type = THEN_TYPE; \
|
result->type = ELSE_TYPE; \
|
||||||
else \
|
if (*buffer->cur == CHAR) \
|
||||||
{ \
|
buffer->cur++, result->type = THEN_TYPE; \
|
||||||
BACKUP (); \
|
} \
|
||||||
result->type = ELSE_TYPE; \
|
while (0)
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* Lex a token into pfile->cur_token, which is also incremented, to
|
/* Lex a token into pfile->cur_token, which is also incremented, to
|
||||||
get diagnostics pointing to the correct location.
|
get diagnostics pointing to the correct location.
|
||||||
|
@ -853,8 +835,8 @@ _cpp_lex_direct (pfile)
|
||||||
case '/':
|
case '/':
|
||||||
/* A potential block or line comment. */
|
/* A potential block or line comment. */
|
||||||
comment_start = buffer->cur;
|
comment_start = buffer->cur;
|
||||||
c = get_effective_char (pfile);
|
c = *buffer->cur;
|
||||||
|
|
||||||
if (c == '*')
|
if (c == '*')
|
||||||
{
|
{
|
||||||
if (_cpp_skip_block_comment (pfile))
|
if (_cpp_skip_block_comment (pfile))
|
||||||
|
@ -880,12 +862,12 @@ _cpp_lex_direct (pfile)
|
||||||
}
|
}
|
||||||
else if (c == '=')
|
else if (c == '=')
|
||||||
{
|
{
|
||||||
|
buffer->cur++;
|
||||||
result->type = CPP_DIV_EQ;
|
result->type = CPP_DIV_EQ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BACKUP ();
|
|
||||||
result->type = CPP_DIV;
|
result->type = CPP_DIV;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -908,179 +890,137 @@ _cpp_lex_direct (pfile)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_LESS;
|
||||||
if (c == '=')
|
if (*buffer->cur == '=')
|
||||||
result->type = CPP_LESS_EQ;
|
buffer->cur++, result->type = CPP_LESS_EQ;
|
||||||
else if (c == '<')
|
else if (*buffer->cur == '<')
|
||||||
IF_NEXT_IS ('=', CPP_LSHIFT_EQ, CPP_LSHIFT);
|
|
||||||
else if (c == '?' && CPP_OPTION (pfile, cplusplus))
|
|
||||||
IF_NEXT_IS ('=', CPP_MIN_EQ, CPP_MIN);
|
|
||||||
else if (c == ':' && CPP_OPTION (pfile, digraphs))
|
|
||||||
{
|
{
|
||||||
result->type = CPP_OPEN_SQUARE;
|
buffer->cur++;
|
||||||
result->flags |= DIGRAPH;
|
IF_NEXT_IS ('=', CPP_LSHIFT_EQ, CPP_LSHIFT);
|
||||||
}
|
}
|
||||||
else if (c == '%' && CPP_OPTION (pfile, digraphs))
|
else if (*buffer->cur == '?' && CPP_OPTION (pfile, cplusplus))
|
||||||
{
|
{
|
||||||
result->type = CPP_OPEN_BRACE;
|
buffer->cur++;
|
||||||
result->flags |= DIGRAPH;
|
IF_NEXT_IS ('=', CPP_MIN_EQ, CPP_MIN);
|
||||||
}
|
}
|
||||||
else
|
else if (CPP_OPTION (pfile, digraphs))
|
||||||
{
|
{
|
||||||
BACKUP ();
|
if (*buffer->cur == ':')
|
||||||
result->type = CPP_LESS;
|
{
|
||||||
|
buffer->cur++;
|
||||||
|
result->flags |= DIGRAPH;
|
||||||
|
result->type = CPP_OPEN_SQUARE;
|
||||||
|
}
|
||||||
|
else if (*buffer->cur == '%')
|
||||||
|
{
|
||||||
|
buffer->cur++;
|
||||||
|
result->flags |= DIGRAPH;
|
||||||
|
result->type = CPP_OPEN_BRACE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_GREATER;
|
||||||
if (c == '=')
|
if (*buffer->cur == '=')
|
||||||
result->type = CPP_GREATER_EQ;
|
buffer->cur++, result->type = CPP_GREATER_EQ;
|
||||||
else if (c == '>')
|
else if (*buffer->cur == '>')
|
||||||
IF_NEXT_IS ('=', CPP_RSHIFT_EQ, CPP_RSHIFT);
|
|
||||||
else if (c == '?' && CPP_OPTION (pfile, cplusplus))
|
|
||||||
IF_NEXT_IS ('=', CPP_MAX_EQ, CPP_MAX);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
BACKUP ();
|
buffer->cur++;
|
||||||
result->type = CPP_GREATER;
|
IF_NEXT_IS ('=', CPP_RSHIFT_EQ, CPP_RSHIFT);
|
||||||
|
}
|
||||||
|
else if (*buffer->cur == '?' && CPP_OPTION (pfile, cplusplus))
|
||||||
|
{
|
||||||
|
buffer->cur++;
|
||||||
|
IF_NEXT_IS ('=', CPP_MAX_EQ, CPP_MAX);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '%':
|
case '%':
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_MOD;
|
||||||
if (c == '=')
|
if (*buffer->cur == '=')
|
||||||
result->type = CPP_MOD_EQ;
|
buffer->cur++, result->type = CPP_MOD_EQ;
|
||||||
else if (CPP_OPTION (pfile, digraphs) && c == ':')
|
else if (CPP_OPTION (pfile, digraphs))
|
||||||
{
|
{
|
||||||
result->flags |= DIGRAPH;
|
if (*buffer->cur == ':')
|
||||||
result->type = CPP_HASH;
|
|
||||||
if (get_effective_char (pfile) == '%')
|
|
||||||
{
|
{
|
||||||
const unsigned char *pos = buffer->cur;
|
buffer->cur++;
|
||||||
|
result->flags |= DIGRAPH;
|
||||||
if (get_effective_char (pfile) == ':')
|
result->type = CPP_HASH;
|
||||||
result->type = CPP_PASTE;
|
if (*buffer->cur == '%' && buffer->cur[1] == ':')
|
||||||
else
|
buffer->cur += 2, result->type = CPP_PASTE;
|
||||||
buffer->cur = pos - 1;
|
}
|
||||||
|
else if (*buffer->cur == '>')
|
||||||
|
{
|
||||||
|
buffer->cur++;
|
||||||
|
result->flags |= DIGRAPH;
|
||||||
|
result->type = CPP_CLOSE_BRACE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
BACKUP ();
|
|
||||||
}
|
|
||||||
else if (CPP_OPTION (pfile, digraphs) && c == '>')
|
|
||||||
{
|
|
||||||
result->flags |= DIGRAPH;
|
|
||||||
result->type = CPP_CLOSE_BRACE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BACKUP ();
|
|
||||||
result->type = CPP_MOD;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '.':
|
case '.':
|
||||||
result->type = CPP_DOT;
|
result->type = CPP_DOT;
|
||||||
c = get_effective_char (pfile);
|
if (ISDIGIT (*buffer->cur))
|
||||||
if (c == '.')
|
|
||||||
{
|
{
|
||||||
const unsigned char *pos = buffer->cur;
|
|
||||||
|
|
||||||
if (get_effective_char (pfile) == '.')
|
|
||||||
result->type = CPP_ELLIPSIS;
|
|
||||||
else
|
|
||||||
buffer->cur = pos - 1;
|
|
||||||
}
|
|
||||||
/* All known character sets have 0...9 contiguous. */
|
|
||||||
else if (ISDIGIT (c))
|
|
||||||
{
|
|
||||||
buffer->cur--;
|
|
||||||
result->type = CPP_NUMBER;
|
result->type = CPP_NUMBER;
|
||||||
lex_number (pfile, &result->val.str);
|
lex_number (pfile, &result->val.str);
|
||||||
}
|
}
|
||||||
else if (c == '*' && CPP_OPTION (pfile, cplusplus))
|
else if (*buffer->cur == '.' && buffer->cur[1] == '.')
|
||||||
result->type = CPP_DOT_STAR;
|
buffer->cur += 2, result->type = CPP_ELLIPSIS;
|
||||||
else
|
else if (*buffer->cur == '*' && CPP_OPTION (pfile, cplusplus))
|
||||||
BACKUP ();
|
buffer->cur++, result->type = CPP_DOT_STAR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '+':
|
case '+':
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_PLUS;
|
||||||
if (c == '+')
|
if (*buffer->cur == '+')
|
||||||
result->type = CPP_PLUS_PLUS;
|
buffer->cur++, result->type = CPP_PLUS_PLUS;
|
||||||
else if (c == '=')
|
else if (*buffer->cur == '=')
|
||||||
result->type = CPP_PLUS_EQ;
|
buffer->cur++, result->type = CPP_PLUS_EQ;
|
||||||
else
|
|
||||||
{
|
|
||||||
BACKUP ();
|
|
||||||
result->type = CPP_PLUS;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_MINUS;
|
||||||
if (c == '>')
|
if (*buffer->cur == '>')
|
||||||
{
|
{
|
||||||
|
buffer->cur++;
|
||||||
result->type = CPP_DEREF;
|
result->type = CPP_DEREF;
|
||||||
if (CPP_OPTION (pfile, cplusplus))
|
if (*buffer->cur == '*' && CPP_OPTION (pfile, cplusplus))
|
||||||
{
|
buffer->cur++, result->type = CPP_DEREF_STAR;
|
||||||
if (get_effective_char (pfile) == '*')
|
|
||||||
result->type = CPP_DEREF_STAR;
|
|
||||||
else
|
|
||||||
BACKUP ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (c == '-')
|
|
||||||
result->type = CPP_MINUS_MINUS;
|
|
||||||
else if (c == '=')
|
|
||||||
result->type = CPP_MINUS_EQ;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BACKUP ();
|
|
||||||
result->type = CPP_MINUS;
|
|
||||||
}
|
}
|
||||||
|
else if (*buffer->cur == '-')
|
||||||
|
buffer->cur++, result->type = CPP_MINUS_MINUS;
|
||||||
|
else if (*buffer->cur == '=')
|
||||||
|
buffer->cur++, result->type = CPP_MINUS_EQ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '&':
|
case '&':
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_AND;
|
||||||
if (c == '&')
|
if (*buffer->cur == '&')
|
||||||
result->type = CPP_AND_AND;
|
buffer->cur++, result->type = CPP_AND_AND;
|
||||||
else if (c == '=')
|
else if (*buffer->cur == '=')
|
||||||
result->type = CPP_AND_EQ;
|
buffer->cur++, result->type = CPP_AND_EQ;
|
||||||
else
|
|
||||||
{
|
|
||||||
BACKUP ();
|
|
||||||
result->type = CPP_AND;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '|':
|
case '|':
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_OR;
|
||||||
if (c == '|')
|
if (*buffer->cur == '|')
|
||||||
result->type = CPP_OR_OR;
|
buffer->cur++, result->type = CPP_OR_OR;
|
||||||
else if (c == '=')
|
else if (*buffer->cur == '=')
|
||||||
result->type = CPP_OR_EQ;
|
buffer->cur++, result->type = CPP_OR_EQ;
|
||||||
else
|
|
||||||
{
|
|
||||||
BACKUP ();
|
|
||||||
result->type = CPP_OR;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ':':
|
case ':':
|
||||||
c = get_effective_char (pfile);
|
result->type = CPP_COLON;
|
||||||
if (c == ':' && CPP_OPTION (pfile, cplusplus))
|
if (*buffer->cur == ':' && CPP_OPTION (pfile, cplusplus))
|
||||||
result->type = CPP_SCOPE;
|
buffer->cur++, result->type = CPP_SCOPE;
|
||||||
else if (c == '>' && CPP_OPTION (pfile, digraphs))
|
else if (*buffer->cur == '>' && CPP_OPTION (pfile, digraphs))
|
||||||
{
|
{
|
||||||
|
buffer->cur++;
|
||||||
result->flags |= DIGRAPH;
|
result->flags |= DIGRAPH;
|
||||||
result->type = CPP_CLOSE_SQUARE;
|
result->type = CPP_CLOSE_SQUARE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
BACKUP ();
|
|
||||||
result->type = CPP_COLON;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '*': IF_NEXT_IS ('=', CPP_MULT_EQ, CPP_MULT); break;
|
case '*': IF_NEXT_IS ('=', CPP_MULT_EQ, CPP_MULT); break;
|
||||||
|
|
Loading…
Reference in New Issue