11.3.148 phrase/[2,3]

Synopsis

phrase(+PhraseType, +List)

phrase(+PhraseType, +List, -Rest)

Used in conjunction with a grammar to parse or generate strings.

Arguments

:PhraseType
callable, must be nonvar

Name of a phrase type.

List
list of term

A list of symbols — tokens or codes.

Rest
list of term

A tail of List; what remains of List after PhraseType has been found. Defaults to [].

Description

This predicate is a convenient way to start execution of grammar rules. Runs through the grammar rules checking whether there is a path by which PhraseType can be rewritten as List.

If List is bound, this goal corresponds to using the grammar for parsing. If List is unbound, this goal corresponds to using the grammar for generation.

phrase/[2,3] succeeds when the portion of List between the start of List and the start of Rest is a phrase of type PhraseType (according to the current grammar rules), where PhraseType is either a non-terminal or, more generally, a grammar rule body.

phrase/[2,3] allows variables to occur as non-terminals in grammar rule bodies, just as call/1 allows variables to occur as goals in clause bodies.

Backtracking

Depends on PhraseType.

Exceptions

Call errors (see ref-sem-exc).

See Also

ref-lod-exp, ref-gru.


Send feedback on this subject.