Improved reading

Implemented pseudo-lexer in place of matching lines with regexes. The lexer
first tokenizes input file into atomic tokens and then tries to analyze token
sequences using predefined grammar rules.

This should make adding new features much easier.