diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-17 18:26:12 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-17 18:26:12 +0000 |
commit | 10b4496ae30845cc3fd784538f35424af952ee8b (patch) | |
tree | 1bee8006a617d6612c2e199afafa13805239e1a9 /gcc/cpplex.c | |
parent | 4e3fed9fd399258823275676d983e5b2dba33397 (diff) | |
download | gcc-10b4496ae30845cc3fd784538f35424af952ee8b.tar.gz |
* cpphash.h (_cpp_lex_direct): New.
* cpplex.c (_cpp_lex_token): Update.
(lex_token): Rename _cpp_lex_direct; lex into pfile->cur_token,
and increment that pointer.
* cppmacro.c (alloc_expansion_token): New.
(lex_expansion_token): Lex macro expansion directly into
macro storage.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45656 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 1bfca20092c..e734f4021b2 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -102,7 +102,6 @@ static void lex_dot PARAMS ((cpp_reader *, cpp_token *)); static int name_p PARAMS ((cpp_reader *, const cpp_string *)); static int maybe_read_ucs PARAMS ((cpp_reader *, const unsigned char **, const unsigned char *, unsigned int *)); -static cpp_token *lex_token PARAMS ((cpp_reader *, cpp_token *)); static tokenrun *next_tokenrun PARAMS ((tokenrun *)); static cpp_chunk *new_chunk PARAMS ((unsigned int)); @@ -811,7 +810,7 @@ save_comment (pfile, token, from) memcpy (buffer + 1, from, len - 1); } -/* Subroutine of lex_token to handle '%'. A little tricky, since we +/* Subroutine of _cpp_lex_direct to handle '%'. A little tricky, since we want to avoid stepping back when lexing %:%X. */ static void lex_percent (pfile, result) @@ -860,7 +859,7 @@ lex_percent (pfile, result) } } -/* Subroutine of lex_token to handle '.'. This is tricky, since we +/* Subroutine of _cpp_lex_direct to handle '.'. This is tricky, since we want to avoid stepping back when lexing '...' or '.123'. In the latter case we should also set a flag for parse_number. */ static void @@ -932,7 +931,9 @@ next_tokenrun (run) return run->next; } -/* Lex a token into RESULT (external interface). */ +/* Lex a token into RESULT (external interface). Takes care of issues + like directive handling, token lookahead, multiple include + opimisation and skipping. */ const cpp_token * _cpp_lex_token (pfile) cpp_reader *pfile; @@ -946,12 +947,14 @@ _cpp_lex_token (pfile) pfile->cur_run = next_tokenrun (pfile->cur_run); pfile->cur_token = pfile->cur_run->base; } - result = pfile->cur_token++; if (pfile->lookaheads) - pfile->lookaheads--; + { + pfile->lookaheads--; + result = pfile->cur_token++; + } else - result = lex_token (pfile, result); + result = _cpp_lex_direct (pfile); if (result->flags & BOL) { @@ -970,7 +973,7 @@ _cpp_lex_token (pfile) break; /* Outside a directive, invalidate controlling macros. At file - EOF, lex_token takes care of popping the buffer, so we never + EOF, _cpp_lex_direct takes care of popping the buffer, so we never get here and MI optimisation works. */ pfile->mi_valid = false; @@ -981,17 +984,25 @@ _cpp_lex_token (pfile) return result; } -/* Lex a token into RESULT. When meeting a newline, returns CPP_EOF - if parsing a directive, otherwise returns to the start of the token - buffer if permissible. Returns the location of the lexed token. */ -static cpp_token * -lex_token (pfile, result) +/* Lex a token into pfile->cur_token, which is also incremented, to + get diagnostics pointing to the correct location. + + Does not handle issues such as token lookahead, multiple-include + optimisation, directives, skipping etc. This function is only + suitable for use by _cpp_lex_token, and in special cases like + lex_expansion_token which doesn't care for any of these issues. + + When meeting a newline, returns CPP_EOF if parsing a directive, + otherwise returns to the start of the token buffer if permissible. + Returns the location of the lexed token. */ +cpp_token * +_cpp_lex_direct (pfile) cpp_reader *pfile; - cpp_token *result; { cppchar_t c; cpp_buffer *buffer; const unsigned char *comment_start; + cpp_token *result = pfile->cur_token++; fresh_line: buffer = pfile->buffer; |