home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / browser2.zip / lex.h < prev    next >
C/C++ Source or Header  |  1995-02-17  |  9KB  |  275 lines

  1. /* EMACS CLASS BROWSER FOR C++.
  2.    Copyright (C) 1993 Gerd Moellmann,
  3.    Altenbergstr. 6, D-4000 Duesseldorf 1, Germany
  4.  
  5.    $Id: lex.h,v 3.1 1995/02/17 18:20:24 mmann Exp $
  6.  
  7.    This file is part of GNU Emacs.
  8.  
  9.    GNU Emacs is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY.  No author or distributor
  11.    accepts responsibility to anyone for the consequences of using it
  12.    or for whether it serves any particular purpose or works at all,
  13.    unless he says so in writing.  Refer to the GNU Emacs General Public
  14.    License for full details.
  15.  
  16.    Everyone is granted permission to copy, modify and redistribute
  17.    GNU Emacs, but only under the conditions described in the
  18.    GNU Emacs General Public License.   A copy of this license is
  19.    supposed to have been given to you along with GNU Emacs so you
  20.    can know your rights and responsibilities.  It should be in a
  21.    file named COPYING.  Among other things, the copyright notice
  22.    and this notice must be preserved on all copies. */
  23.  
  24. #ifndef lex_h_included
  25. #define lex_h_included
  26.  
  27. #ifdef __BORLANDC__
  28. #define PROTOTYPES
  29. #endif
  30.  
  31. #ifdef __IBMC__
  32. #define PROTOTYPES
  33. #endif
  34.  
  35. #ifdef MSDOS
  36. #define CONVERT_BACKSLASH
  37. #endif
  38.  
  39. #ifdef OS2
  40. #define CONVERT_BACKSLASH
  41. #endif
  42.  
  43. /* Parameters. */
  44.  
  45. #ifdef MSDOS
  46. #define INBUFFER_SIZE   64000        /* would you believe that there are
  47.                                         source files larger than this? */
  48. #else
  49. #define INBUFFER_SIZE    200000
  50. #endif
  51.  
  52. #define MAX_ID_LENGTH   100
  53. #define MAX_REGEXP      50
  54. #define MIN_REGEXP      5
  55. #define DEFAULT_OUTFILE "BROWSE"
  56. #define VERSION         "GeM 3.00"
  57. #define USE_STRUCTS     1           /* Use Lisp structs where possible */
  58. #define USE_ARRAYS      1           /* Use Lisp arrays where possible */
  59. #define SYM_HASH_SIZE   1001        /* Hash table size for classes */
  60. #define MAX_INPUTFILES  50          /* Max no. of -i<file> options */
  61. #define GLOBALS_NAME    "*Globals*" /* Name of pseudo class for globals. */
  62.  
  63. /* Storage classes, so to say. */
  64.  
  65. #define SC_UNKNOWN      0
  66. #define SC_MEMBER       1
  67. #define SC_STATIC       2
  68. #define SC_FRIEND       3
  69. #define SC_TYPE         4
  70.  
  71. /* Visibility */
  72.  
  73. #define V_PUBLIC        0
  74. #define V_PROTECTED     1
  75. #define V_PRIVATE       2
  76.  
  77. /* Constants. */
  78.  
  79. #define CSTRING         256
  80. #define CCHAR           257
  81. #define CINT            258
  82. #define CFLOAT          259
  83.  
  84. /* Tokens not expressable with multibyte character constants. */
  85.  
  86. #define ELLIPSIS        260    /* ... */
  87. #define LSHIFTASGN      261    /* <<= */
  88. #define RSHIFTASGN      262    /* >>= */
  89. #define ARROWSTAR       263    /* ->* */
  90. #define IDENT           264    /* identifier */
  91. #define DIVASGN        265    /* /= */
  92. #define INC        266    /* ++ */
  93. #define ADDASGN        267    /* += */
  94. #define DEC        268    /* -- */
  95. #define ARROW        269    /* -> */
  96. #define SUBASGN        270    /* -= */
  97. #define MULASGN        271    /* *= */
  98. #define MODASGN        272    /* %= */
  99. #define LOR        273    /* || */
  100. #define ORASGN        274    /* |= */
  101. #define LAND        275    /* && */
  102. #define ANDASGN        276    /* &= */
  103. #define XORASGN        277    /* ^= */
  104. #define POINTSTAR    278    /* .* */
  105. #define DCOLON        279    /* :: */
  106. #define EQ        280    /* == */
  107. #define NE        281    /* != */
  108. #define LE        282    /* <= */
  109. #define LSHIFT        283    /* << */
  110. #define GE        284    /* >= */
  111. #define RSHIFT        285    /* >> */
  112.  
  113.  
  114. /* Keywords in alphabetical order */
  115.  
  116. #define ASM             286
  117. #define AUTO            287
  118. #define BREAK           288
  119. #define CASE            289
  120. #define CATCH           290
  121. #define CHAR            291
  122. #define CLASS           292
  123. #define CONST           293
  124. #define CONTINUE        294
  125. #define DEFAULT         295
  126. #define DELETE          296
  127. #define DO              297
  128. #define DOUBLE          298
  129. #define ELSE            299
  130. #define ENUM            300
  131. #define EXTERN          301
  132. #define FLOAT           302
  133. #define FOR             303
  134. #define FRIEND          304
  135. #define GOTO            305
  136. #define IF              306
  137. #define INLINE          307
  138. #define INT             308
  139. #define LONG            309
  140. #define NEW             310
  141. #define OPERATOR        311
  142. #define PRIVATE         312
  143. #define PROTECTED       313
  144. #define PUBLIC          314
  145. #define REGISTER        315
  146. #define RETURN          316
  147. #define SHORT           317
  148. #define SIGNED          318
  149. #define SIZEOF          319
  150. #define STATIC          320
  151. #define STRUCT          321
  152. #define SWITCH          322
  153. #define TEMPLATE        323
  154. #define THIS            324
  155. #define THROW           325
  156. #define TRY             326
  157. #define TYPEDEF         327
  158. #define UNION           328
  159. #define UNSIGNED        329
  160. #define VIRTUAL         330
  161. #define VOID            331
  162. #define VOLATILE        332
  163. #define WHILE           333
  164. #define YYEOF           0
  165.  
  166. /* The following depends on the CL implementation in use, and its
  167.    implementation of `structs'. */
  168.  
  169. #define TREE_HEADER_STRUCT    "[cl-struct-tree-header "
  170. #define TREE_STRUCT        "[cl-struct-tree "
  171. #define MEMBER_STRUCT        "[cl-struct-member "
  172. #define BROWSE_STRUCT        "[cl-struct-browse "
  173. #define CLASS_STRUCT        "[cl-struct-class "
  174.  
  175. extern char yytext[];
  176. extern FILE* yyout;
  177. extern int regexp_file;
  178. extern char* filename;
  179. extern char* regexp_filename;
  180. extern unsigned yyline;
  181. extern int f_costly_friends;
  182. extern int f_append;
  183. extern int f_structs;
  184. extern int f_verbose;
  185. extern int f_very_verbose;
  186. extern int f_emacs;
  187. extern int f_regexps;
  188. extern int f_nested_classes;
  189. extern long total_allocated;
  190. extern long long_val;
  191.  
  192. typedef struct link
  193. {
  194.   struct sym* sym;
  195.   struct link* next;
  196. }
  197. link_t;
  198.  
  199. typedef struct member
  200. {
  201.   struct member* next;
  202.   long params;                  /* hash value for parameter types */
  203.   unsigned vis : 4;             /* visibility (private, ...) */
  204.   unsigned is_virtual : 1;      /* virtual function? */
  205.   unsigned is_inline : 1;       /* inline function? */
  206.   unsigned is_const : 1;        /* const function? */
  207.   unsigned is_pure : 1;         /* pure virtual function? */
  208.   char* regexp;                 /* matching regular expression */
  209.   char* filename;               /* don't free this shared string */
  210.   unsigned pos;                 /* buffer position of occurrence */
  211.   char* def_regexp;
  212.   char* def_filename;           /* don't free this shared string */
  213.   unsigned def_pos;
  214.   char name[1];
  215. }
  216. member_t;
  217.  
  218. /* The structure used to describe a class in the symbol
  219.    table. */
  220.  
  221. typedef struct sym
  222. {
  223.   unsigned is_template : 1;    /* is class a template class? */
  224.   unsigned visited : 1;        /* used to find circles. */
  225.   struct sym* next;             /* hash collision list */
  226.   link_t* subs;                 /* list of subclasses */
  227.   link_t* supers;               /* list of superclasses */
  228.   member_t* vars;               /* list of instance variables */
  229.   member_t* fns;                /* list of instance functions */
  230.   member_t* static_vars;        /* list of static variables */
  231.   member_t* static_fns;         /* list of static functions */
  232.   member_t* friends;            /* list of friend functions */
  233.   member_t* types;              /* list of local types */
  234.   char* regexp;                 /* matching regular expression */
  235.   unsigned pos;                 /* buffer position */
  236.   char* filename;               /* file in which it can be found */
  237.   char* sfilename;              /* file in which members can be found */
  238.   char name[1];                 /* name of the class */
  239. }
  240. sym_t;
  241.  
  242. #ifdef PROTOTYPES
  243. int yylex (void);
  244. void yyerror (char* format, ...);
  245. int yyparse (void);
  246. void re_init_parse (void);
  247. char* token_string (unsigned tk);
  248. char* line_start (void);
  249. unsigned buffer_pos (void);
  250. void init_sym (void);
  251. sym_t* add_sym (char* name);
  252. sym_t* find_sym (char* name);
  253. void add_link (sym_t* super, sym_t* sub);
  254. void add_member_definition (sym_t* cls, char* name, char* regexp,
  255.                             unsigned pos, long hash, int var,
  256.                             int is_static, int is_inline, int is_const);
  257. void add_member_declaration (sym_t* cls, char* name, char* regexp,
  258.                              unsigned pos, long hash, int var,
  259.                              int is_static, unsigned vis,
  260.                              int is_virtual, int is_inline,
  261.                              int is_const, int is_pure);
  262. void dump_roots (FILE* fp);
  263. char* dupstr (char* s);
  264. void* xmalloc (unsigned sz);
  265. void xfree (void* p);
  266. void add_global_definition (char* name, char* regexp, unsigned pos,
  267.                             long hash, int is_var, int sc, int is_inline,
  268.                 int is_const);
  269. void add_global_declaration (char* name, char* regexp, unsigned pos,
  270.                  long hash, int is_var, int sc, int is_inline,
  271.                  int is_const);
  272. void mark_inherited_virtual (void);
  273. #endif
  274. #endif
  275.