1 # Checking Push Parsing. -*- Autotest -*-
2 # Copyright (C) 2007 Free Software Foundation, Inc.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([[Push Parsing Tests]])
19 ## ---------------------------------------------- ##
20 ## Push Parsing: Memory Leak for Early Deletion. ##
21 ## ---------------------------------------------- ##
23 AT_SETUP([[Push Parsing: Memory Leak for Early Deletion]])
27 AT_DATA_GRAMMAR([[input.y]],
33 void yyerror (char const *msg);
36 %define api.pure %define api.push_pull "push"
45 yyerror (char const *msg)
47 fprintf (stderr, "%s\n", msg);
55 /* Make sure we don't try to free ps->yyss in this case. */
59 /* yypstate_delete used to leak ps->yyss if the stack was reallocated but the
60 parse did not return on success, syntax error, or memory exhaustion. */
62 assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
66 assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE);
67 assert (yypush_parse (ps, 'b', NULL) == YYPUSH_MORE);
74 AT_CHECK([[bison -o input.c input.y]])
76 AT_PARSER_CHECK([[./input]])
80 ## ----------------------------------------- ##
81 ## Push Parsing: Multiple impure instances. ##
82 ## ----------------------------------------- ##
84 AT_SETUP([[Push Parsing: Multiple impure instances]])
86 AT_DATA_GRAMMAR([[input.y]],
91 void yyerror (char const *msg);
95 %define api.push_pull "both"
104 yyerror (char const *msg)
106 fprintf (stderr, "%s\n", msg);
121 for (i = 0; i < 2; ++i)
123 ps = yypstate_new ();
125 assert (yypstate_new () == NULL);
126 assert (yyparse () == 2);
128 assert (yypush_parse (ps) == 0);
129 assert (yypstate_new () == NULL);
130 assert (yyparse () == 2);
131 yypstate_delete (ps);
138 AT_CHECK([[bison -o input.c input.y]])
139 AT_COMPILE([[input]])
140 AT_PARSER_CHECK([[./input]], 0, [],
141 [[cannot allocate multiple impure push-parser instances
142 cannot allocate multiple impure push-parser instances
143 cannot allocate multiple impure push-parser instances
144 cannot allocate multiple impure push-parser instances
145 cannot allocate multiple impure push-parser instances
146 cannot allocate multiple impure push-parser instances
147 cannot allocate multiple impure push-parser instances
148 cannot allocate multiple impure push-parser instances
153 ## ------------------------------------- ##
154 ## Push Parsing: Unsupported Skeletons. ##
155 ## ------------------------------------- ##
157 AT_SETUP([[Push Parsing: Unsupported Skeletons]])
161 %define api.push_pull "push"
166 AT_CHECK([[bison input.y]], [0], [],
167 [[input.y:2.9-21: warning: %define variable `api.push_pull' is not used