System.QueryException: unexpected token: '<EOF>' exception in Salesforce occurs due to Malformed Query String.
If you are dynamically building the query, use System.debug() to print the query.
Generated Debug log to find the query that failed and the exact SOQL. Check whether the SOQL is generated correctly.