Bug 1022859 - Factorize parser into a class

https://bugzilla.mozilla.org/show_bug.cgi?id=1022859