LLlex.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. int r_sign; /* positive or negative */
  16. };
  17. /* Token structure. Keep it small, as it is part of a parse-tree node
  18. */
  19. struct token {
  20. short tk_symb; /* token itself */
  21. unsigned short tk_lineno; /* linenumber on which it occurred */
  22. union {
  23. struct idf *tk_idf; /* IDENT */
  24. struct string *tk_str; /* STRING */
  25. arith tk_int; /* INTEGER */
  26. struct real *tk_real; /* REAL */
  27. struct def *tk_def; /* only used in parse tree node */
  28. arith *tk_set; /* only used in parse tree node */
  29. label tk_lab; /* only used in parse tree node */
  30. } tk_data;
  31. };
  32. #define TOK_IDF tk_data.tk_idf
  33. #define TOK_STR tk_data.tk_str->s_str
  34. #define TOK_SLE tk_data.tk_str->s_length
  35. #define TOK_SLA tk_data.tk_str->s_lab
  36. #define TOK_INT tk_data.tk_int
  37. #define TOK_REL tk_data.tk_real->r_real
  38. #define TOK_RIV tk_data.tk_real->r_inverse
  39. #define TOK_RLA tk_data.tk_real->r_lab
  40. #define TOK_RSI tk_data.tk_real->r_sign
  41. extern struct token dot, aside;
  42. extern struct type *toktype, *asidetype;
  43. #define ASIDE aside.tk_symb