Java Parser for regular grammars