Prevent possible infinite loops when parsing stylesheets

We're not getting any infinite loops, but this should be in there as a precaution anyway
Add an EOF check when converting a string to lexemes

We need this to work with our new flex scanner