aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorNeil Booth <neilb@earthling.net>2000-04-27 05:49:33 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-04-27 05:49:33 +0000
commit6777db6d4ae38b136bc0a937afb61e95f5468a6a (patch)
tree7b5ab3deec58ecdc4da392d9db01abcef6b534cf /gcc/cpplex.c
parentb4593d17c03d7a32bb761b5d22a4fa0285548216 (diff)
downloadgcc-6777db6d4ae38b136bc0a937afb61e95f5468a6a.zip
gcc-6777db6d4ae38b136bc0a937afb61e95f5468a6a.tar.gz
gcc-6777db6d4ae38b136bc0a937afb61e95f5468a6a.tar.bz2
cpplib.h: "~=" is not a single pp-token.
2000-04-26 Neil Booth <NeilB@earthling.net> * cpplib.h: "~=" is not a single pp-token. * cpplex.c: Correct commentary. From-SVN: r33463
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 1f9a359..11a88e1 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -2056,24 +2056,24 @@ _cpp_init_input_buffer (pfile)
that replaced trigraphs and deleted esacped newlines, and a second
pass that tokenized the result of the first pass. Tokenisation was
performed by peeking at the next character in the input stream. For
- example, if the input stream contained "~=", the handler for the ~
+ example, if the input stream contained "!=", the handler for the !
character would peek at the next character, and if it were a '='
- would skip over it, and return a "~=" token, otherwise it would
- return just the "~" token.
+ would skip over it, and return a "!=" token, otherwise it would
+ return just the "!" token.
To implement a single-pass lexer, this peeking ahead is unworkable.
An arbitrary number of escaped newlines, and trigraphs (in particular
- ??/ which translates to the escape \), could separate the '~' and '='
- in the input stream, yet the next token is still a "~=".
+ ??/ which translates to the escape \), could separate the '!' and '='
+ in the input stream, yet the next token is still a "!=".
Suppose instead that we lex by one logical line at a time, producing
- a token list or stack for each logical line, and when seeing the '~'
- push a CPP_COMPLEMENT token on the list. Then if the '~' is part of
- a longer token ("~=") we know we must see the remainder of the token
- by the time we reach the end of the logical line. Thus we can have
- the '=' handler look at the previous token (at the end of the list /
- top of the stack) and see if it is a "~" token, and if so, instead of
- pushing a "=" token revise the existing token to be a "~=" token.
+ a token list or stack for each logical line, and when seeing the '!'
+ push a CPP_NOT token on the list. Then if the '!' is part of a
+ longer token ("!=") we know we must see the remainder of the token by
+ the time we reach the end of the logical line. Thus we can have the
+ '=' handler look at the previous token (at the end of the list / top
+ of the stack) and see if it is a "!" token, and if so, instead of
+ pushing a "=" token revise the existing token to be a "!=" token.
This works in the presence of escaped newlines, because the '\' would
have been pushed on the top of the stack as a CPP_BACKSLASH. The
@@ -2091,7 +2091,7 @@ _cpp_init_input_buffer (pfile)
To the preprocessor, whitespace is only significant to the point of
knowing whether whitespace precedes a particular token. For example,
the '=' handler needs to know whether there was whitespace between it
- and a "~" token on the top of the stack, to make the token conversion
+ and a "!" token on the top of the stack, to make the token conversion
decision correctly. So each token has a PREV_WHITESPACE flag to
indicate this - the standard permits consecutive whitespace to be
regarded as a single space. The compiler front ends are not