in reply to An adventure with 5.10 regular expressions

Here is a minimal example of infix to postfix translation preserving the correct associativity. For the sake of simplicity I have reduced the grammar to the minus operator:
pl@nereida:~/Lperltesting$ cat calc510withactions.pl #!/usr/local/lib/perl/5.10.1/bin//perl5.10.1 use v5.10; # Infix to postfix translator using 5.10 regexp # original grammar: # exp -> exp '-' digits # | digits # # Applying left-recursion elimination we have: # exp -> digits rest # rest -> '-' rest # | # empty # my @stack; my $regexp = qr{ (?&exp) (?(DEFINE) (?<exp> (?&digits) \s* (?&rest) ) (?<rest> \s* - (?&digits) \s* (?{ push @stack, '-' }) (?&r +est) | # empty ) (?<digits> \s* (\d+) (?{ push @stack, $^N }) ) ) }xms; my $input = <>; chomp($input); if ($input =~ $regexp) { say "matches: $&\nStack=(@stack)"; } else { say "does not match"; }