LLlex.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* 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 */
  2. /* Structure to store a string constant
  3. */
  4. struct string {
  5. arith s_length; /* length of a string */
  6. char *s_str; /* the string itself */
  7. label s_lab; /* data label of string */
  8. };
  9. /* Structure to store a real constant
  10. */
  11. struct real {
  12. char *r_real; /* string representation of real */
  13. struct real *r_inverse; /* the inverse of this real */
  14. label r_lab; /* data label of real */
  15. };
  16. /* Token structure. Keep it small, as it is part of a parse-tree node
  17. */
  18. struct token {
  19. short tk_symb; /* token itself */
  20. unsigned short tk_lineno; /* linenumber on which it occurred */
  21. union {
  22. struct idf *tk_idf; /* IDENT */
  23. struct string *tk_str; /* STRING */
  24. arith tk_int; /* INTEGER */
  25. struct real *tk_real; /* REAL */
  26. struct def *tk_def; /* only used in parse tree node */
  27. arith *tk_set; /* only used in parse tree node */
  28. label tk_lab; /* only used in parse tree node */
  29. } tk_data;
  30. };
  31. #define TOK_IDF tk_data.tk_idf
  32. #define TOK_STR tk_data.tk_str->s_str
  33. #define TOK_SLE tk_data.tk_str->s_length
  34. #define TOK_SLA tk_data.tk_str->s_lab
  35. #define TOK_INT tk_data.tk_int
  36. #define TOK_REL tk_data.tk_real->r_real
  37. #define TOK_RIV tk_data.tk_real->r_inverse
  38. #define TOK_RLA tk_data.tk_real->r_lab
  39. extern struct token dot, aside;
  40. extern struct type *toktype, *asidetype;
  41. extern int tokenseen;
  42. #define ASIDE aside.tk_symb