| リストの入力記号で文法規則をコールする。
phrase(+項, +リスト)
phrase/2 は、リストにリストされた入力記号で文法規則 項 をコールする。
引数
項 項
リスト 記号のリスト
例
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]).
成功して、"result = 4"を出す。
標準
この述語は、ISO-Prolog 標準には含まれない。
関連
expand_term/2.
|