fork download
  1. #include <errno.h>
  2. #include <inttypes.h>
  3. #include <limits.h>
  4. #include <malloc.h>
  5. #include <stddef.h>
  6. #include <stdint.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <unistd.h>
  11. typedef signed char flex_int8_t;
  12. typedef short int flex_int16_t;
  13. typedef int flex_int32_t;
  14. typedef unsigned char flex_uint8_t;
  15. typedef unsigned short int flex_uint16_t;
  16. typedef unsigned int flex_uint32_t;
  17. typedef struct yy_buffer_state* YY_BUFFER_STATE;
  18. typedef size_t yy_size_t;
  19. extern int yyleng;
  20. extern FILE *yyin, *yyout;
  21. struct yy_buffer_state {
  22. FILE* yy_input_file;
  23. char* yy_ch_buf;
  24. char* yy_buf_pos;
  25. int yy_buf_size;
  26. int yy_n_chars;
  27. int yy_is_our_buffer;
  28. int yy_is_interactive;
  29. int yy_at_bol;
  30. int yy_bs_lineno;
  31. int yy_bs_column;
  32. int yy_fill_buffer;
  33. int yy_buffer_status;
  34. };
  35. static size_t yy_buffer_stack_top = 0;
  36. static size_t yy_buffer_stack_max = 0;
  37. static YY_BUFFER_STATE* yy_buffer_stack = NULL;
  38. static char yy_hold_char;
  39. static int yy_n_chars;
  40. int yyleng;
  41. static char* yy_c_buf_p = NULL;
  42. static int yy_init = 0;
  43. static int yy_start = 0;
  44. static int yy_did_buffer_switch_on_eof;
  45. void yyrestart(FILE* input_file);
  46. void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer);
  47. YY_BUFFER_STATE yy_create_buffer(FILE* file, int size);
  48. void yy_delete_buffer(YY_BUFFER_STATE b);
  49. void yy_flush_buffer(YY_BUFFER_STATE b);
  50. void yypush_buffer_state(YY_BUFFER_STATE new_buffer);
  51. void yypop_buffer_state(void);
  52. static void yyensure_buffer_stack(void);
  53. static void yy_load_buffer_state(void);
  54. static void yy_init_buffer(YY_BUFFER_STATE b, FILE* file);
  55. YY_BUFFER_STATE yy_scan_buffer(char* base, yy_size_t size);
  56. YY_BUFFER_STATE yy_scan_string(const char* yy_str);
  57. YY_BUFFER_STATE yy_scan_bytes(const char* bytes, int len);
  58. void* yyalloc(yy_size_t);
  59. void* yyrealloc(void*, yy_size_t);
  60. void yyfree(void*);
  61. typedef flex_uint8_t YY_CHAR;
  62. FILE *yyin = NULL, *yyout = NULL;
  63. typedef int yy_state_type;
  64. extern int yylineno;
  65. int yylineno = 1;
  66. extern char* yytext;
  67. static yy_state_type yy_get_previous_state(void);
  68. static yy_state_type yy_try_NUL_trans(yy_state_type current_state);
  69. static int yy_get_next_buffer(void);
  70. static void yy_fatal_error(const char* msg);
  71. struct yy_trans_info {
  72. flex_int32_t yy_verify;
  73. flex_int32_t yy_nxt;
  74. };
  75. static const flex_int16_t yy_accept[11] = {0, 0, 0, 6, 5, 4, 1, 2, 5, 3, 0};
  76. static const YY_CHAR yy_ec[256] = {
  77. 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  78. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 1, 1, 1, 5, 1, 1,
  79. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  80. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  81. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  82. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  83. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  84. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  85. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  86. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  87. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  88. static const YY_CHAR yy_meta[7] = {0, 1, 1, 1, 1, 1, 2};
  89. static const flex_int16_t yy_base[12] = {0, 0, 0, 8, 9, 9, 9, 9, 0, 9, 9, 5};
  90. static const flex_int16_t yy_def[12] = {0, 10, 1, 10, 10, 10,
  91. 10, 10, 11, 10, 0, 10};
  92. static const flex_int16_t yy_nxt[16] = {0, 4, 5, 6, 7, 8, 4, 9,
  93. 10, 3, 10, 10, 10, 10, 10, 10};
  94. static const flex_int16_t yy_chk[16] = {0, 1, 1, 1, 1, 1, 1, 11,
  95. 3, 10, 10, 10, 10, 10, 10, 10};
  96. static yy_state_type yy_last_accepting_state;
  97. static char* yy_last_accepting_cpos;
  98. extern int yy_flex_debug;
  99. int yy_flex_debug = 0;
  100. char* yytext;
  101. void yyerror(char*);
  102. extern int yydebug;
  103. enum yytokentype {
  104. YYEMPTY = -2,
  105. YYEOF = 0,
  106. YYerror = 256,
  107. YYUNDEF = 257,
  108. NEWLINE = 258,
  109. ARROW = 259
  110. };
  111. typedef enum yytokentype yytoken_kind_t;
  112. typedef int YYSTYPE;
  113. extern YYSTYPE yylval;
  114. int yyparse(void);
  115. static int yy_init_globals(void);
  116. int yylex_destroy(void);
  117. int yyget_debug(void);
  118. void yyset_debug(int debug_flag);
  119. void* yyget_extra(void);
  120. void yyset_extra(void* user_defined);
  121. FILE* yyget_in(void);
  122. void yyset_in(FILE* _in_str);
  123. FILE* yyget_out(void);
  124. void yyset_out(FILE* _out_str);
  125. int yyget_leng(void);
  126. char* yyget_text(void);
  127. int yyget_lineno(void);
  128. void yyset_lineno(int _line_number);
  129. extern int yywrap(void);
  130. static void yyunput(int c, char* buf_ptr);
  131. static int input(void);
  132. extern int yylex(void);
  133. int yylex(void) {
  134. yy_state_type yy_current_state;
  135. char *yy_cp, *yy_bp;
  136. int yy_act;
  137. if (!(yy_init)) {
  138. (yy_init) = 1;
  139. if (!(yy_start)) (yy_start) = 1;
  140. if (!yyin) yyin = stdin;
  141. if (!yyout) yyout = stdout;
  142. if (!((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)]
  143. : NULL)) {
  144. yyensure_buffer_stack();
  145. (yy_buffer_stack)[(yy_buffer_stack_top)] =
  146. yy_create_buffer(yyin, 16384);
  147. }
  148. yy_load_buffer_state();
  149. }
  150. {
  151. while (1) {
  152. yy_cp = (yy_c_buf_p);
  153. *yy_cp = (yy_hold_char);
  154. yy_bp = yy_cp;
  155. yy_current_state = (yy_start);
  156. yy_match:
  157. do {
  158. YY_CHAR yy_c = yy_ec[((YY_CHAR)(*yy_cp))];
  159. if (yy_accept[yy_current_state]) {
  160. (yy_last_accepting_state) = yy_current_state;
  161. (yy_last_accepting_cpos) = yy_cp;
  162. }
  163. while (yy_chk[yy_base[yy_current_state] + yy_c] !=
  164. yy_current_state) {
  165. yy_current_state = (int)yy_def[yy_current_state];
  166. if (yy_current_state >= 11) yy_c = yy_meta[yy_c];
  167. }
  168. yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  169. ++yy_cp;
  170. } while (yy_base[yy_current_state] != 9);
  171. yy_find_action:
  172. yy_act = yy_accept[yy_current_state];
  173. if (yy_act == 0) {
  174. yy_cp = (yy_last_accepting_cpos);
  175. yy_current_state = (yy_last_accepting_state);
  176. yy_act = yy_accept[yy_current_state];
  177. }
  178. (yytext) = yy_bp;
  179. yyleng = (int)(yy_cp - yy_bp);
  180. (yy_hold_char) = *yy_cp;
  181. *yy_cp = '\0';
  182. (yy_c_buf_p) = yy_cp;
  183. ;
  184. do_action:
  185. switch (yy_act) {
  186. case 0:
  187. *yy_cp = (yy_hold_char);
  188. yy_cp = (yy_last_accepting_cpos);
  189. yy_current_state = (yy_last_accepting_state);
  190. goto yy_find_action;
  191. case 1:
  192. return '(';
  193. break;
  194. case 2:
  195. return ')';
  196. break;
  197. case 3: {
  198. return 259;
  199. } break;
  200. case 4:
  201. return 258;
  202. break;
  203. case 5:
  204. do {
  205. if (fwrite(yytext, (size_t)yyleng, 1, yyout)) {
  206. }
  207. } while (0);
  208. break;
  209. case (6 + 0 + 1):
  210. return 0;
  211. case 6: {
  212. int yy_amount_of_matched_text = (int)(yy_cp - (yytext)) - 1;
  213. *yy_cp = (yy_hold_char);
  214. if ((yy_buffer_stack)[(yy_buffer_stack_top)]
  215. ->yy_buffer_status == 0) {
  216. (yy_n_chars) = (yy_buffer_stack)[(yy_buffer_stack_top)]
  217. ->yy_n_chars;
  218. (yy_buffer_stack)[(yy_buffer_stack_top)]
  219. ->yy_input_file = yyin;
  220. (yy_buffer_stack)[(yy_buffer_stack_top)]
  221. ->yy_buffer_status = 1;
  222. }
  223. if ((yy_c_buf_p) <=
  224. &(yy_buffer_stack)[(yy_buffer_stack_top)]
  225. ->yy_ch_buf[(yy_n_chars)]) {
  226. yy_state_type yy_next_state;
  227. (yy_c_buf_p) = (yytext) + yy_amount_of_matched_text;
  228. yy_current_state = yy_get_previous_state();
  229. yy_next_state = yy_try_NUL_trans(yy_current_state);
  230. yy_bp = (yytext) + 0;
  231. if (yy_next_state) {
  232. yy_cp = ++(yy_c_buf_p);
  233. yy_current_state = yy_next_state;
  234. goto yy_match;
  235. } else {
  236. yy_cp = (yy_c_buf_p);
  237. goto yy_find_action;
  238. }
  239. } else
  240. switch (yy_get_next_buffer()) {
  241. case 1: {
  242. (yy_did_buffer_switch_on_eof) = 0;
  243. if (yywrap()) {
  244. (yy_c_buf_p) = (yytext) + 0;
  245. yy_act = (6 + (((yy_start)-1) / 2) + 1);
  246. goto do_action;
  247. } else {
  248. if (!(yy_did_buffer_switch_on_eof))
  249. yyrestart(yyin);
  250. }
  251. break;
  252. }
  253. case 0:
  254. (yy_c_buf_p) =
  255. (yytext) + yy_amount_of_matched_text;
  256. yy_current_state = yy_get_previous_state();
  257. yy_cp = (yy_c_buf_p);
  258. yy_bp = (yytext) + 0;
  259. goto yy_match;
  260. case 2:
  261. (yy_c_buf_p) =
  262. &(yy_buffer_stack)[(yy_buffer_stack_top)]
  263. ->yy_ch_buf[(yy_n_chars)];
  264. yy_current_state = yy_get_previous_state();
  265. yy_cp = (yy_c_buf_p);
  266. yy_bp = (yytext) + 0;
  267. goto yy_find_action;
  268. }
  269. break;
  270. }
  271. default:
  272. yy_fatal_error(
  273. "fatal flex scanner internal error--no action found");
  274. }
  275. }
  276. }
  277. }
  278. static int yy_get_next_buffer(void) {
  279. char* dest = (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf;
  280. char* source = (yytext);
  281. int number_to_move, i;
  282. int ret_val;
  283. if ((yy_c_buf_p) >
  284. &(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars) + 1])
  285. yy_fatal_error(
  286. "fatal flex scanner internal error--end of buffer missed");
  287. if ((yy_buffer_stack)[(yy_buffer_stack_top)]->yy_fill_buffer == 0) {
  288. if ((yy_c_buf_p) - (yytext)-0 == 1) {
  289. return 1;
  290. } else {
  291. return 2;
  292. }
  293. }
  294. number_to_move = (int)((yy_c_buf_p) - (yytext)-1);
  295. for (i = 0; i < number_to_move; ++i) *(dest++) = *(source++);
  296. if ((yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buffer_status == 2)
  297. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars) = 0;
  298. else {
  299. int num_to_read =
  300. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size -
  301. number_to_move - 1;
  302. while (num_to_read <= 0) {
  303. YY_BUFFER_STATE b = (yy_buffer_stack)[(yy_buffer_stack_top)];
  304. int yy_c_buf_p_offset = (int)((yy_c_buf_p)-b->yy_ch_buf);
  305. if (b->yy_is_our_buffer) {
  306. int new_size = b->yy_buf_size * 2;
  307. if (new_size <= 0)
  308. b->yy_buf_size += b->yy_buf_size / 8;
  309. else
  310. b->yy_buf_size *= 2;
  311. b->yy_ch_buf = (char*)yyrealloc(
  312. (void*)b->yy_ch_buf, (yy_size_t)(b->yy_buf_size + 2));
  313. } else
  314. b->yy_ch_buf = NULL;
  315. if (!b->yy_ch_buf)
  316. yy_fatal_error("fatal error - scanner input buffer overflow");
  317. (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
  318. num_to_read =
  319. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size -
  320. number_to_move - 1;
  321. }
  322. if (num_to_read > 8192) num_to_read = 8192;
  323. if ((yy_buffer_stack)[(yy_buffer_stack_top)]->yy_is_interactive) {
  324. int c = '*';
  325. int n;
  326. for (n = 0; n < num_to_read && (c = getc(yyin)) != EOF && c != '\n';
  327. ++n)
  328. (&(yy_buffer_stack)[(yy_buffer_stack_top)]
  329. ->yy_ch_buf[number_to_move])[n] = (char)c;
  330. if (c == '\n')
  331. (&(yy_buffer_stack)[(yy_buffer_stack_top)]
  332. ->yy_ch_buf[number_to_move])[n++] = (char)c;
  333. if (c == EOF && ferror(yyin))
  334. yy_fatal_error("input in flex scanner failed");
  335. (yy_n_chars) = n;
  336. } else {
  337. errno = 0;
  338. while (((yy_n_chars) =
  339. (int)fread((&(yy_buffer_stack)[(yy_buffer_stack_top)]
  340. ->yy_ch_buf[number_to_move]),
  341. 1, (yy_size_t)num_to_read, yyin)) == 0 &&
  342. ferror(yyin)) {
  343. if (errno != EINTR) {
  344. yy_fatal_error("input in flex scanner failed");
  345. break;
  346. }
  347. errno = 0;
  348. clearerr(yyin);
  349. }
  350. };
  351. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars);
  352. }
  353. if ((yy_n_chars) == 0) {
  354. if (number_to_move == 0) {
  355. ret_val = 1;
  356. yyrestart(yyin);
  357. } else {
  358. ret_val = 2;
  359. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buffer_status = 2;
  360. }
  361. } else
  362. ret_val = 0;
  363. if (((yy_n_chars) + number_to_move) >
  364. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size) {
  365. int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
  366. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf = (char*)yyrealloc(
  367. (void*)(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf,
  368. (yy_size_t)new_size);
  369. if (!(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf)
  370. yy_fatal_error("out of dynamic memory in yy_get_next_buffer()");
  371. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size =
  372. (int)(new_size - 2);
  373. }
  374. (yy_n_chars) += number_to_move;
  375. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars)] = 0;
  376. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars) + 1] = 0;
  377. (yytext) = &(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[0];
  378. return ret_val;
  379. }
  380. static yy_state_type yy_get_previous_state(void) {
  381. yy_state_type yy_current_state;
  382. char* yy_cp;
  383. yy_current_state = (yy_start);
  384. for (yy_cp = (yytext) + 0; yy_cp < (yy_c_buf_p); ++yy_cp) {
  385. YY_CHAR yy_c = (*yy_cp ? yy_ec[((YY_CHAR)(*yy_cp))] : 1);
  386. if (yy_accept[yy_current_state]) {
  387. (yy_last_accepting_state) = yy_current_state;
  388. (yy_last_accepting_cpos) = yy_cp;
  389. }
  390. while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
  391. yy_current_state = (int)yy_def[yy_current_state];
  392. if (yy_current_state >= 11) yy_c = yy_meta[yy_c];
  393. }
  394. yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  395. }
  396. return yy_current_state;
  397. }
  398. static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state) {
  399. int yy_is_jam;
  400. char* yy_cp = (yy_c_buf_p);
  401. YY_CHAR yy_c = 1;
  402. if (yy_accept[yy_current_state]) {
  403. (yy_last_accepting_state) = yy_current_state;
  404. (yy_last_accepting_cpos) = yy_cp;
  405. }
  406. while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) {
  407. yy_current_state = (int)yy_def[yy_current_state];
  408. if (yy_current_state >= 11) yy_c = yy_meta[yy_c];
  409. }
  410. yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  411. yy_is_jam = (yy_current_state == 10);
  412. return yy_is_jam ? 0 : yy_current_state;
  413. }
  414. static void yyunput(int c, char* yy_bp) {
  415. char* yy_cp;
  416. yy_cp = (yy_c_buf_p);
  417. *yy_cp = (yy_hold_char);
  418. if (yy_cp < (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf + 2) {
  419. int number_to_move = (yy_n_chars) + 2;
  420. char* dest =
  421. &(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf
  422. [(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size + 2];
  423. char* source = &(yy_buffer_stack)[(yy_buffer_stack_top)]
  424. ->yy_ch_buf[number_to_move];
  425. while (source > (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf)
  426. *--dest = *--source;
  427. yy_cp += (int)(dest - source);
  428. yy_bp += (int)(dest - source);
  429. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars) =
  430. (int)(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_size;
  431. if (yy_cp < (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf + 2)
  432. yy_fatal_error("flex scanner push-back overflow");
  433. }
  434. *--yy_cp = (char)c;
  435. (yytext) = yy_bp;
  436. (yy_hold_char) = *yy_cp;
  437. (yy_c_buf_p) = yy_cp;
  438. }
  439. static int input(void) {
  440. int c;
  441. *(yy_c_buf_p) = (yy_hold_char);
  442. if (*(yy_c_buf_p) == 0) {
  443. if ((yy_c_buf_p) <
  444. &(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[(yy_n_chars)])
  445. *(yy_c_buf_p) = '\0';
  446. else {
  447. int offset = (int)((yy_c_buf_p) - (yytext));
  448. ++(yy_c_buf_p);
  449. switch (yy_get_next_buffer()) {
  450. case 2:
  451. yyrestart(yyin);
  452. case 1: {
  453. if (yywrap()) return 0;
  454. if (!(yy_did_buffer_switch_on_eof)) yyrestart(yyin);
  455. return input();
  456. }
  457. case 0:
  458. (yy_c_buf_p) = (yytext) + offset;
  459. break;
  460. }
  461. }
  462. }
  463. c = *(unsigned char*)(yy_c_buf_p);
  464. *(yy_c_buf_p) = '\0';
  465. (yy_hold_char) = *++(yy_c_buf_p);
  466. return c;
  467. }
  468. void yyrestart(FILE* input_file) {
  469. if (!((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)]
  470. : NULL)) {
  471. yyensure_buffer_stack();
  472. (yy_buffer_stack)[(yy_buffer_stack_top)] =
  473. yy_create_buffer(yyin, 16384);
  474. }
  475. yy_init_buffer(
  476. ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL),
  477. input_file);
  478. yy_load_buffer_state();
  479. }
  480. void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer) {
  481. yyensure_buffer_stack();
  482. if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL) ==
  483. new_buffer)
  484. return;
  485. if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
  486. *(yy_c_buf_p) = (yy_hold_char);
  487. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_pos = (yy_c_buf_p);
  488. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars);
  489. }
  490. (yy_buffer_stack)[(yy_buffer_stack_top)] = new_buffer;
  491. yy_load_buffer_state();
  492. (yy_did_buffer_switch_on_eof) = 1;
  493. }
  494. static void yy_load_buffer_state(void) {
  495. (yy_n_chars) = (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars;
  496. (yytext) = (yy_c_buf_p) =
  497. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_pos;
  498. yyin = (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_input_file;
  499. (yy_hold_char) = *(yy_c_buf_p);
  500. }
  501. YY_BUFFER_STATE yy_create_buffer(FILE* file, int size) {
  502. YY_BUFFER_STATE b;
  503. b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state));
  504. if (!b) yy_fatal_error("out of dynamic memory in yy_create_buffer()");
  505. b->yy_buf_size = size;
  506. b->yy_ch_buf = (char*)yyalloc((yy_size_t)(b->yy_buf_size + 2));
  507. if (!b->yy_ch_buf)
  508. yy_fatal_error("out of dynamic memory in yy_create_buffer()");
  509. b->yy_is_our_buffer = 1;
  510. yy_init_buffer(b, file);
  511. return b;
  512. }
  513. void yy_delete_buffer(YY_BUFFER_STATE b) {
  514. if (!b) return;
  515. if (b ==
  516. ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
  517. (yy_buffer_stack)[(yy_buffer_stack_top)] = (YY_BUFFER_STATE)0;
  518. if (b->yy_is_our_buffer) yyfree((void*)b->yy_ch_buf);
  519. yyfree((void*)b);
  520. }
  521. static void yy_init_buffer(YY_BUFFER_STATE b, FILE* file) {
  522. int oerrno = errno;
  523. yy_flush_buffer(b);
  524. b->yy_input_file = file;
  525. b->yy_fill_buffer = 1;
  526. if (b !=
  527. ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
  528. b->yy_bs_lineno = 1;
  529. b->yy_bs_column = 0;
  530. }
  531. b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0;
  532. errno = oerrno;
  533. }
  534. void yy_flush_buffer(YY_BUFFER_STATE b) {
  535. if (!b) return;
  536. b->yy_n_chars = 0;
  537. b->yy_ch_buf[0] = 0;
  538. b->yy_ch_buf[1] = 0;
  539. b->yy_buf_pos = &b->yy_ch_buf[0];
  540. b->yy_at_bol = 1;
  541. b->yy_buffer_status = 0;
  542. if (b ==
  543. ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
  544. yy_load_buffer_state();
  545. }
  546. void yypush_buffer_state(YY_BUFFER_STATE new_buffer) {
  547. if (new_buffer == NULL) return;
  548. yyensure_buffer_stack();
  549. if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
  550. *(yy_c_buf_p) = (yy_hold_char);
  551. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_buf_pos = (yy_c_buf_p);
  552. (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_n_chars = (yy_n_chars);
  553. }
  554. if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
  555. (yy_buffer_stack_top)++;
  556. (yy_buffer_stack)[(yy_buffer_stack_top)] = new_buffer;
  557. yy_load_buffer_state();
  558. (yy_did_buffer_switch_on_eof) = 1;
  559. }
  560. void yypop_buffer_state(void) {
  561. if (!((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL))
  562. return;
  563. yy_delete_buffer(
  564. ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL));
  565. (yy_buffer_stack)[(yy_buffer_stack_top)] = NULL;
  566. if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top);
  567. if (((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
  568. yy_load_buffer_state();
  569. (yy_did_buffer_switch_on_eof) = 1;
  570. }
  571. }
  572. static void yyensure_buffer_stack(void) {
  573. yy_size_t num_to_alloc;
  574. if (!(yy_buffer_stack)) {
  575. num_to_alloc = 1;
  576. (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc(
  577. num_to_alloc * sizeof(struct yy_buffer_state*));
  578. if (!(yy_buffer_stack))
  579. yy_fatal_error("out of dynamic memory in yyensure_buffer_stack()");
  580. memset((yy_buffer_stack), 0,
  581. num_to_alloc * sizeof(struct yy_buffer_state*));
  582. (yy_buffer_stack_max) = num_to_alloc;
  583. (yy_buffer_stack_top) = 0;
  584. return;
  585. }
  586. if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1) {
  587. yy_size_t grow_size = 8;
  588. num_to_alloc = (yy_buffer_stack_max) + grow_size;
  589. (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc(
  590. (yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*));
  591. if (!(yy_buffer_stack))
  592. yy_fatal_error("out of dynamic memory in yyensure_buffer_stack()");
  593. memset((yy_buffer_stack) + (yy_buffer_stack_max), 0,
  594. grow_size * sizeof(struct yy_buffer_state*));
  595. (yy_buffer_stack_max) = num_to_alloc;
  596. }
  597. }
  598. YY_BUFFER_STATE yy_scan_buffer(char* base, yy_size_t size) {
  599. YY_BUFFER_STATE b;
  600. if (size < 2 || base[size - 2] != 0 || base[size - 1] != 0) return NULL;
  601. b = (YY_BUFFER_STATE)yyalloc(sizeof(struct yy_buffer_state));
  602. if (!b) yy_fatal_error("out of dynamic memory in yy_scan_buffer()");
  603. b->yy_buf_size = (int)(size - 2);
  604. b->yy_buf_pos = b->yy_ch_buf = base;
  605. b->yy_is_our_buffer = 0;
  606. b->yy_input_file = NULL;
  607. b->yy_n_chars = b->yy_buf_size;
  608. b->yy_is_interactive = 0;
  609. b->yy_at_bol = 1;
  610. b->yy_fill_buffer = 0;
  611. b->yy_buffer_status = 0;
  612. yy_switch_to_buffer(b);
  613. return b;
  614. }
  615. YY_BUFFER_STATE yy_scan_string(const char* yystr) {
  616. return yy_scan_bytes(yystr, (int)strlen(yystr));
  617. }
  618. YY_BUFFER_STATE yy_scan_bytes(const char* yybytes, int _yybytes_len) {
  619. YY_BUFFER_STATE b;
  620. char* buf;
  621. yy_size_t n;
  622. int i;
  623. n = (yy_size_t)(_yybytes_len + 2);
  624. buf = (char*)yyalloc(n);
  625. if (!buf) yy_fatal_error("out of dynamic memory in yy_scan_bytes()");
  626. for (i = 0; i < _yybytes_len; ++i) buf[i] = yybytes[i];
  627. buf[_yybytes_len] = buf[_yybytes_len + 1] = 0;
  628. b = yy_scan_buffer(buf, n);
  629. if (!b) yy_fatal_error("bad buffer in yy_scan_bytes()");
  630. b->yy_is_our_buffer = 1;
  631. return b;
  632. }
  633. static void yy_fatal_error(const char* msg) {
  634. fprintf(stderr, "%s\n", msg);
  635. exit(2);
  636. }
  637. int yyget_lineno(void) {
  638. return yylineno;
  639. }
  640. FILE* yyget_in(void) {
  641. return yyin;
  642. }
  643. FILE* yyget_out(void) {
  644. return yyout;
  645. }
  646. int yyget_leng(void) {
  647. return yyleng;
  648. }
  649. char* yyget_text(void) {
  650. return yytext;
  651. }
  652. void yyset_lineno(int _line_number) {
  653. yylineno = _line_number;
  654. }
  655. void yyset_in(FILE* _in_str) {
  656. yyin = _in_str;
  657. }
  658. void yyset_out(FILE* _out_str) {
  659. yyout = _out_str;
  660. }
  661. int yyget_debug(void) {
  662. return yy_flex_debug;
  663. }
  664. void yyset_debug(int _bdebug) {
  665. yy_flex_debug = _bdebug;
  666. }
  667. static int yy_init_globals(void) {
  668. (yy_buffer_stack) = NULL;
  669. (yy_buffer_stack_top) = 0;
  670. (yy_buffer_stack_max) = 0;
  671. (yy_c_buf_p) = NULL;
  672. (yy_init) = 0;
  673. (yy_start) = 0;
  674. yyin = NULL;
  675. yyout = NULL;
  676. return 0;
  677. }
  678. int yylex_destroy(void) {
  679. while (
  680. ((yy_buffer_stack) ? (yy_buffer_stack)[(yy_buffer_stack_top)] : NULL)) {
  681. yy_delete_buffer(((yy_buffer_stack)
  682. ? (yy_buffer_stack)[(yy_buffer_stack_top)]
  683. : NULL));
  684. (yy_buffer_stack)[(yy_buffer_stack_top)] = NULL;
  685. yypop_buffer_state();
  686. }
  687. yyfree((yy_buffer_stack));
  688. (yy_buffer_stack) = NULL;
  689. yy_init_globals();
  690. return 0;
  691. }
  692. void* yyalloc(yy_size_t size) {
  693. return malloc(size);
  694. }
  695. void* yyrealloc(void* ptr, yy_size_t size) {
  696. return realloc(ptr, size);
  697. }
  698. void yyfree(void* ptr) {
  699. free((char*)ptr);
  700. }
  701. int yywrap(void) {
  702. return 1;
  703. }
  704. int yylex(void);
  705. void yyerror(char*);
  706. int MAX(int a, int b) {
  707. if (a < b) return b;
  708. return a;
  709. }
  710. enum yysymbol_kind_t {
  711. YYSYMBOL_YYEMPTY = -2,
  712. YYSYMBOL_YYEOF = 0,
  713. YYSYMBOL_YYerror = 1,
  714. YYSYMBOL_YYUNDEF = 2,
  715. YYSYMBOL_NEWLINE = 3,
  716. YYSYMBOL_ARROW = 4,
  717. YYSYMBOL_5_ = 5,
  718. YYSYMBOL_6_ = 6,
  719. YYSYMBOL_YYACCEPT = 7,
  720. YYSYMBOL_program = 8,
  721. YYSYMBOL_expr = 9
  722. };
  723. typedef enum yysymbol_kind_t yysymbol_kind_t;
  724. typedef signed char yytype_int8;
  725. typedef short yytype_int16;
  726. typedef unsigned char yytype_uint8;
  727. typedef unsigned short yytype_uint16;
  728. typedef yytype_int8 yy_state_t;
  729. typedef int yy_state_fast_t;
  730. union yyalloc {
  731. yy_state_t yyss_alloc;
  732. YYSTYPE yyvs_alloc;
  733. };
  734. static const yytype_int8 yytranslate[] = {
  735. 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  736. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 6, 2, 2, 2, 2, 2, 2,
  737. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  738. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  739. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  740. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  741. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  742. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  743. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  744. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  745. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4};
  746. static const yytype_int8 yyrline[] = {0, 16, 16, 21, 25, 29};
  747. static const char* yysymbol_name(yysymbol_kind_t yysymbol);
  748. static const char* const yytname[] = {"\"end of file\"",
  749. "error",
  750. "\"invalid token\"",
  751. "NEWLINE",
  752. "ARROW",
  753. "'('",
  754. "')'",
  755. "$accept",
  756. "program",
  757. "expr",
  758. ((void*)0)};
  759. static const char* yysymbol_name(yysymbol_kind_t yysymbol) {
  760. return yytname[yysymbol];
  761. }
  762. static const yytype_int8 yypact[] = {6, 0, 2, 5, -4, -3, -4, -4, 6, -4, 8};
  763. static const yytype_int8 yydefact[] = {0, 0, 0, 0, 3, 0, 1, 2, 0, 4, 5};
  764. static const yytype_int8 yypgoto[] = {-4, -4, -1};
  765. static const yytype_int8 yydefgoto[] = {0, 2, 3};
  766. static const yytype_int8 yytable[] = {5, 8, 6, 9, 0, 1, 4, 10, 7, 8, 0, 1, 8};
  767. static const yytype_int8 yycheck[] = {1, 4, 0, 6, -1, 5, 6, 8, 3, 4, -1, 5, 4};
  768. static const yytype_int8 yystos[] = {0, 5, 8, 9, 6, 9, 0, 3, 4, 6, 9};
  769. static const yytype_int8 yyr1[] = {0, 7, 8, 9, 9, 9};
  770. static const yytype_int8 yyr2[] = {0, 2, 2, 2, 3, 3};
  771. enum { YYENOMEM = -2 };
  772. static void yy_symbol_value_print(FILE* yyo, yysymbol_kind_t yykind,
  773. YYSTYPE const* const yyvaluep) {
  774. FILE* yyoutput = yyo;
  775. ((void)(yyoutput));
  776. if (!yyvaluep) return;
  777. ((void)(yykind));
  778. }
  779. static void yy_symbol_print(FILE* yyo, yysymbol_kind_t yykind,
  780. YYSTYPE const* const yyvaluep) {
  781. fprintf(yyo, "%s %s (", yykind < 7 ? "token" : "nterm",
  782. yysymbol_name(yykind));
  783. yy_symbol_value_print(yyo, yykind, yyvaluep);
  784. fprintf(yyo, ")");
  785. }
  786. static void yy_stack_print(yy_state_t* yybottom, yy_state_t* yytop) {
  787. fprintf(stderr, "Stack now");
  788. for (; yybottom <= yytop; yybottom++) {
  789. int yybot = *yybottom;
  790. fprintf(stderr, " %d", yybot);
  791. }
  792. fprintf(stderr, "\n");
  793. }
  794. static void yy_reduce_print(yy_state_t* yyssp, YYSTYPE* yyvsp, int yyrule) {
  795. int yylno = yyrline[yyrule];
  796. int yynrhs = yyr2[yyrule];
  797. int yyi;
  798. fprintf(stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1,
  799. yylno);
  800. for (yyi = 0; yyi < yynrhs; yyi++) {
  801. fprintf(stderr, " $%d = ", yyi + 1);
  802. yy_symbol_print(stderr,
  803. ((yysymbol_kind_t)(yystos[+yyssp[yyi + 1 - yynrhs]])),
  804. &yyvsp[(yyi + 1) - (yynrhs)]);
  805. fprintf(stderr, "\n");
  806. }
  807. }
  808. int yydebug;
  809. static void yydestruct(const char* yymsg, yysymbol_kind_t yykind,
  810. YYSTYPE* yyvaluep) {
  811. ((void)(yyvaluep));
  812. if (!yymsg) yymsg = "Deleting";
  813. do {
  814. if (yydebug) {
  815. fprintf(stderr, "%s ", yymsg);
  816. yy_symbol_print(stderr, yykind, yyvaluep);
  817. fprintf(stderr, "\n");
  818. }
  819. } while (0);
  820. ((void)(yykind));
  821. }
  822. int yychar;
  823. YYSTYPE yylval;
  824. int yynerrs;
  825. int yyparse(void) {
  826. yy_state_fast_t yystate = 0;
  827. int yyerrstatus = 0;
  828. long yystacksize = 200;
  829. yy_state_t yyssa[200];
  830. yy_state_t* yyss = yyssa;
  831. yy_state_t* yyssp = yyss;
  832. YYSTYPE yyvsa[200];
  833. YYSTYPE* yyvs = yyvsa;
  834. YYSTYPE* yyvsp = yyvs;
  835. int yyn;
  836. int yyresult;
  837. yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
  838. YYSTYPE yyval;
  839. int yylen = 0;
  840. do {
  841. if (yydebug) fprintf(stderr, "Starting parse\n");
  842. } while (0);
  843. yychar = -2;
  844. goto yysetstate;
  845. yynewstate:
  846. yyssp++;
  847. yysetstate:
  848. do {
  849. if (yydebug) fprintf(stderr, "Entering state %d\n", yystate);
  850. } while (0);
  851. ((void)(0 && (0 <= yystate && yystate < 11)));
  852. *yyssp = ((yy_state_t)(yystate));
  853. do {
  854. if (yydebug) yy_stack_print((yyss), (yyssp));
  855. } while (0);
  856. if (yyss + yystacksize - 1 <= yyssp) {
  857. long yysize = yyssp - yyss + 1;
  858. if (10000 <= yystacksize) goto yyexhaustedlab;
  859. yystacksize *= 2;
  860. if (10000 < yystacksize) yystacksize = 10000;
  861. {
  862. yy_state_t* yyss1 = yyss;
  863. union yyalloc* yyptr = ((union yyalloc*)(malloc(
  864. ((unsigned)(((yystacksize) * (((long)(sizeof(yy_state_t))) +
  865. ((long)(sizeof(YYSTYPE)))) +
  866. (((long)(sizeof(union yyalloc))) - 1)))))));
  867. if (!yyptr) goto yyexhaustedlab;
  868. do {
  869. long yynewbytes;
  870. do {
  871. long yyi;
  872. for (yyi = 0; yyi < (yysize); yyi++)
  873. (&yyptr->yyss_alloc)[yyi] = (yyss)[yyi];
  874. } while (0);
  875. yyss = &yyptr->yyss_alloc;
  876. yynewbytes = yystacksize * ((long)(sizeof(*yyss))) +
  877. (((long)(sizeof(union yyalloc))) - 1);
  878. yyptr += yynewbytes / ((long)(sizeof(*yyptr)));
  879. } while (0);
  880. do {
  881. long yynewbytes;
  882. do {
  883. long yyi;
  884. for (yyi = 0; yyi < (yysize); yyi++)
  885. (&yyptr->yyvs_alloc)[yyi] = (yyvs)[yyi];
  886. } while (0);
  887. yyvs = &yyptr->yyvs_alloc;
  888. yynewbytes = yystacksize * ((long)(sizeof(*yyvs))) +
  889. (((long)(sizeof(union yyalloc))) - 1);
  890. yyptr += yynewbytes / ((long)(sizeof(*yyptr)));
  891. } while (0);
  892. if (yyss1 != yyssa) free(yyss1);
  893. }
  894. yyssp = yyss + yysize - 1;
  895. yyvsp = yyvs + yysize - 1;
  896. do {
  897. if (yydebug)
  898. fprintf(stderr, "Stack size increased to %ld\n",
  899. ((long)(yystacksize)));
  900. } while (0);
  901. if (yyss + yystacksize - 1 <= yyssp) goto yyabortlab;
  902. }
  903. if (yystate == 6) goto yyacceptlab;
  904. goto yybackup;
  905. yybackup:
  906. yyn = yypact[yystate];
  907. if (((yyn) == (-4))) goto yydefault;
  908. if (yychar == -2) {
  909. do {
  910. if (yydebug) fprintf(stderr, "Reading a token\n");
  911. } while (0);
  912. yychar = yylex();
  913. }
  914. if (yychar <= 0) {
  915. yychar = 0;
  916. yytoken = YYSYMBOL_YYEOF;
  917. do {
  918. if (yydebug) fprintf(stderr, "Now at end of input.\n");
  919. } while (0);
  920. } else if (yychar == 256) {
  921. yychar = 257;
  922. yytoken = YYSYMBOL_YYerror;
  923. goto yyerrlab1;
  924. } else {
  925. yytoken = (0 <= (yychar) && (yychar) <= 259
  926. ? ((yysymbol_kind_t)(yytranslate[yychar]))
  927. : YYSYMBOL_YYUNDEF);
  928. do {
  929. if (yydebug) {
  930. fprintf(stderr, "%s ", "Next token is");
  931. yy_symbol_print(stderr, yytoken, &yylval);
  932. fprintf(stderr, "\n");
  933. }
  934. } while (0);
  935. }
  936. yyn += yytoken;
  937. if (yyn < 0 || 12 < yyn || yycheck[yyn] != yytoken) goto yydefault;
  938. yyn = yytable[yyn];
  939. if (yyn <= 0) {
  940. if (0) goto yyerrlab;
  941. yyn = -yyn;
  942. goto yyreduce;
  943. }
  944. if (yyerrstatus) yyerrstatus--;
  945. do {
  946. if (yydebug) {
  947. fprintf(stderr, "%s ", "Shifting");
  948. yy_symbol_print(stderr, yytoken, &yylval);
  949. fprintf(stderr, "\n");
  950. }
  951. } while (0);
  952. yystate = yyn;
  953. *++yyvsp = yylval;
  954. yychar = -2;
  955. goto yynewstate;
  956. yydefault:
  957. yyn = yydefact[yystate];
  958. if (yyn == 0) goto yyerrlab;
  959. goto yyreduce;
  960. yyreduce:
  961. yylen = yyr2[yyn];
  962. yyval = yyvsp[1 - yylen];
  963. do {
  964. if (yydebug) yy_reduce_print(yyssp, yyvsp, yyn);
  965. } while (0);
  966. switch (yyn) {
  967. case 2: {
  968. return yyval;
  969. } break;
  970. case 3: {
  971. yyval = 0;
  972. } break;
  973. case 4: {
  974. yyval = yyvsp[-1];
  975. } break;
  976. case 5: {
  977. yyval = MAX(yyvsp[-2] + 1, yyvsp[0]);
  978. } break;
  979. default:
  980. break;
  981. }
  982. do {
  983. if (yydebug) {
  984. fprintf(stderr, "%s ", "-> $$ =");
  985. yy_symbol_print(stderr, ((yysymbol_kind_t)(yyr1[yyn])), &yyval);
  986. fprintf(stderr, "\n");
  987. }
  988. } while (0);
  989. (yyvsp -= (yylen), yyssp -= (yylen));
  990. yylen = 0;
  991. *++yyvsp = yyval;
  992. {
  993. const int yylhs = yyr1[yyn] - 7;
  994. const int yyi = yypgoto[yylhs] + *yyssp;
  995. yystate = (0 <= yyi && yyi <= 12 && yycheck[yyi] == *yyssp
  996. ? yytable[yyi]
  997. : yydefgoto[yylhs]);
  998. }
  999. goto yynewstate;
  1000. yyerrlab:
  1001. yytoken = yychar == -2 ? YYSYMBOL_YYEMPTY
  1002. : (0 <= (yychar) && (yychar) <= 259
  1003. ? ((yysymbol_kind_t)(yytranslate[yychar]))
  1004. : YYSYMBOL_YYUNDEF);
  1005. if (!yyerrstatus) {
  1006. ++yynerrs;
  1007. yyerror("syntax error");
  1008. }
  1009. if (yyerrstatus == 3) {
  1010. if (yychar <= 0) {
  1011. if (yychar == 0) goto yyabortlab;
  1012. } else {
  1013. yydestruct("Error: discarding", yytoken, &yylval);
  1014. yychar = -2;
  1015. }
  1016. }
  1017. goto yyerrlab1;
  1018. yyerrorlab:
  1019. if (0) goto yyerrorlab;
  1020. ++yynerrs;
  1021. (yyvsp -= (yylen), yyssp -= (yylen));
  1022. yylen = 0;
  1023. do {
  1024. if (yydebug) yy_stack_print((yyss), (yyssp));
  1025. } while (0);
  1026. yystate = *yyssp;
  1027. goto yyerrlab1;
  1028. yyerrlab1:
  1029. yyerrstatus = 3;
  1030. for (;;) {
  1031. yyn = yypact[yystate];
  1032. if (!((yyn) == (-4))) {
  1033. yyn += YYSYMBOL_YYerror;
  1034. if (0 <= yyn && yyn <= 12 && yycheck[yyn] == YYSYMBOL_YYerror) {
  1035. yyn = yytable[yyn];
  1036. if (0 < yyn) break;
  1037. }
  1038. }
  1039. if (yyssp == yyss) goto yyabortlab;
  1040. yydestruct("Error: popping", ((yysymbol_kind_t)(yystos[yystate])),
  1041. yyvsp);
  1042. (yyvsp -= (1), yyssp -= (1));
  1043. yystate = *yyssp;
  1044. do {
  1045. if (yydebug) yy_stack_print((yyss), (yyssp));
  1046. } while (0);
  1047. }
  1048. *++yyvsp = yylval;
  1049. do {
  1050. if (yydebug) {
  1051. fprintf(stderr, "%s ", "Shifting");
  1052. yy_symbol_print(stderr, ((yysymbol_kind_t)(yystos[yyn])), yyvsp);
  1053. fprintf(stderr, "\n");
  1054. }
  1055. } while (0);
  1056. yystate = yyn;
  1057. goto yynewstate;
  1058. yyacceptlab:
  1059. yyresult = 0;
  1060. goto yyreturnlab;
  1061. yyabortlab:
  1062. yyresult = 1;
  1063. goto yyreturnlab;
  1064. yyexhaustedlab:
  1065. yyerror("memory exhausted");
  1066. yyresult = 2;
  1067. goto yyreturnlab;
  1068. yyreturnlab:
  1069. if (yychar != -2) {
  1070. yytoken = (0 <= (yychar) && (yychar) <= 259
  1071. ? ((yysymbol_kind_t)(yytranslate[yychar]))
  1072. : YYSYMBOL_YYUNDEF);
  1073. yydestruct("Cleanup: discarding lookahead", yytoken, &yylval);
  1074. }
  1075. (yyvsp -= (yylen), yyssp -= (yylen));
  1076. do {
  1077. if (yydebug) yy_stack_print((yyss), (yyssp));
  1078. } while (0);
  1079. while (yyssp != yyss) {
  1080. yydestruct("Cleanup: popping", ((yysymbol_kind_t)(yystos[+*yyssp])),
  1081. yyvsp);
  1082. (yyvsp -= (1), yyssp -= (1));
  1083. }
  1084. if (yyss != yyssa) free(yyss);
  1085. return yyresult;
  1086. }
  1087. void yyerror(char* s) {
  1088. fprintf(stderr, "%s\n", s);
  1089. }
  1090. int main(void) {
  1091. printf("%d\n", yyparse());
  1092. return 0;
  1093. }
Success #stdin #stdout #stderr 0s 5424KB
stdin
Standard input is empty
stdout
1
stderr
syntax error