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

Diff of /bison/tests/torture.at

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

revision 1.14 by akim, Mon Apr 22 08:22:11 2002 UTC revision 1.15 by akim, Sun May 5 11:56:37 2002 UTC
# Line 27  AT_BANNER([[Torture Tests.]]) Line 27  AT_BANNER([[Torture Tests.]])
27  # -------------------------------------------  # -------------------------------------------
28  # Create FILE-NAME, containing a self checking parser for a huge  # Create FILE-NAME, containing a self checking parser for a huge
29  # triangular grammar.  # triangular grammar.
 # FIXME: The `10 *' below are there to avoid clashes with predefined  
 # tokens.  These clashes should be exercised, I'm afraid something  
 # is broken wrt previous Bisons.  
30  m4_define([AT_DATA_TRIANGULAR_GRAMMAR],  m4_define([AT_DATA_TRIANGULAR_GRAMMAR],
31  [AT_DATA([[gengram.pl]],  [AT_DATA([[gengram.pl]],
32  [[#! /usr/bin/perl -w  [[#! /usr/bin/perl -w
# Line 144  AT_CLEANUP Line 141  AT_CLEANUP
141  # -------------------------------------------  # -------------------------------------------
142  # Create FILE-NAME, containing a self checking parser for a huge  # Create FILE-NAME, containing a self checking parser for a huge
143  # horizontal grammar.  # horizontal grammar.
 # FIXME: The `10 *' below are there to avoid clashes with predefined  
 # tokens.  These clashes should be exercised, I'm afraid something  
 # is broken wrt previous Bisons.  
144  m4_define([AT_DATA_HORIZONTAL_GRAMMAR],  m4_define([AT_DATA_HORIZONTAL_GRAMMAR],
145  [AT_DATA([[gengram.pl]],  [AT_DATA([[gengram.pl]],
146  [[#! /usr/bin/perl -w  [[#! /usr/bin/perl -w
# Line 237  AT_DATA_HORIZONTAL_GRAMMAR([input.y], [1 Line 231  AT_DATA_HORIZONTAL_GRAMMAR([input.y], [1
231  AT_CHECK([bison input.y -v -o input.c])  AT_CHECK([bison input.y -v -o input.c])
232  AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])  AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])
233  AT_CHECK([./input])  AT_CHECK([./input])
234    
235    AT_CLEANUP
236    
237    
238    
239    # AT_DATA_LOOKAHEADS_GRAMMAR(FILE-NAME, SIZE)
240    # -------------------------------------------
241    # Create FILE-NAME, containing a self checking parser for a grammar
242    # requiring SIZE lookaheads.
243    m4_define([AT_DATA_LOOKAHEADS_GRAMMAR],
244    [AT_DATA([[gengram.pl]],
245    [[#! /usr/bin/perl -w
246    
247    use strict;
248    use Text::Wrap;
249    my $max = $ARGV[0] || 10;
250    
251    print <<EOF;
252    %{
253    #include <stdio.h>
254    #include <stdlib.h>
255    #include <assert.h>
256    
257    #define YYERROR_VERBOSE 1
258    #define YYDEBUG 1
259    
260    static int yylex (void);
261    static void yyerror (const char *msg);
262    %}
263    %union
264    {
265      int val;
266    };
267    
268    %type <val> input exp
269    %token token
270    EOF
271    
272    print
273      wrap ("%type <val> ",
274            "            ",
275            map { "token$_" } (1 .. $max)),
276      "\n";
277    
278    for my $count (1 .. $max)
279      {
280        print "%token \"$count\" $count\n";
281      };
282    
283    print <<EOF;
284    %%
285    input:
286      exp        { assert (\@S|@1 == 1); \$\$ = \@S|@1; }
287    | input exp  { assert (\@S|@2 == \@S|@1 + 1); \$\$ = \@S|@2; }
288    ;
289    
290    exp:
291      token1 "1" { assert (\@S|@1 == 1); }
292    EOF
293    
294    for my $count (2 .. $max)
295      {
296        print "| token$count \"$count\" { assert (\@S|@1 == $count); }\n";
297      };
298    print ";\n";
299    
300    for my $count (1 .. $max)
301      {
302        print "token$count: token { \$\$ = $count; };\n";
303      };
304    
305    print <<EOF;
306    %%
307    static int
308    yylex (void)
309    {
310      static int return_token = 1;
311      static int counter = 1;
312      if (counter > $max)
313        return 0;
314      if (return_token)
315        {
316          return_token = 0;
317          return token;
318        }
319      return_token = 1;
320      return counter++;
321    }
322    
323    static void
324    yyerror (const char *msg)
325    {
326      fprintf (stderr, "%s\\n", msg);
327    }
328    
329    int
330    main (void)
331    {
332      yydebug = !!getenv ("YYDEBUG");
333      return yyparse ();
334    }
335    EOF
336    ]])
337    
338    AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
339    mv stdout $1
340    ])
341    
342    
343    ## ----------------- ##
344    ## Many lookaheads.  ##
345    ## ----------------- ##
346    
347    AT_SETUP([Many lookaheads])
348    
349    AT_DATA_LOOKAHEADS_GRAMMAR([input.y], [1000])
350    AT_CHECK([bison input.y -v -o input.c])
351    AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])
352    AT_CHECK([./input])
353    
354  AT_CLEANUP  AT_CLEANUP
355    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

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