LLmessage.c 1.2 KB

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