home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / lr.zip / LR_MESS.INC < prev    next >
Text File  |  1993-05-15  |  6KB  |  106 lines

  1. /*
  2. _________________________________________________________________________
  3. Error/status messages for LR
  4. Serge Kovalyov, March 1993.
  5. _________________________________________________________________________
  6. */
  7.  
  8. #ifndef LR_MESS_INC
  9. #define LR_MESS_INC
  10.  
  11. // Error messages
  12.  
  13. #define lr_error_text(NAME)             lr_error_##NAME##_text
  14.  
  15. // The following macro is used to print message (with line number)
  16.  
  17. #define lr_error_text_and_number(NAME)  lr_error_text(NAME), (*E)->line_number
  18.  
  19. // Status messages
  20.  
  21. #define lr_status_text(NAME)            lr_status_##NAME##_text
  22.  
  23. #define lr_status_set(NAME)             (lr_status = (char *)lr_status_text(NAME))
  24.  
  25. #ifdef LR_MESSAGE_DEFINE      /* Module with messages definitions */
  26.  
  27. // Error messages
  28.  
  29. #define lr_error_define(NAME, text)     const char *lr_error_text(NAME)  = text
  30.  
  31. // Severe errors
  32.  
  33. lr_error_define(required,       "Line %-4d: 0001 %d closing parentheses required in grammar source\n");
  34. lr_error_define(ignored,        "Line %-4d: 0002 closing parenthesis ignored\n");
  35. lr_error_define(quote,          "Line %-4d: 0003 closing quote assumed\n");
  36. lr_error_define(name,           "Global   : 0004 NAME missing\n");
  37. lr_error_define(rules,          "Global   : 0005 RULES missing\n");
  38. lr_error_define(start_symbol,   "Global   : 0006 No start symbol\n");
  39. lr_error_define(start_substr,   "Line %-4d: 0007 Start rule is a substring '%s'\n");
  40. lr_error_define(save,           "Global   : 0008 Unable to save");
  41. lr_error_define(terminal,       "Line %-4d: 0009 Invalid terminal option '%s' for terminal '%s'\n");
  42. lr_error_define(non_terminal,   "Line %-4d: 0010 Invalid non terminal option '%s' for non terminal '%s'\n");
  43. lr_error_define(sec_nt,         "Line %-4d: 0011 Secondary rule '%s(%d)' contains a non terminal\n");
  44. lr_error_define(rc_sec_nt,      "Line %-4d: 0012 Rule '%s(%d)' specifies '%s' as a secondary non terminal, but '%s' contains a non terminal\n");
  45. lr_error_define(lhs,            "Line %-4d: 0013 Undefined non terminal '%s'\n");
  46. lr_error_define(nt_option,      "Line %-4d: 0010 Invalid non terminal option '%s'\n");
  47. lr_error_define(str_str,        "Line %-4d: 0014 String '%s' over string '%s' in rule '%s(%d)'\n");
  48. lr_error_define(substr_str,     "Line %-4d: 0015 Substring '%s' over string '%s' in rule '%s(%d)'\n");
  49. lr_error_define(normal_substr,  "Line %-4d: 0016 Normal '%s' over substring '%s' in rule '%s(%d)'\n");
  50. lr_error_define(reduce,         "Line %-4d: 0017 Reduce '%s(%d)' reduce '%s(%d)' at state %d\n");
  51. lr_error_define(mixed,          "Line %-4d: 0018 Mixed rule '%s(%d)'\n");
  52. lr_error_define(zero_production,"Line %-4d: 0019 Zero production in rule '%s(%d)'\n");
  53. lr_error_define(reuse,          "Line %-4d: 0020 Re-use of non terminal '%s' in rule '%s(%d)'\n");
  54. lr_error_define(non_deter,      "0021 Non-determinism");
  55. lr_error_define(ignore_conflict,"Line %-4d: 0022 'Ignore' in definition of non terminal '%s' in rule '%s(%d)' conflicts with 'No Ignore' in rule '%s(%d)'\n");
  56. lr_error_define(second_conflict,"Line %-4d: 0023 'Secondary' in definition of non terminal '%s' in rule '%s(%d)' conflicts with 'Not Secondary' in rule '%s(%d)'\n");
  57. lr_error_define(final,          "Line %-4d: 0024 Unable to locate next state from state %d on '%s(%d)' in rule '%s(%d)'\n");
  58. lr_error_define(doubled,        "Line %-4d: 0025 Double exit from state %d on non terminal '%s'\n");
  59. lr_error_define(overlap,        "Line %-4d: 0026 Terminal symbol overlap on '%s(%d)' in rule '%s(%d)' which affects state %d\n");
  60. lr_error_define(no_shift_reduce,"Line %-4d: 0027 State %d contains neither shift nor reduce (rule component '%s(%d)')\n");
  61.  
  62. // Informational messages
  63.  
  64. lr_error_define(title,          "Global   : 0101 TITLE missing\n");
  65. lr_error_define(rhs,            "Line %-4d: 0102 Unused non terminal '%s'\n");
  66. lr_error_define(optional,       "Line %-4d: 0103 Undefined optional '%s'\n");
  67. lr_error_define(secondary,      "Line %-4d: 0104 Undefined secondary '%s'\n");
  68. lr_error_define(string,         "Line %-4d: 0105 Undefined string '%s'\n");
  69. lr_error_define(zero,           "Line %-4d: 0106 Undefined zero '%s'\n");
  70. lr_error_define(repeat,         "Line %-4d: 0107 Undefined repeat '%s'\n");
  71. lr_error_define(choice,         "Line %-4d: 0108 Undefined choice '%s'\n");
  72. lr_error_define(ignore,         "Line %-4d: 0109 Undefined ignore '%s'\n");
  73. lr_error_define(dup_rule_name,  "Line %-4d: 0110 Duplicate rule name '%s' within non terminal '%s'\n");
  74. lr_error_define(reduce_shift,   "Line %-4d: 0111 Reduce-shift conflict from state %d, shift text '%s' or reduce by '%s(%d)'\n");
  75.  
  76. // Status messages
  77.  
  78. #define lr_status_define(NAME, text)    const char *lr_status_text(NAME) = text
  79.  
  80. #define lr_status_default       "0200 No grammar is being compiled"
  81.  
  82. lr_status_define(inactive,      lr_status_default);
  83. lr_status_define(start,         "0201 Started");
  84. lr_status_define(void_parse,    "0202 Performing void language parse");
  85. lr_status_define(create_nts,    "0203 Creating non terminals");
  86. lr_status_define(create_rcs,    "0204 Creating rule components");
  87. lr_status_define(process_strs,  "0205 Processing string reductions");
  88. lr_status_define(expand_states, "0206 Expanding states");
  89. lr_status_define(reduce_states, "0207 Reducing states");
  90. lr_status_define(remove_states, "0208 Removing unreachable states and actions");
  91. lr_status_define(save,          "0209 Saving LR parse table");
  92. lr_status_define(print,         "0210 Printing LR parse table");
  93. lr_status_define(finish,        "0211 Finished");
  94. lr_status_define(abort,         "0212 Aborted by user");
  95.  
  96. char *lr_status = lr_status_default;
  97.  
  98. #else
  99. #define lr_error_extern(NAME)   extern const char *lr_error_text(NAME)
  100. #define lr_status_extern(NAME)  extern const char *lr_status_text(NAME)
  101.  
  102. extern       char *lr_status;
  103.  
  104. #endif
  105.  
  106. #endif