The reason converting by hand is faster than a parser is that you already have a parser written, and you can find it in the back of your head
which is a
smart place to keep it. It is by no means difficult to write a parser, eg with lex and yacc (JFlex and CUP are more modern counterparts) or ANTLR or similar, if the grammar is context-free. You will find lex, flex, JFlex etc, use regular expressions frequently to identify numbers, keywords, etc.