I was going through this example on DCG
integer(I) -->
digit(D0),
digits(D),
{ number_codes(I, [D0|D])
}.
digits([D|T]) -->
digit(D), !,
digits(T).
digits([]) -->
[].
digit(D) -->
[D],
{ code_type(D, digit)
}.
But this example parses an integer only if it's in the beginning of the string (because digit(D0) fails is D0 is not a number code). How do I go about parsing an integer anywhere in the string, e.g. "abc123def"?