Improve tokenizeExpression() function, which is used for query completion