macro.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* PREPROCESSOR: DEFINITION OF MACRO DESCRIPTOR */
  7. /* The flags of the mc_flag field of the macro structure. Note that
  8. these flags can be set simultaneously.
  9. */
  10. #define NOFLAG 0 /* no special flags */
  11. #define FUNC 01 /* function attached */
  12. #define NOREPLACE 02 /* don't replace */
  13. #define FORMALP 0200 /* mask for creating macro formal parameter */
  14. /* The macro descriptor is very simple, except the fact that the
  15. mc_text, which points to the replacement text, contains the
  16. non-ascii characters \201, \202, etc, indicating the position of a
  17. formal parameter in this text.
  18. */
  19. struct macro {
  20. struct macro *next;
  21. char * mc_text; /* the replacement text */
  22. int mc_nps; /* number of formal parameters */
  23. int mc_length; /* length of replacement text */
  24. int mc_count; /* # of "concurrent" invocations*/
  25. char mc_flag; /* marking this macro */
  26. };
  27. /* allocation definitions of struct macro */
  28. extern char *st_alloc();
  29. extern struct macro *h_macro;
  30. #ifdef DEBUG
  31. extern int cnt_macro;
  32. extern char *std_alloc();
  33. #define new_macro() ((struct macro *) std_alloc((char **)&h_macro, sizeof(struct macro), 20, &cnt_macro))
  34. #else
  35. #define new_macro() ((struct macro *) st_alloc((char **)&h_macro, sizeof(struct macro), 20))
  36. #endif
  37. #define free_macro(p) st_free(p, &h_macro, sizeof(struct macro))
  38. struct mlist {
  39. struct mlist *next;
  40. struct macro *m_mac;
  41. char *m_repl;
  42. int m_level;
  43. };
  44. /* allocation definitions of struct mlist */
  45. extern char *st_alloc();
  46. extern struct mlist *h_mlist;
  47. #ifdef DEBUG
  48. extern int cnt_mlist;
  49. extern char *std_alloc();
  50. #define new_mlist() ((struct mlist *) std_alloc((char **)&h_mlist, sizeof(struct mlist), 20, &cnt_mlist))
  51. #else
  52. #define new_mlist() ((struct mlist *) st_alloc((char **)&h_mlist, sizeof(struct mlist), 20))
  53. #endif
  54. #define free_mlist(p) st_free(p, &h_mlist, sizeof(struct mlist))
  55. /* `token' numbers of keywords of command-line processor
  56. */
  57. #define K_UNKNOWN 0
  58. #define K_DEFINE 1
  59. #define K_ELIF 2
  60. #define K_ELSE 3
  61. #define K_ENDIF 4
  62. #define K_IF 5
  63. #define K_IFDEF 6
  64. #define K_IFNDEF 7
  65. #define K_INCLUDE 8
  66. #define K_LINE 9
  67. #define K_UNDEF 10
  68. #define K_PRAGMA 11
  69. #define K_FILE 100 /* for dependency generator */