diff options
author | David Mitchell <davem@iabyn.com> | 2016-02-10 10:53:03 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-02-11 17:08:58 +0000 |
commit | 5996679157f48f8ada9884c32fd6bcb007f83718 (patch) | |
tree | 614bc903a1c6bf828d01177751d20c7967948a39 /regen_perly.pl | |
parent | 95a1c52083ec4d3ba0727a0362422d8ac6192ba3 (diff) | |
download | perl-5996679157f48f8ada9884c32fd6bcb007f83718.tar.gz |
regen_perly.pl: improve action extracting
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.
Diffstat (limited to 'regen_perly.pl')
-rw-r--r-- | regen_perly.pl | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/regen_perly.pl b/regen_perly.pl index ce69936a43..33cb3b79a2 100644 --- a/regen_perly.pl +++ b/regen_perly.pl @@ -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; |