Next: Data-terms, Previous: DCG-rules, Up: Syntax [Contents]

A DCG-goal is a term of one of the following forms:

`some`

`Vars``DCG-goal`A DCG existential quantification.

`Vars`must be a list of variables.`DCG-goal`must be a valid DCG-goal.Semantics:

transform(V_in, V_out, some Vars DCG_goal) = some Vars transform(V_in, V_out, DCG_goal)

`all`

`Vars``DCG-goal`A DCG universal quantification.

`Vars`must be a list of variables.`DCG-goal`must be a valid DCG-goal.Semantics:

transform(V_in, V_out, all Vars DCG_goal) = all Vars transform(V_in, V_out, DCG_goal)

`DCG-goal1`,`DCG-goal2`A DCG sequence. Intuitively, this means “parse DCG-goal1 and then parse DCG-goal2” or “do DCG-goal1 and then do DCG-goal2”. (Note that the only way this construct actually forces the desired sequencing is by the modes of the implicit DCG arguments.)

`DCG-goal1`and`DCG-goal2`must be valid DCG-goals.Semantics:

transform(V_in, V_out, (DCG-goal1, DCG-goal2)) = (transform(V_in, V_new, DCG_goal1), transform(V_new, V_out, DCG_goal2))

where V_new is a fresh variable.

`DCG-goal1`;`DCG-goal2`A disjunction.

`DCG-goal1`and`DCG-goal2`must be valid goals.`DCG-goal1`must not be of the form ‘`DCG-goal1a -> DCG-goal1b`’. (If it is, then the goal is an if-then-else, not a disjunction.)Semantics:

transform(V_in, V_out, (DCG_goal1 ; DCG_goal2)) = ( transform(V_in, V_out, DCG_goal1) ; transform(V_in, V_out, DCG_goal2) )

`{`

`Goal`}A brace-enclosed ordinary goal.

`Goal`must be a valid goal.Semantics:

transform(V_in, V_out, { Goal }) = (Goal, V_out = V_in)

`[`

`Term`, …]A DCG input match. Unifies the implicit DCG input variable V_in, which must have type ‘

`list(_)`’, with a list whose initial elements are the terms specified and whose tail is the implicit DCG output variable V_out. The terms must be valid data-terms.Semantics:

transform(V_in, V_out, [Term1, …]) = (V_in = [Term, … | V_Out])

`[]`

The null DCG goal (an empty DCG input match). Equivalent to ‘

`{ true }`’.Semantics:

transform(V_in, V_out, []) = (V_out = V_in)

`not`

`DCG-goal``\+`

`DCG-goal`A DCG negation. The two different syntaxes have identical semantics.

`Goal`must be a valid goal.Semantics:

transform(V_in, V_out, not DCG_goal) = (not transform(V_in, V_new, DCG_goal), V_out = V_in)

where V_new is a fresh variable.

`if`

`CondGoal`then`ThenGoal`else`ElseGoal``CondGoal`->`ThenGoal`;`ElseGoal`A DCG if-then-else. The two different syntaxes have identical semantics.

`CondGoal`,`ThenGoal`, and`ElseGoal`must be valid DCG-goals.Semantics:

transform(V_in, V_out, if CondGoal then ThenGoal else ElseGoal) = if transform(V_in, V_cond, CondGoal) then transform(V_cond, V_out, ThenGoal) else transform(V_in, V_out, ElseGoal)

`=(`

`Term`)A DCG unification. Unifies

`Term`with the implicit DCG argument.`Term`must be a valid data-term.Semantics:

transform(V_in, V_out, =(Term)) = (Term = V_in, V_out = V_in)

`:=(`

`Term`)A DCG output unification. Unifies

`Term`with the implicit DCG output argument, ignoring the input DCG argument.`Term`must be a valid data-term.Semantics:

transform(V_in, V_out, :=(Term)) = (V_out = Term)

`Term`=^`field_list`A DCG field selection. Unifies

`Term`with the result of applying the field selection`field_list`to the implicit DCG argument.`Term`must be a valid data-term.`field_list`must be a valid field list. See Record syntax.Semantics:

transform(V_in, V_out, Term =^ field_list) = (Term = V_in ^ field_list, V_out = V_in)

`^`

`field_list`:=`Term`A DCG field update. Replaces a field in the implicit DCG argument.

`Term`must be a valid data-term.`field_list`must be a valid field list. See Record syntax.Semantics:

transform(V_in, V_out, ^ field_list := Term) = (V_out = V_in ^ field_list := Term)

`DCG-call`Any term which does not match any of the above forms must be a DCG predicate call. If the term is a variable

`Var`, it is treated as if it were ‘`call(`’. Then, the two implicit DCG arguments are appended to the specified arguments.`Var`)Semantics:

transform(V_in, V_out, p(A1, …, AN)) = p(A1, …, AN, V_in, V_out)

Next: Data-terms, Previous: DCG-rules, Up: Syntax [Contents]