Your grammar misses the base case of list_w//1, and I can't understand why after upto_comma(W) you require the same thing just read.
I would write this way
list_w([W|Ws]) --> string(W), ",", !, list_w(Ws).
list_w([W]) --> string(W).
string([]) --> [].
string([H|T]) -->[H],string(T).
test:
?- phrase(list_w(S),"cat,dog").
S = [[99, 97, 116], [100, 111, 103]] ;
false.