swipldcgtut
swipldcgtut copied to clipboard
Need to explain first argument of phrase/2 better
Two other remarks regarding phrase/2: You write: To execute a grammar rule, we use Prolog's built-in phrase/2 predicate. The first argument is a DCG body. phrase(Body, Ls) is true iff Body describes the list Ls.
BUT that first argument is the HEAD of the/a “top" rule of a DCG, isn’t it? (It can be the head of a lower rule too of course, if you want to test/find substructures of a DCG.)
Maybe it’s clearer to replace "iff Body describes” with "iff (sub)DCG describes”?