mess.y 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /* mess.y - test bison error handling */
  2. /* these are the warning messages generated in bison
  3. getargs.c: warns("extra argument ignored: %s", program_name);
  4. lex.c: warn ("unexpected `/' found and ignored");
  5. lex.c: warn ("unescaped newline in constant");
  6. lex.c: warns("more than three octal digits: `\\%o'", code);
  7. lex.c: warns("hexadecimal value above 255: `\\x%x'", code);
  8. lex.c: warns("unknown escape sequence `\\%c'", c);
  9. lex.c: warns("unknown escape sequence: `\\' followed by char code 0x%x", c);
  10. lex.c: warn ("use \"...\" for multicharacter literal tokens");
  11. lex.c: warn ("unterminated type name");
  12. */
  13. /* in subroutine skip_to_char */
  14. /* reader.c: warn (" Skipping to next \\n"); */
  15. /* reader.c: warns(" Skipping to next %c", target); */
  16. /* declarations section */
  17. /* read_declarations */
  18. /* reader.c: warns("unrecognized: %s", token_buffer); */
  19. /* reader.c: warns("unknown character: %c (\\%03o)", c); */
  20. /* copy definition %{ ... %} */
  21. /* reader.c: warn ("unterminated string"); */
  22. /* parse_token_declaration */
  23. /* reader.c: warns("symbol %s redefined", symval->tag); */
  24. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  25. /* reader.c: warns("'%s' is invalid in %s", */
  26. /* parse_thong_declaration */
  27. /* reader.c: warns("unrecognized item %s, expected an identifier", */
  28. /* reader.c: warns("expected string constant instead of %s", */
  29. /* parse_start_decl */
  30. /* reader.c: warn ("multiple %%start declarations"); */
  31. /* reader.c: warn ("invalid %%start declaration"); */
  32. /* parse_type_decl */
  33. /* reader.c: warn ("%%type declaration has no <typename>"); */
  34. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  35. /* reader.c: warns("invalid %%type declaration due to item: %s", token_buffer); */
  36. /* parse_assoc_decl */
  37. /* reader.c: warns("redefining precedence of %s", symval->tag); */
  38. /* reader.c: warns("symbol %s redefined", symval->tag); */
  39. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  40. /* reader.c: warns("invalid text (%s). Number should be after identifier.", */
  41. /* reader.c: warns("unexpected item: %s", token_buffer); */
  42. /* parse_union_decl */
  43. /* reader.c: warn ("multiple %%union declarations"); */
  44. /* reader.c: warn ("unmatched close-brace (`}')"); */
  45. /* parse_expect_decl */
  46. /* reader.c: warn ("funny integer after %%expect"); */
  47. /* rules section */
  48. /* get_type_name */
  49. /* reader.c: warn ("invalid $ value"); n < 0 */
  50. /* reader.c: warn ("invalid $ value"); n > # items */
  51. /* copy_guard */
  52. /* reader.c: warn ("unmatched right brace ('}')"); */
  53. /* reader.c: warn ("unterminated string"); */
  54. /* reader.c: warns("$$ of '%s' has no declared type.", rule->sym->tag); */
  55. /* reader.c: warns("$%d of '%s' has no declared type.", n, rule->sym->tag); */
  56. /* reader.c: warns("$%c is invalid", c); */
  57. /* reader.c: warns("@%c is invalid", c); */
  58. /* copy_action */
  59. /* reader.c: warn ("unterminated string"); */
  60. /* reader.c: warns("$$ of '%s' has no declared type.", rule->sym->tag); */
  61. /* reader.c: warns("$%d of '%s' has no declared type.", n, rule->sym->tag); */
  62. /* reader.c: warns("$%c is invalid",c); */
  63. /* reader.c: warn ("invalid @-construct"); */
  64. /* readgram */
  65. /* reader.c: warn ("ill-formed rule: initial symbol not followed by colon"); */
  66. /* reader.c: warn ("grammar starts with vertical bar"); */
  67. /* reader.c: warns("rule given for %s, which is a token", lhs->tag); */
  68. /* reader.c: warn ("two actions at end of one rule"); */
  69. /* reader.c: warns("type clash ('%s' '%s') on default action", */
  70. /* reader.c: warn ("empty rule for typed nonterminal, and no action"); */
  71. /* reader.c: warns("invalid input: %s", token_buffer); */
  72. /* reader.c: warns("symbol %s is used, but is not defined as a token and has no rules", */
  73. /* get_type */
  74. /* reader.c: warn ("ill-formed %%type declaration"); */
  75. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  76. /* packsymbols */
  77. /* reader.c: warns("conflicting precedences for %s and %s", */
  78. /* reader.c: warns("conflicting assoc values for %s and %s", */
  79. /* reader.c: warns("tokens %s and %s both assigned number %d", */
  80. /* lex.c: warn ("unexpected `/' found and ignored"); */
  81. /
  82. /* lex.c: warn ("unescaped newline in constant"); */
  83. %token a "...
  84. /* lex.c: warns("octal value outside range 0...255: `\\%o'", code); */
  85. %token b "\3333"
  86. /* lex.c: warns("hexadecimal value above 255: `\\x%x'", code); */
  87. %token c "\x1Fa"
  88. /* lex.c: warns("unknown escape sequence `\\%c'", c); */
  89. %token d "\q"
  90. /* lex.c: warns("unknown escape sequence: `\\' followed by char code 0x%x", c); */
  91. %token e "\"
  92. /* lex.c: warn ("use \"...\" for multicharacter literal tokens"); */
  93. %token f 'ab'
  94. /* lex.c: warn ("unterminated type name"); */
  95. %token <unterminated g
  96. %token
  97. /* in subroutine skip_to_char */
  98. /* reader.c: warn (" Skipping to next \\n"); */
  99. /* never used */
  100. /* reader.c: warns(" Skipping to next %c", target); */
  101. /* appears many places below; target is always '%' */
  102. /* declarations section */
  103. %union {int u1; long u2; double u3;}
  104. /* read_declarations */
  105. /* reader.c: warns("unrecognized: %s", token_buffer); */
  106. %garbage
  107. /* reader.c: warns("unknown character: %c (\\%03o)", c); */
  108. %start foo $
  109. /* copy definition %{ ... %} */
  110. /* reader.c: warn ("unterminated string"); */
  111. %{ "...
  112. %}
  113. /* parse_token_declaration */
  114. %token <u1> bog sog tog
  115. %token <u2> gog
  116. /* reader.c: warns("symbol %s redefined", symval->tag); */
  117. %nterm <u1> bog rog
  118. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  119. %token <u2> bog
  120. /* reader.c: warns("'%s' is invalid in %s", */
  121. %token <u1> ;
  122. /* parse_thong_declaration */
  123. /* reader.c: warns("unrecognized item %s, expected an identifier", */
  124. %thong 3
  125. /* reader.c: warns("expected string constant instead of %s", */
  126. %thong lesseq 4
  127. %thong geq 5 ">="
  128. /* parse_start_decl */
  129. /* reader.c: warn ("multiple %%start declarations"); */
  130. %start fog
  131. /* reader.c: warn ("invalid %%start declaration"); */
  132. %start 3
  133. /* parse_type_decl */
  134. /* reader.c: warn ("%%type declaration has no <typename>"); */
  135. %type fog
  136. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  137. %type <u1> gog
  138. /* reader.c: warns("invalid %%type declaration due to item: %s", token_buffer); */
  139. %type <u1> fog :
  140. /* parse_assoc_decl */
  141. %left '-' 3
  142. /* reader.c: warns("redefining precedence of %s", symval->tag); */
  143. %right '-'
  144. /* reader.c: warns("symbol %s redefined", symval->tag); */
  145. %right rog
  146. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  147. %left <u1> gog 3
  148. /* reader.c: warns("invalid text (%s). Number should be after identifier.", */
  149. %left 8 '+'
  150. /* reader.c: warns("unexpected item: %s", token_buffer); */
  151. %nonassoc '<' 1 { '>'
  152. /* parse_union_decl */
  153. /* reader.c: warn ("multiple %%union declarations"); */
  154. /* reader.c: warn ("unmatched close-brace (`}')"); */
  155. %union }{int u1; long u2;}
  156. /* parse_expect_decl */
  157. /* reader.c: warn ("funny integer after %%expect"); */
  158. %expect 000000000000000023%thong confprec "<<"
  159. %left confprec
  160. %right "<<"
  161. %thong confassoc "=="
  162. %left confassoc
  163. %nonassoc "=="
  164. %semantic_parser
  165. %%
  166. /* rules section */
  167. /* readgram */
  168. /* reader.c: warn ("grammar starts with vertical bar"); */
  169. | ;
  170. /* reader.c: warn ("ill-formed rule: initial symbol not followed by colon"); */
  171. rr 3
  172. /* reader.c: warns("rule given for %s, which is a token", lhs->tag); */
  173. confprec : /* empty */ ;
  174. /* reader.c: warn ("two actions at end of one rule"); */
  175. /* this message cannot occur */
  176. twoact : '.' {$$=NULL;} {$$=NULL;} ;
  177. /* reader.c: warns("type clash ('%s' '%s') on default action", */
  178. gog : fog;
  179. /* reader.c: warn ("empty rule for typed nonterminal, and no action"); */
  180. gog : /* empty */ ;
  181. /* reader.c: warns("invalid input: %s", token_buffer); */
  182. {
  183. /* reader.c: warns("symbol %s is used, but is not defined as a token and has no rules", */
  184. /* fog */
  185. /* get_type_name */
  186. /* reader.c: warn ("invalid $ value"); n < 0 */
  187. r1 : rog {$-1 = NULL;}
  188. /* reader.c: warn ("invalid $ value"); n > # items */
  189. tog {$3 = NULL;} ;
  190. /* copy_guard */
  191. r1 : '.'
  192. /* reader.c: warn ("unmatched right brace ('}')"); */
  193. %guard } ;
  194. /* reader.c: warn ("unterminated string"); */
  195. r1 : ',' %guard { "...
  196. } ;
  197. /* reader.c: warns("$$ of '%s' has no declared type.", rule->sym->tag); */
  198. r1 : ';' %guard { int i; i = $$;
  199. /* reader.c: warns("$%d of '%s' has no declared type.", n, rule->sym->tag); */
  200. i = $1;
  201. /* reader.c: warns("$%c is invalid", c); */
  202. i = $2;
  203. /* reader.c: warns("@%c is invalid", c); */
  204. @x; } ;
  205. /* copy_action {*/
  206. /* reader.c: warn ("unterminated string"); */
  207. r1 : 'a' { "...
  208. } ;
  209. /* reader.c: warns("$$ of '%s' has no declared type.", rule->sym->tag); */
  210. r1 : 'b' {$$ = 3;};
  211. /* reader.c: warns("$%d of '%s' has no declared type.", n, rule->sym->tag); */
  212. r1 : 'c' {$1 = 3;};
  213. /* reader.c: warns("$%c is invalid",c); */
  214. r1 : 'd' {$x = 4;};
  215. /* reader.c: warn ("invalid @-construct"); */
  216. r1 : 'e' {@x;};
  217. /* get_type */
  218. /* this function is unused */
  219. /* reader.c: warn ("ill-formed %%type declaration"); */
  220. /* reader.c: warns("type redeclaration for %s", symval->tag); */
  221. /* packsymbols */
  222. /* reader.c: warns("conflicting precedences for %s and %s", */
  223. /* %thong confprec "<<"
  224. %left confprec
  225. %right "<<" */
  226. /* reader.c: warns("conflicting assoc values for %s and %s", */
  227. /* %thong confassoc "=="
  228. %left confassoc
  229. %nonassoc "==" */
  230. /* reader.c: warns("tokens %s and %s both assigned number %d", */
  231. /* gog and '-' are both 3 */