aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplex.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-07-08 02:33:00 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-07-08 02:33:00 +0000
commitcf00a885103d939b2175adc8918908a3b6f211d2 (patch)
tree063609848f321cdd31d0d1155b156f5af32e889c /gcc/cpplex.c
parent563dd08adfa12573fdecf9669fdf685fef5fd360 (diff)
downloadgcc-cf00a885103d939b2175adc8918908a3b6f211d2.zip
gcc-cf00a885103d939b2175adc8918908a3b6f211d2.tar.gz
gcc-cf00a885103d939b2175adc8918908a3b6f211d2.tar.bz2
cppexp.c: Update all code for new lexer interface.
* cppexp.c: Update all code for new lexer interface. (op_t, operator codes, struct token, tokentab2, op_to_str): Remove. (struct suffix, vsuf_1, vsuf_2, vsuf_3, op_to_prio): New. * cpplex.c (token_names): Trim leading CPP_ from names; make the strings unsigned. (_cpp_spell_operator): New. (is_macro_disabled): Disable all macros if rescanning preprocessed text. (_cpp_get_directive_token): Remove. * cppinit.c: Don't set no_macro_expand. * cpplib.c (read_line_number, do_line): Check only for EOF, not VSPACE. * cpphash.h: Update prototypes. * cpplib.h (CPP_VSPACE): Remove. (struct cpp_reader): Remove no_macro_expand. testsuite: * gcc.dg/cpp/19951227-1.c, gcc.dg/cpp/assert2.c, gcc.dg/cpp/if-1.c, gcc.dg/cpp/if-4.c: Tweak error regexps. From-SVN: r34920
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r--gcc/cpplex.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 03439fa..23d6540 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -167,13 +167,13 @@ token_spellings [N_TTYPES + 1] = {TTYPE_TABLE {0, 0} };
#undef N
/* For debugging: the internal names of the tokens. */
-#define T(e, s) STRINGX(e),
-#define I(e, s) STRINGX(e),
-#define S(e, s) STRINGX(e),
-#define C(e, s) STRINGX(e),
-#define N(e, s) STRINGX(e),
+#define T(e, s) U STRINGX(e) + 4,
+#define I(e, s) U STRINGX(e) + 4,
+#define S(e, s) U STRINGX(e) + 4,
+#define C(e, s) U STRINGX(e) + 4,
+#define N(e, s) U STRINGX(e) + 4,
-const char * const token_names[N_TTYPES] = { TTYPE_TABLE };
+const U_CHAR *const token_names[N_TTYPES] = { TTYPE_TABLE };
#undef T
#undef I
@@ -1872,10 +1872,9 @@ output_token (pfile, token, prev)
}
/* Write the spelling of a token TOKEN to BUFFER. The buffer must
- already contain the enough space to hold the token's spelling. If
- WHITESPACE is true, and the token was preceded by whitespace,
- output a single space before the token proper. Returns a pointer
- to the character after the last character written. */
+ already contain the enough space to hold the token's spelling.
+ Returns a pointer to the character after the last character
+ written. */
static unsigned char *
spell_token (pfile, token, buffer)
@@ -1933,6 +1932,19 @@ spell_token (pfile, token, buffer)
return buffer;
}
+/* Return the spelling of a token known to be an operator.
+ Does not distinguish digraphs from their counterparts. */
+const unsigned char *
+_cpp_spell_operator (type)
+ enum cpp_ttype type;
+{
+ if (token_spellings[type].type == SPELL_OPERATOR)
+ return token_spellings[type].spelling;
+ else
+ return token_names[type];
+}
+
+
/* Macro expansion algorithm. TODO. */
static const cpp_token placemarker_token = {0, 0, CPP_PLACEMARKER, 0 UNION_INIT_ZERO};
@@ -2022,6 +2034,10 @@ is_macro_disabled (pfile, expansion, token)
{
cpp_context *context = CURRENT_CONTEXT (pfile);
+ /* Don't expand anything if this file has already been preprocessed. */
+ if (CPP_OPTION (pfile, preprocessed))
+ return 1;
+
/* Arguments on either side of ## are inserted in place without
macro expansion (6.10.3.3.2). Conceptually, any macro expansion
occurs during a later rescan pass. The effect is that we expand
@@ -3275,26 +3291,6 @@ _cpp_dump_list (pfile, list, token, flush)
cpp_output_tokens (pfile, pfile->printer, pfile->token_list.line);
}
-/* Stub function during conversion, mainly for cppexp.c's benefit. */
-enum cpp_ttype
-_cpp_get_directive_token (pfile)
- cpp_reader *pfile;
-{
- const cpp_token *tok;
-
- if (pfile->no_macro_expand)
- tok = _cpp_get_raw_token (pfile);
- else
- tok = cpp_get_token (pfile);
-
- if (tok->type == CPP_EOF)
- return CPP_VSPACE; /* backward compat; and don't try to spell EOF */
-
- CPP_RESERVE (pfile, TOKEN_LEN (tok));
- pfile->limit = spell_token (pfile, tok, pfile->limit);
- return tok->type;
-}
-
/* Allocate pfile->input_buffer, and initialize trigraph_map[]
if it hasn't happened already. */