Remove a couple of if-else chains in parsing directives, replacing them by a
switch. Committed with Jim's and Chris's approval.