LLlex.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. *
  5. * Author: Ceriel J.H. Jacobs
  6. */
  7. /* T O K E N D E S C R I P T O R D E F I N I T I O N */
  8. /* $Id$ */
  9. #include "real.h"
  10. /* Structure to store a string constant
  11. */
  12. struct string {
  13. unsigned s_length; /* length of a string */
  14. char *s_str; /* the string itself */
  15. };
  16. union tk_attr {
  17. struct string *tk_str;
  18. arith tk_int;
  19. struct real *tk_real;
  20. struct {
  21. union {
  22. arith *tky_set;
  23. struct idf *tky_idf;
  24. struct def *tky_def;
  25. } tk_yy;
  26. struct node *tky_next;
  27. } tk_y;
  28. struct {
  29. struct node *tkx_left, *tkx_right;
  30. } tk_x;
  31. };
  32. #define tk_left tk_x.tkx_left
  33. #define tk_right tk_x.tkx_right
  34. #define tk_next tk_y.tky_next
  35. #define tk_idf tk_y.tk_yy.tky_idf
  36. #define tk_def tk_y.tk_yy.tky_def
  37. #define tk_set tk_y.tk_yy.tky_set
  38. /* Token structure. Keep it small, as it is part of a parse-tree node
  39. */
  40. struct token {
  41. short tk_symb; /* token itself */
  42. unsigned short tk_lineno; /* linenumber on which it occurred */
  43. union tk_attr tk_data;
  44. };
  45. typedef struct token t_token;
  46. #define TOK_IDF tk_data.tk_idf
  47. #define TOK_SSTR tk_data.tk_str
  48. #define TOK_STR tk_data.tk_str->s_str
  49. #define TOK_SLE tk_data.tk_str->s_length
  50. #define TOK_INT tk_data.tk_int
  51. #define TOK_REAL tk_data.tk_real
  52. #define TOK_RSTR tk_data.tk_real->r_real
  53. #define TOK_RVAL tk_data.tk_real->r_val
  54. extern t_token dot, aside;
  55. extern struct type *toktype;
  56. #define DOT dot.tk_symb
  57. #define ASIDE aside.tk_symb
  58. extern int token_nmb;
  59. extern int tk_nmb_at_last_syn_err;