OSDN Git Service

* c-lex.c (read_escape, read_ucs): Delete.
[pf3gnuchains/gcc-fork.git] / gcc / cpplib.h
index e332a27..bfc6a3f 100644 (file)
@@ -20,10 +20,11 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  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" {
@@ -45,6 +46,7 @@ typedef struct cpp_callbacks cpp_callbacks;
 
 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
@@ -119,6 +121,7 @@ struct file_name_map_list;
   OP(CPP_SCOPE,                "::")                   \
   OP(CPP_DEREF_STAR,   "->*")                  \
   OP(CPP_DOT_STAR,     ".*")                   \
+  OP(CPP_ATSIGN,       "@")  /* used in Objective C */ \
 \
   TK(CPP_NAME,         SPELL_IDENT)    /* word */                      \
   TK(CPP_INT,          SPELL_STRING)   /* 23 */                        \
@@ -131,7 +134,6 @@ struct file_name_map_list;
 \
   TK(CPP_STRING,       SPELL_STRING)   /* "string" */                  \
   TK(CPP_WSTRING,      SPELL_STRING)   /* L"string" */                 \
-  TK(CPP_OSTRING,      SPELL_STRING)   /* @"string" - Objective C */   \
   TK(CPP_HEADER_NAME,  SPELL_STRING)   /* <stdio.h> in #include */     \
 \
   TK(CPP_COMMENT,      SPELL_STRING)   /* Only if output comments.  */ \
@@ -166,6 +168,7 @@ struct cpp_string
 #define PASTE_LEFT     (1 << 3) /* If on LHS of a ## operator.  */
 #define NAMED_OP       (1 << 4) /* C++ named operators.  */
 #define NO_EXPAND      (1 << 5) /* Do not macro-expand this token.  */
+#define AVOID_LPASTE   (1 << 6) /* Check left for accidental pastes.  */
 
 /* A preprocessing token.  This has been carefully packed and should
    occupy 12 bytes on 32-bit hosts and 16 bytes on 64-bit hosts.  */
@@ -176,7 +179,7 @@ struct cpp_token
 
   union
   {
-    struct cpp_hashnode *node; /* An identifier.  */
+    cpp_hashnode *node;                /* An identifier.  */
     struct cpp_string str;     /* A string, or number.  */
     unsigned int arg_no;       /* Argument no. for a CPP_MACRO_ARG.  */
     unsigned char c;           /* Character represented by CPP_OTHER.  */
@@ -239,8 +242,8 @@ struct cpp_options
   const char *deps_file;
 
   /* Search paths for include files.  */
-  struct file_name_list *quote_include;         /* First dir to search for "file" */
-  struct file_name_list *bracket_include;/* First dir to search for <file> */
+  struct search_path *quote_include;   /* "" */
+  struct search_path *bracket_include;  /* <> */
 
   /* Map between header names and file names, used only on DOS where
      file names are limited in length.  */
@@ -443,6 +446,7 @@ enum cpp_buffer_type {BUF_FAKE, BUF_FILE, BUF_BUILTIN,
 #define NODE_POISONED  (1 << 1)        /* Poisoned identifier.  */
 #define NODE_BUILTIN   (1 << 2)        /* Builtin macro.  */
 #define NODE_DIAGNOSTIC (1 << 3)       /* Possible diagnostic when lexed.  */
+#define NODE_WARN      (1 << 4)        /* Warn if redefined or undefined.  */
 
 /* Different flavors of hash node.  */
 enum node_type
@@ -464,21 +468,22 @@ enum builtin_type
   BT_STDC                      /* `__STDC__' */
 };
 
-/* There is a slot in the hashnode for use by front ends when integrated
-   with cpplib.  It holds a tree (see tree.h) but we mustn't drag that
-   header into every user of cpplib.h.  cpplib does not do anything with
-   this slot except clear it when a new node is created.  */
-union tree_node;
+#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 cpp_hashnode
 {
-  const unsigned char *name;           /* Null-terminated name.  */
-  unsigned int hash;                   /* Cached hash value.  */
-  unsigned short length;               /* Length of name excluding null.  */
+  struct ht_identifier ident;
   unsigned short arg_index;            /* Macro argument index.  */
   unsigned char directive_index;       /* Index into directive table.  */
-  ENUM_BITFIELD(node_type) type : 8;   /* Node type.  */
-  unsigned char flags;                 /* Node flags.  */
+  unsigned char rid_code;              /* Rid code - for front ends.  */
+  ENUM_BITFIELD(node_type) type : 8;   /* CPP node type.  */
+  unsigned char flags;                 /* CPP flags.  */
 
   union
   {
@@ -487,12 +492,18 @@ struct cpp_hashnode
     enum cpp_ttype operator;           /* Code for a named operator.  */
     enum builtin_type builtin;         /* Code for a builtin macro.  */
   } value;
-
-  union tree_node *fe_value;           /* Front end 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 int cpp_destroy PARAMS ((cpp_reader *));
 
 /* Call these to get pointers to the options and callback structures
    for a given reader.  These pointers are good until you call
@@ -529,7 +540,6 @@ extern void cpp_register_pragma_space PARAMS ((cpp_reader *, const char *));
 
 extern int cpp_start_read PARAMS ((cpp_reader *, const char *));
 extern void cpp_finish PARAMS ((cpp_reader *));
-extern void cpp_cleanup PARAMS ((cpp_reader *));
 extern int cpp_avoid_paste PARAMS ((cpp_reader *, const cpp_token *,
                                    const cpp_token *));
 extern enum cpp_ttype cpp_can_paste PARAMS ((cpp_reader *, const cpp_token *,
@@ -539,6 +549,11 @@ extern const cpp_lexer_pos *cpp_get_line PARAMS ((cpp_reader *));
 extern const unsigned char *cpp_macro_definition PARAMS ((cpp_reader *,
                                                  const cpp_hashnode *));
 
+/* Evaluate a CPP_CHAR or CPP_WCHAR token.  */
+extern HOST_WIDE_INT
+cpp_interpret_charconst PARAMS ((cpp_reader *, const cpp_token *,
+                                int, int, unsigned int *));
+
 extern void cpp_define PARAMS ((cpp_reader *, const char *));
 extern void cpp_assert PARAMS ((cpp_reader *, const char *));
 extern void cpp_undef  PARAMS ((cpp_reader *, const char *));
@@ -586,20 +601,28 @@ extern int cpp_ideq                       PARAMS ((const cpp_token *,
 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));
 extern void cpp_start_lookahead                PARAMS ((cpp_reader *));
 extern void cpp_stop_lookahead         PARAMS ((cpp_reader *, int));
+extern int  cpp_sys_macro_p            PARAMS ((cpp_reader *));
 
 /* In cppfiles.c */
 extern int cpp_included        PARAMS ((cpp_reader *, const char *));
@@ -608,4 +631,4 @@ extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int));
 #ifdef __cplusplus
 }
 #endif
-#endif /* __GCC_CPPLIB__ */
+#endif /* GCC_CPPLIB_H */