bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04-fyi-user-tok-num.patch


From: Akim Demaille
Subject: 04-fyi-user-tok-num.patch
Date: Mon, 08 Apr 2002 13:44:53 +0200

Index: NEWS
--- NEWS Sun, 07 Apr 2002 21:22:52 +0200 akim
+++ NEWS Sun, 07 Apr 2002 22:06:28 +0200 akim
@@ -4,7 +4,8 @@
 Changes in version 1.49a:
 
 * Large grammars
-  Are now supported.
+  Are now supported (large token numbers, large grammar size (= sum of
+  the LHS and RHS lengths).
 
 * The initial rule is explicit.
   Bison used to play hacks with the initial rule, which the user does
Index: src/symtab.h
--- src/symtab.h Sat, 06 Apr 2002 22:14:47 +0200 akim
+++ src/symtab.h Sun, 07 Apr 2002 21:41:22 +0200 akim
@@ -53,7 +53,7 @@
   short number;
   short prec;
   associativity assoc;
-  short user_token_number;
+  int user_token_number;
 
   /* Points to the other in the identifier-symbol pair for an
      alias. Special value SALIAS in the identifier half of the
Index: tests/torture.at
--- tests/torture.at Sun, 07 Apr 2002 21:22:52 +0200 akim
+++ tests/torture.at Sun, 07 Apr 2002 22:04:52 +0200 akim
@@ -140,6 +140,108 @@ exp:
 
 
 
+# AT_DATA_HORIZONTAL_GRAMMAR(FILE-NAME, SIZE)
+# -------------------------------------------
+# Create FILE-NAME, containing a self checking parser for a huge
+# 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.
+m4_define([AT_DATA_HORIZONTAL_GRAMMAR],
+[AT_DATA([[gengram.pl]],
+[[#! /usr/bin/perl -w
+
+use strict;
+my $max = $ARGV[0] || 10;
+
+print <<EOF;
+%{
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#define YYERROR_VERBOSE 1
+#define YYDEBUG 1
+
+static int yylex (void);
+static void yyerror (const char *msg);
+%}
+EOF
+
+for my $size (1 .. $max)
+  {
+    print "%token \"$size\" ", $size * 10, "\n";
+  };
+
+print <<EOF;
+%%
+EOF
+
+use Text::Wrap;
+print
+  wrap ("exp: ", "  ",
+       (map { "\"$_\"" } (1 .. $max)), ";"),
+  "\n";
+
+print <<EOF;
+%%
+static int
+yylex (void)
+{
+  static int counter = 1;
+  if (counter > $max)
+    return 0;
+  else
+  return counter++ * 10;
+}
+
+static void
+yyerror (const char *msg)
+{
+  fprintf (stderr, "%s\\n", msg);
+}
+
+int
+main (void)
+{
+  yydebug = !!getenv ("YYDEBUG");
+  return yyparse ();
+}
+EOF
+]])
+
+AT_CHECK([perl -w ./gengram.pl $2 || exit 77], 0, [stdout])
+mv stdout $1
+])
+
+
+## ---------------- ##
+## Big horizontal.  ##
+## ---------------- ##
+
+AT_SETUP([Big horizontal])
+
+# I have been able to go up to 10000 on my machine, but I had to
+# increase the maximum stack size (* 100).  It gave:
+#
+# input.y      263k
+# input.tab.c  1.3M
+# input        453k
+#
+# gengram.pl 10000                 0.70s user 0.01s sys  99% cpu    0.711 total
+# bison input.y                  730.56s user 0.53s sys  99% cpu 12:12.34 total
+# gcc -Wall input.tab.c -o input   5.81s user 0.20s sys 100% cpu     6.01 total
+# ./input                          0.00s user 0.01s sys 108% cpu     0.01 total
+#
+AT_DATA_HORIZONTAL_GRAMMAR([input.y], [1000])
+AT_CHECK([bison input.y -v -o input.c])
+AT_CHECK([$CC $CFLAGS $CPPFLAGS input.c -o input], 0, [], [ignore])
+AT_CHECK([./input])
+
+AT_CLEANUP
+
+
+
 # AT_DATA_STACK_TORTURE(C-PROLOGUE)
 # ---------------------------------
 # A parser specialized in torturing the stack size.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]