calls a grammar rule with the inputsymbols of a list.
phrase/2 calls a grammar rule Term with the inputsymbols listed in List.
Term term List list of symbols
polish(Stack, Result) -->
[X], {integer(X)}, polish([X|Stack], Result).
polish([Y,X|Stack], Result) -->
[(+)], {Z is X+Y}, polish([Z|Stack], Result).
polish([Y,X|Stack], Result) -->
[(-)], {Z is X-Y}, polish([Z|Stack], Result).
polish([Z], Z) -->
[].
main(X) :-
phrase(polish([], Result), [2,3,(+),1,(-)]),
println(['result = ', Result]).
Succeeds and prints "result = 4".
This predicate is not part of the ISO-Prolog Standard.