parse(Output)--> [Input], {member(Input, [ab, cd]), atom_codes(Input, Output)}.
test(In):- phrase(parse(L), [In]), writeln(L).
?- test(ab). [97,98] true .
?- test(cd). [99,100] true.
?- test(xy). false.
parse(Output)--> [Input], {member(Input, [ab, cd]), atom_codes(Input, Output)}.
test(In):- phrase(parse(L), [In]), writeln(L).
?- test(ab). [97,98] true .
?- test(cd). [99,100] true.
?- test(xy). false.