converting to a stream-based parser/lexer

Signed-off-by: Daniel Fagnan <dnfagnan@gmail.com>