This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regen_perly.pl: improve action extracting
authorDavid Mitchell <davem@iabyn.com>
Wed, 10 Feb 2016 10:53:03 +0000 (10:53 +0000)
committerDavid Mitchell <davem@iabyn.com>
Thu, 11 Feb 2016 17:08:58 +0000 (17:08 +0000)
The regex was sometimes missing final cases from the big
action switch.

This simplifies the regex, but assumes that 'default: break;' is the last
case.  This is the case in bison 2.7 and 3.0.2.

regen_perly.pl

index ce69936..33cb3b7 100644 (file)
@@ -187,6 +187,8 @@ foreach ($act_fh, $tab_fh, $h_fh) {
 exit 0;
 
 
+# extract the tables and actions from the generated .c file
+
 sub extract {
     my $clines = shift;
     my $tablines;
@@ -207,23 +209,12 @@ sub extract {
     $tablines = $&;
 
 
+    # extract all the cases in the big action switch statement
+
     $clines =~ m@
-       switch \s* \( \s* \w+ \s* \) \s* { \s*
-       (
-           case \s* \d+ \s* :
-           \s*
-           (?: \s* /\* .*? \*/ \s* )*  # optional C-comments
-           \s*
-           \#line [^\n]+"\Q$y_file\E"
-           .*?
-       )
-       }
-       \s*
-       (?: \s* /\* .*? \*/ \s* )*      # optional C-comments
-       \s*
-       (
-           YY_SYMBOL_PRINT
-       )
+       switch \s* \( \s* yyn \s* \) \s* { \s*
+            ( .*?  default: \s* break; \s* )
+        }
     @xms
        or die "Can't extract actions from $tmpc_file\n";
     $actlines = $1;