aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.h
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-07-08 19:00:39 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-07-08 19:00:39 +0000
commitbfb9dc7faa9330d05c109e8a40710b752dddea14 (patch)
treea059282fddfed885a943028a39f8275bd50d44e0 /gcc/cpplib.h
parentffc14f31599c19980371b165a7f6ad2e0a93015c (diff)
downloadgcc-bfb9dc7faa9330d05c109e8a40710b752dddea14.zip
gcc-bfb9dc7faa9330d05c109e8a40710b752dddea14.tar.gz
gcc-bfb9dc7faa9330d05c109e8a40710b752dddea14.tar.bz2
cpplib.h (struct cpp_name): Now struct cpp_string.
* cpplib.h (struct cpp_name): Now struct cpp_string. (CPP_INT, CPP_FLOAT, CPP_NUMBER, CPP_COMMENT, CPP_HEADER_NAME): Change to type S. (struct cpp_token): Rename 'name' field to 'str'. Add 'node' field, a cpp_hashnode *. All references to val.name updated to use val.str or val.node as appropriate. (struct cpp_reader): Add spec_nodes field. (cpp_idcmp): Now cpp_ideq; takes a token * and a char *. * cpphash.h (struct spec_nodes): New. (enum spell_type): Reorder. Only SPELL_STRING tokens use val.str. All references to 'spelling > SPELL_NONE' updated to match. (CPP_IN_SYSTEM_HEADER): Check pfile->buffer and pfile->buffer->inc are not NULL before dereferencing them. * cpplex.c (parse_name): Take a pointer to the current token, plus current position and limit as args; return the new position; don't copy the text of a name into the string buffer, instead call cpp_lookup and store the node pointer. If extending a token, copy out the text of the old into a scratch buffer, append the new, look that up and store the new node pointer. Inline. (maybe_paste_with_next): If the result of paste is a NAME, then look up the pasted text and store its node pointer. (lex_line): Adjust for new parse_name interface. Check for L"str", L'str' using spec_nodes->n_L. (spell_token): SPELL_IDENT tokens have their spelling in val.node->name. Handle SPELL_STRING tokens that don't have string delimiters. (_cpp_expand_name_space, (can_paste): Check for L ## "str" using spec_nodes->n_L. (cpp_get_token, special_symbol): No need to call cpp_lookup. (cpp_idcmp): Now cpp_ideq; take a token * and a const char *; return 1=equal 0=not, not a tristate. * cpphash.c (var_args_str): Delete. (find_param): Compare node fields directly. (is__va_args__): Use CPP_PEDANTIC. Just compare token->val.node with spec_nodes->n__VA_ARGS__. (dump_funlike_macro): Don't use var_args_str. * cpplib.c (_cpp_check_directive): Just walk through spec_nodes->dirs comparing pointers. (get_define_node, do_pragma_poison, detect_if_not_defined, parse_ifdef): The identifier has already been looked up. (do_ifdef, do_ifndef): parse_ifdef won't return a poisoned node. (do_if): Only call detect_if_not_defined at beginning of file. (_cpp_parse_assertion): Only copy string pointers for SPELL_STRING tokens. (pragma_dispatch): Take a node pointer and examine its name field. (_cpp_init_stacks): Also initialize the spec_nodes structure. * cppinit.c (cpp_reader_init): Call _cpp_init_stacks after _cpp_init_macros. (cpp_cleanup): Free pfile->spec_nodes. Call _cpp_cleanup_* in reverse order from the corresponding _cpp_init_* routines. * cppexp.c (parse_number, parse_charconst, parse_defined, lex): Check val.node->type instead of calling cpp_defined. Use spec_nodes entries where appropriate. * fix-header.c, scan-decls.c: Update for interface changes. From-SVN: r34926
Diffstat (limited to 'gcc/cpplib.h')
-rw-r--r--gcc/cpplib.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/gcc/cpplib.h b/gcc/cpplib.h
index 5f49f91..2868a5b 100644
--- a/gcc/cpplib.h
+++ b/gcc/cpplib.h
@@ -34,7 +34,7 @@ typedef struct cpp_options cpp_options;
typedef struct cpp_printer cpp_printer;
typedef struct cpp_token cpp_token;
typedef struct cpp_toklist cpp_toklist;
-typedef struct cpp_name cpp_name;
+typedef struct cpp_string cpp_string;
typedef struct cpp_hashnode cpp_hashnode;
/* The first two groups, apart from '=', can appear in preprocessor
@@ -112,18 +112,18 @@ typedef struct cpp_hashnode cpp_hashnode;
C(CPP_OTHER, 0) /* stray punctuation */ \
\
I(CPP_NAME, 0) /* word */ \
- I(CPP_INT, 0) /* 23 */ \
- I(CPP_FLOAT, 0) /* 3.14159 */ \
- I(CPP_NUMBER, 0) /* 34_be+ta */ \
+ S(CPP_INT, 0) /* 23 */ \
+ S(CPP_FLOAT, 0) /* 3.14159 */ \
+ S(CPP_NUMBER, 0) /* 34_be+ta */ \
S(CPP_CHAR, 0) /* 'char' */ \
S(CPP_WCHAR, 0) /* L'char' */ \
S(CPP_STRING, 0) /* "string" */ \
S(CPP_WSTRING, 0) /* L"string" */ \
\
- I(CPP_COMMENT, 0) /* Only if output comments. */ \
+ S(CPP_COMMENT, 0) /* Only if output comments. */ \
N(CPP_MACRO_ARG, 0) /* Macro argument. */ \
N(CPP_EOF, 0) /* End of file. */ \
- I(CPP_HEADER_NAME, 0) /* <stdio.h> in #include */
+ S(CPP_HEADER_NAME, 0) /* <stdio.h> in #include */
#define T(e, s) e,
#define I(e, s) e,
@@ -141,8 +141,8 @@ enum cpp_ttype
#undef C
#undef N
-/* Payload of a NAME, NUMBER, FLOAT, STRING, or COMMENT token. */
-struct cpp_name
+/* Payload of a NUMBER, FLOAT, STRING, or COMMENT token. */
+struct cpp_string
{
unsigned int len;
const unsigned char *text;
@@ -168,7 +168,8 @@ struct cpp_token
union
{
HOST_WIDEST_INT integer; /* an integer */
- struct cpp_name name; /* a string */
+ struct cpp_hashnode *node; /* an identifier */
+ struct cpp_string str; /* a string, or number */
unsigned int aux; /* argument no. for a CPP_MACRO_ARG, or
character represented by CPP_OTHER. */
} val;
@@ -558,6 +559,10 @@ struct cpp_reader
/* True if output_line_command needs to output a newline. */
unsigned char need_newline;
+
+ /* Special nodes - identifiers with predefined significance to the
+ preprocessor. */
+ struct spec_nodes *spec_nodes;
};
/* struct cpp_printer encapsulates state used to convert the stream of
@@ -693,8 +698,8 @@ extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
extern cpp_buffer *cpp_pop_buffer PARAMS ((cpp_reader *));
extern void cpp_scan_buffer PARAMS ((cpp_reader *, cpp_printer *));
extern void cpp_scan_buffer_nooutput PARAMS ((cpp_reader *));
-extern int cpp_idcmp PARAMS ((const unsigned char *,
- size_t, const char *));
+extern int cpp_ideq PARAMS ((const cpp_token *,
+ const char *));
/* In cpphash.c */
extern int cpp_defined PARAMS ((cpp_reader *,