Factor char handling from parse.c into stream*