parser: organize compiled regular expressions

Put them in a dictionary and look them up when you need them. Slower but
no matter right now.
parser: open file for reading only using with statement

Get rid of unused local variables.
parser: get tests to pass