/[bison]/bison/tests/reduce.at
ViewVC logotype

Diff of /bison/tests/reduce.at

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by akim, Fri Nov 30 11:15:02 2001 UTC revision 1.7 by akim, Sun Apr 7 17:36:38 2002 UTC
# Line 174  AT_CLEANUP Line 174  AT_CLEANUP
174    
175    
176  ## ------------------- ##  ## ------------------- ##
177    ## Reduced Automaton.  ##
178    ## ------------------- ##
179    
180    # Check that the automaton is that as the for the grammar reduced by
181    # hand.
182    
183    AT_SETUP([Reduced Automaton])
184    
185    # The non reduced grammar.
186    # ------------------------
187    AT_DATA([[not-reduced.y]],
188    [[/* A useless token. */
189    %token useless_token
190    /* A useful one. */
191    %token useful
192    %verbose
193    %output="not-reduced.c"
194    
195    %%
196    
197    exp: useful            { /* A useful action. */ }
198       | non_productive    { /* A non productive action. */ }
199       ;
200    
201    not_reachable: useful  { /* A not reachable action. */ }
202                 ;
203    
204    non_productive: non_productive useless_token
205                           { /* Another non productive action. */ }
206                  ;
207    ]])
208    
209    AT_CHECK([[bison not-reduced.y]], 0, [],
210    [[not-reduced.y contains 2 useless nonterminals and 3 useless rules
211    ]])
212    
213    AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0,
214    [[Useless nonterminals:
215       not_reachable
216       non_productive
217    Terminals which are not used:
218       useless_token
219    Useless rules:
220    #2     exp: non_productive;
221    #3     not_reachable: useful;
222    #4     non_productive: non_productive useless_token;
223    ]])
224    
225    # The reduced grammar.
226    # --------------------
227    AT_DATA([[reduced.y]],
228    [[/* A useless token. */
229    %token useless_token
230    /* A useful one. */
231    %token useful
232    %verbose
233    %output="reduced.c"
234    
235    %%
236    
237    exp: useful            { /* A useful action. */ }
238    //   | non_productive    { /* A non productive action. */ } */
239       ;
240    
241    //not_reachable: useful  { /* A not reachable action. */ }
242    //             ;
243    
244    //non_productive: non_productive useless_token
245    //                       { /* Another non productive action. */ }
246    //              ;
247    ]])
248    
249    AT_CHECK([[bison reduced.y]])
250    
251    # Comparing the parsers.
252    cp reduced.c expout
253    AT_CHECK([sed 's/not-reduced/reduced/g' not-reduced.c], 0, [expout])
254    
255    AT_CLEANUP
256    
257    
258    
259    ## ------------------- ##
260  ## Underivable Rules.  ##  ## Underivable Rules.  ##
261  ## ------------------- ##  ## ------------------- ##
262    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26