wrote a parser for patterns