You can use the GetFieldsFromExpression method to get the field names from an expression. I am not aware of a way to get the variable names, however if I was doing something like this I would use the CreateSessionObject with the following parameters:
and then use GetLayout on the resulting session object to get a list of all the variables in your app which could then be used with some sort of regex function to figure out which variables are being used in the expression.