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.
Sample SOQL with the exception:
String strSOQL = 'SELECT Id, Company FROMLead';
System.debug(
Database.query(
strSOQL
)
);
In the above SOQL, there should space between FROM and Lead.