LLmessage.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /* $Id$ */
  6. /* PARSER ERROR ADMINISTRATION */
  7. #include <alloc.h>
  8. #include "idf.h"
  9. #include "arith.h"
  10. #include "LLlex.h"
  11. #include "Lpars.h"
  12. char *symbol2str(int tok);
  13. void insert_token(int tk);
  14. void LLmessage(tk)
  15. {
  16. err_occurred = 1;
  17. if (tk < 0) {
  18. error("end of file expected");
  19. }
  20. else if (tk) {
  21. #ifndef LLNONCORR
  22. error("%s missing before %s", symbol2str(tk), symbol2str(DOT));
  23. #endif
  24. insert_token(tk);
  25. }
  26. else {
  27. #ifndef LLNONCORR
  28. error("%s deleted", symbol2str(DOT));
  29. #else
  30. error("%s not expected", symbol2str(DOT));
  31. #endif
  32. }
  33. tk_nmb_at_last_syn_err = token_nmb;
  34. }
  35. void insert_token(int tk)
  36. {
  37. aside = dot;
  38. DOT = tk;
  39. switch (tk) {
  40. /* The operands need some body */
  41. case IDENTIFIER:
  42. dot.tk_idf = gen_idf();
  43. break;
  44. case TYPE_IDENTIFIER:
  45. dot.tk_idf = str2idf("int", 0);
  46. break;
  47. case STRING:
  48. dot.tk_bts = Salloc("", 1);
  49. dot.tk_len = 1;
  50. break;
  51. case INTEGER:
  52. dot.tk_fund = INT;
  53. dot.tk_ival = 1;
  54. break;
  55. case FLOATING:
  56. dot.tk_fval = Salloc("0.0", 4);
  57. break;
  58. }
  59. }