イフコンピュータ > MINERVA > マニュアル > レファレンス > 述語 > 文法規則 > phrase/2

phrase/2

MINERVA
ifcomputer logo
f
Expert Services on the Web

リストの入力記号で文法規則をコールする。

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.

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/grammar_rules/phrase/print_jp.html
published 2012/5/21 update 1997/6/22 (c) 1996-2009 IF Computer Japan
IF Computer 〒113-0022 Tel 03-5814-3352 start (AT) ifcomputer.com
Customer Support 東京都文京区千駄木5-28-2   http://www.ifcomputer.co.jp
戻る> managed with ubiCMS