Pretty much the same way you're doing it now, I would suspect -- but instead of stopping at one particular character, you stop at "whatever doesn't make sense". So when you're trying to read a number (for instance), 'y' doesn't make sense, so you're done. When you're trying to read a variable name, '=' doesn't make sense. Etc.