You cannot put a space between a method name and the parenthesis used to invoke it. If you do, the parenthesis are no longer part of the function invocation, they're for order-of-operations on the arguments to the function.
Consider a few examples of valid and invalid syntax:
x() is a valid invocation with no arguments
x () is an invalid invocation of x with one argument: (). Because () is not a valid expression, this is a syntax error.
x (name: "bob") or x (->3 * 3), 4 are both valid invocations, because the (...) is a valid expression
x(a, b) is again a valid invocation of x with two arguments
x (a, b) is an invalid invocation of x with one argument: (a, b). Again, (a, b) is not itself a valid expression, so this is a syntax error.
In your case, you're trying to invoke .factory with one argument: ("transformService", x), which is not a valid expression.
What you've written is essentially this:
a = ("transformSerice", x) # invalid syntax
factory(a)