In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
-#ifndef __GCC_CPPLIB__
-#define __GCC_CPPLIB__
+#ifndef GCC_CPPLIB_H
+#define GCC_CPPLIB_H
#include <sys/types.h>
+#include "hashtable.h"
#ifdef __cplusplus
extern "C" {
typedef struct cpp_options cpp_options;
typedef struct cpp_token cpp_token;
typedef struct cpp_string cpp_string;
-typedef struct c_common_identifier cpp_hashnode;
+typedef struct cpp_hashnode cpp_hashnode;
typedef struct cpp_macro cpp_macro;
typedef struct cpp_lexer_pos cpp_lexer_pos;
typedef struct cpp_lookahead cpp_lookahead;
struct answer;
struct file_name_map_list;
+struct ht;
/* The first two groups, apart from '=', can appear in preprocessor
expressions. This allows a lookup table to be implemented in
BT_STDC /* `__STDC__' */
};
-#include "c-rid.h"
-
-#define C_RID_CODE(id) (((struct c_common_identifier *) (id))->rid_code)
+#define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE))
+#define HT_NODE(NODE) ((ht_identifier *) (NODE))
+#define NODE_LEN(NODE) HT_LEN (&(NODE)->ident)
+#define NODE_NAME(NODE) HT_STR (&(NODE)->ident)
/* The common part of an identifier node shared amongst all 3 C front
ends. Also used to store CPP identifiers, which are a superset of
identifiers in the grammatical sense. */
-struct c_common_identifier
+struct cpp_hashnode
{
- struct tree_identifier ident; /* See tree-core.h. */
+ struct ht_identifier ident;
unsigned short arg_index; /* Macro argument index. */
unsigned char directive_index; /* Index into directive table. */
- ENUM_BITFIELD(rid) rid_code : 8; /* Rid code - for front ends. */
+ unsigned char rid_code; /* Rid code - for front ends. */
ENUM_BITFIELD(node_type) type : 8; /* CPP node type. */
unsigned char flags; /* CPP flags. */
} value;
};
-/* Call this first to get a handle to pass to other functions. */
-extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
+/* Call this first to get a handle to pass to other functions. If you
+ want cpplib to manage its own hashtable, pass in a NULL pointer.
+ Or you can pass in an initialised hash table that cpplib will use;
+ this technique is used by the C front ends. */
+extern cpp_reader *cpp_create_reader PARAMS ((struct ht *,
+ enum c_lang));
/* Call this to release the handle. Any use of the handle after this
function returns is invalid. Returns cpp_errors (pfile). */
extern void cpp_output_line PARAMS ((cpp_reader *, FILE *));
extern void cpp_output_token PARAMS ((const cpp_token *, FILE *));
extern const char *cpp_type2name PARAMS ((enum cpp_ttype));
+extern unsigned int cpp_parse_escape PARAMS ((cpp_reader *,
+ const unsigned char **,
+ const unsigned char *,
+ unsigned HOST_WIDE_INT, int));
/* In cpphash.c */
+
+/* Lookup an identifier in the hashtable. Puts the identifier in the
+ table if it is not already there. */
extern cpp_hashnode *cpp_lookup PARAMS ((cpp_reader *,
- const unsigned char *, size_t));
+ const unsigned char *,
+ unsigned int));
+
+typedef int (*cpp_cb) PARAMS ((cpp_reader *, cpp_hashnode *, void *));
extern void cpp_forall_identifiers PARAMS ((cpp_reader *,
- int (*) PARAMS ((cpp_reader *,
- cpp_hashnode *,
- void *)),
- void *));
+ cpp_cb, void *));
/* In cppmacro.c */
extern void cpp_scan_buffer_nooutput PARAMS ((cpp_reader *, int));
#ifdef __cplusplus
}
#endif
-#endif /* __GCC_CPPLIB__ */
+#endif /* GCC_CPPLIB_H */