implemented stateful low-level parser

This is a more invasive commit but the behavior of the parser should be clearer.
We cannot get stuck anymore while reading garbage. every read $ will correctly reset the parser.
I did a gcov run which shows 100% coverage of the parser using the parse/main.c example.