Tags Perl
I'm starting to really get a hang of this P::RD thing. As they say, nothing replaces experience. Indeed !

Here's a gotcha to be wary of:

One of my rules is command_w_arg (for all commands that have arguments, that is all of MIXAL commands, bar HLT and NOP).

In this rule, I'm trying to match all shift instructions:

/S[LR](A|X|AX|C)/
This rule, however, fails to parse "SLAX". How come ? The answer is simple - the regex matches SLA, and X is a leftover - the alternation is non-greedy ! It sounds simple now, but it took be 20 minutes to grok why this doesn't work.

I wonder whether there's a greedy-alternation regex, or should I just order the alternated strings longest-first (this is what I'm now doing).