/*
 * bLN^[
 * 	{CCUvO V1.0
 *			2010 (C) Copyright H.Niwa
 *
 */

? <include list>;
? <include generator>;
? <include ktaiso>;

// u
<Replace () ()>;
<Replace ((Ȃ :#a1):#b2) (( :#a1):#b1)>	<Replace #b2 #b1>;
<Replace ((Ȃ :#a1):#b2) ((킽 :#a1):#b1)><Replace #b2 #b1>;
<Replace ((Ȃ :#a1):#b2) (( :#a1):#b1)><Replace #b2 #b1>;
<Replace ((Ȃ :#a1):#b2) (( :#a1):#b1)>	<Replace #b2 #b1>;
<Replace ((Ȃ :#a1):#b2) (( :#a1):#b1)>	<Replace #b2 #b1>;
<Replace ((Ȃ :#a1):#b2) ((I :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((Ȃ :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((Ai^ :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((܂ :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((I}G :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((O :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) (( :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((LT} :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((M :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (( :#a1):#b2) ((M :#a1):#b1)>	<Replace #b2 #b1>;
<Replace (#f : #b2) (#f : #b1)>			<Replace #b2 #b1>;


// C
<Eliza>
	<print "ɂ́ACCUłB">
	<print "bĂ܂񂩁H">
	<print>
	{ 
		<printf "> ">
		::sys <getline #x 
			::sys <strdelcntl #x1 #x> 
			::sys <split #x2 #x1 "BH?">
			[<noteq #x2 ()> <print>]
			<foreach (#x3 #x2)
			    ::sys <syntax #x3
				(
				  ::ktaiso < #a #b>
				  <Replace #a2 #a>
				  <is #n (#a2 #b)>
				|
				  <is #n (#x2)>
				)
				::list <flatten #list #n>
				<c #list2 #list>
				::list <flatten #list3 (#list2)>
				::sys <concat #s #list3>
				<print "#" #s>
			    >
			>
			[<noteq #x2 ()> <print>]
		>
	};


// select one at random
<comb #r #l>
	::generator <permutation #r1 #l 1>
	::sys <car #r #r1>
	;

// data operation
<d #o #list>
	<comb #o #list>
	;

// Keyword and conversation data	
<c #o (#h _ :#l)>
	(<is #h ")"> | <is #h "]"> | <is #h "j"> | <is #h "z">
		| <is #h "}"> | <is #h "l"> | <is #h "p"> 
		| <is #h "v"> | <is #h "x">)
	<c #o #l>
	;
<c #o (#h :#l)>
	(<is #h ɂ> | <is #h 񂿂> | <is #h ɂ> 
		| <is #h n[>)
	<d #o (
		(ɂ)
		)>
	;
<c #o (#h :#l)>
	(<is #h ΂>)
	<d #o (
		(΂)
		)>
	;
<c #o (#h :#l)>
	(<is #h > | <is #h ͂> | <is #h ͂悤> | <is #h "͂["> 
		| <is #h ͂悤> | <is #h In> | <is #h "In["> )
	<d #o (
		(͂悤܂)
		)>
	;

<c #o (#h Ȃ)>
	<d #o (
		(ႤƂƂ͂Ȃł)
		(Ȃł)
		(ł͂ȂƂ͂܂)
		(Ƃł)
		(킩悤ȋC܂)
		({ł)
		(Ȃ́A#h ȂƂ͂܂)
		)>
	;
<c #o (ł :#l)>
	<d #o  (
		(ł̂ł)
		(́AǂƂł)
		(ق)
		(ł̂łAł)
		(ꂪ]݂̂ł)
		(ȂƂłȂł傤)
		)>
	;
<c #o (Ȃ  :#l)>
	<d #o (
		(Ȃ́A#l )
		(#l  Aŗǂ̂ł)
		(#l AłǂȂłH)
		(ɂĂǂv܂H)
		(ł)
		)>
	;
<c #o (  :#l)>
	<d #o (
		(̓CCUłAȂ̂߂ɂɋ܂)
		(́ACCUł)
		(ȂłAȂ #l)
		(킩܂)
		(ȂƓł)
		(Ȃ́AǂȂł傤)
		)>
	;
<c #o ( :#l)>
	<d #o (
		(͑厖ł)
		(ƁAȂƂȂ܂)
		(΁A]܂)
		(͂Ȃ̂ł)
		)>
	;
<c #o (] :#l)>
	<d #o (
		(]͑厖ł)
		(]܂傤)
		(ƁAȂƂȂ܂)
		(΁A]܂)
		(Ȃ̂]ł)
		)>
	;
<c #o (J :#l)>
	<d #o (
		(JĂ̂Ƃ܂)
		(]܂傤)
		(ƁAȂƂȂ܂)
		(΁A]܂)
		(̂ȂƂȂ܂)
		(lł)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ͂ǂȂ̂ł傤H)
		(ꂪ #h ł)
		(#h ɂĂǂv܂)
		(#h ͂ǂł傤)
		(Ȃ #h Ɋ҂ł܂)
		(炭A #h ̂ƂƎv܂)
		(#h ɂĘbĂ)
		(ʓI #h ł)
		(#h ȂĎvȂł)
		(łA #h ͖{͂Ȃ̂Ȃł)
		(#l ƂƂł)
		(#h ́A{ł)
		(#h ̑_͉ł傤)
		(#h ̖͉ł傤)
		(#h ł܂)
		(#l ɂ́ANN܂)
		(ȂƁI #l Ƃ́II)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ͂ǂȂ̂[ł)
		(#h y݂ł)
		(#h ł)
		(A#h ɂčl܂)
		(͂A#h ͏dvł)
		(#h Qlɂ܂傤)
		(#h ́A􂵂ł)
		(#h ł܂)
		(#h ͂ǂȂ̂ł傤)
		(#h CɂȂ܂)
		(#l ƂƂł)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ɂ͂ǂ̂悤ȖړI܂)
		(#h Ɋ҂܂傤)
		(#h ͂ǂł)
		(#h ɂ͍܂)
		(#h ɂ͋Ȃł)
		(́A #h ł)
		(#h ́Azȏł)
		(#h ɂ́AVN܂)
		(#h ͂ǂȂ̂ł傤)
		(ȂقǁA #l ƂƂł)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ɂ͂ǂ̂悤ȖړI܂)
		(|Cg #h ł)
		(#h ͑؂ł)
		(#h 𓚂Ă)
		(#h ͊mł)
		(#h ҂܂傤)
		( #h ͊mł)
		(#h ͂ǂȂ̂ł傤)
		(́A #h ƂƂł)
		(́A #l ƂƂł)
		)>
	;
<c #o (#h1  #h2 :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<noteq #h2 "u"><noteq #h2 "w"><noteq #h2 "("><noteq #h2 "i">
	<noteq #h2 "["><noteq #h2 "{"><noteq #h2 "m"><noteq #h2 "o">
	<d #o (
		(#h1  #h2 ɂ́Aǂ̂悤ȖړI܂)
		(#h1  #h2 Advȃ|Cgł)
		(|Cg #h1  #h2 ł)
		(#h1  #h2 ɂĘbĂ)
		(#h1  #h2 ́A؂ł)
		(#h1  #h2 ɒڂ܂)
		(#h1  #h2 ͂ǂȂ̂ł傤)
		(#h1  #h2 ɂӂ킵Ȃł)
		(́A #h1  #h2 ƂƂł)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ͂ǂ܂łȂ̂łH)
		(ꂪ #l ł)
		(#h ƂƂɂĂǂv܂)
		)>
	;
<c #o (Ԃ :#l)>
	<d #o (
		(ɂẮA悭mȂ̂ł)
		(#l AlĂ݂܂傤)
		(łH)
		(#l ɂāAmĂ邱Ƃ͂܂H)
		)>
	;
<c #o ()>
	<d #o (
		(ł)
		(łH)
		()
		(ł͂܂)
		)>
	;
<c #o (  :#l)>
	<d #o (
		(ƂƂłAႦ΂ǂ̂悤ȎȂ̂ł傤H)
		(łH)
		(Ȃ́A #l)
		(܂łł傤H)
		)>
	;
<c #o (CCU :#l)>
	<d #o (
		(CCÚA}V)
		(CCÚAAIł)
		(̃CCÚAfJgŏĂ܂)
		(CCUfJǵA񃍃WbNvO~Oł)
		(CCÚAȂ̖܂)
		(ƂŃfJgmĂ܂H)
		(CCU|͂ȂłH)
		(CCUAlX~ƍl܂񂩁H)
		)>
	;
<c #o (#h )>
	<d #o #h (
		(Ȃ #h)
		(Ȃ͐MĂ܂)
		(Ȃ͐MĂ܂)
		(ԂAȂ #h)
		)>
	;
<c #o (#h ܂)>
	<d #o (
		(Ȃ́A#h ܂)
		(ȂłA#h ܂)
		(ȂقǁA#h ܂)
		)>
	;
<c #o (#h ł)>
	<d #o (
		(łA #h ł)
		(#h ł̂ł)
		(Ȃق #h ł)
		)>
	;
<c #o (#h )>
	<d #o (
		(łA #h ł)
		(#h ł̂ł)
		(Ȃق #h ł)
		)>
	;
<c #o (#h )>
	<d #o (
		(łA #h ł)
		(#h ł̂ł)
		(Ȃق #h ł)
		)>
	;
<c #o ()>
	<d #o (
		(ӂށAӂ)
		(Ȃق)
		(ȂƂ킯ȂłI)
		(Ȃł)
		(ŁAǂȂ̂łH)
		(킩܂)
		([)
		(ł)
		()
		(ǂ܂傤)
		(ǂł傤)
		(ǂł)
		(Rł)
		(v킹Ԃł)
		(łA)
		(ȂˁI)
		(Ă)
		(͂͂)
		(ււ[)
		(ӂӂ)
		(ց[)
		(ւ[)
		()
		([)
		)>
	;
<c #o (#l1 : #l2)>
	<c #o #l2>
	;
	

? <Eliza>;
