/*
 * bLN^[
 * 	cfo[W 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) ((Ȃ :#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 "ׂʂɘb킯Ȃ񂾂">
	<print "łAǂĂȂbȂ">
	<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 Ȃ)>
	<d #o (
		(Ⴄ񂶂Ȃ)
		()
		(Ƃ)
		({I)
		(񂽂́A#h Ȃ)
		)>
	;
<c #o (ł :#l)>
	<d #o  (
		(ł̂)
		(́AǂƂ)
		([)
		(ł́AAI)
		(ꂪ]݂́A{)
		(ȂƂłȂ)
		)>
	;
<c #o (  :#l)>
	<d #o (
		(񂽂́A#l )
		(#l  Aŗǂ)
		(#l AłǂȂ̂H)
		(ǂv̂H)
		()
		)>
	;
<c #o (  :#l)>
	<d #o (
		(꣎qA񂽂̂߂ɂɋ̂)
		(́A꣎q)
		(A񂽂 #l Ax킹Ȃł)
		(킩Ȃ)
		(񂽂Ɠ)
		(񂽂́AǂȂ̂)
		)>
	;
<c #o ( :#l)>
	<d #o (
		(͑厖)
		(ƁAȂƂȂ)
		(΁A]Ă̂)
		(͂Ȃ̂)
		)>
	;
<c #o (] :#l)>
	<d #o (
		(]͑厖)
		(])
		(ƁAȂƂȂ)
		(΁A])
		(Ȃ̂])
		)>
	;
<c #o (J :#l)>
	<d #o (
		(JĂ̂Ƃ)
		(])
		(ƁAȂƂȂ)
		(΁A]̂)
		(̂ȂƂȂ)
		(ʂɁA񂽂̂ƂȂ񂩐SzȂ)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ͂ǂȂ́H)
		(ꂪ #h )
		(#h ɂĂǂvẮHA͂肵ȂI)
		(#h ͂ǂ)
		(Ȃ #h Ɋ҂ł)
		(炭A #h ̂ƂˁA킩)
		(#h ɂĘb)
		(ӂ #h )
		(łA #h ͖{͂Ȃ̂Ȃ)
		(#l ƂƂ)
		(#h ȂĎvȂ)
		(#h ́A{)
		(#h ̑_͉Hł̂)
		(#h ̖͉H)
		(#h ł)
		(#h ɂ́ANN)
		(#l ɂ́ANN)
		(ȂƁI #l Ƃ́II)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ͂ǂȂ)
		(#h y݁ANN)
		(#h )
		(#h ȂˁAႢȂł)
		(A#h ɂčlAזȂł)
		(͂A#h ͏dv)
		(#h Qlɂ)
		(#h ́A􂵂)
		(#h łAȂقǂ)
		(#h ͂ǂȂ́H)
		(#h CɂȂAmĂȂ狳ȂI)
		(#l ƂƂ)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ɂ͂ǂȖړI)
		(#h Ɋ҂Aʂɂ񂽂̂ƂȂ)
		(#h ͂ǂH)
		(#h ɂ͍)
		(#h ɂ͋Ȃ)
		(#h ȂˁAႢȂł)
		(́A #h )
		(#h ́AzȏゾA{)
		(#h ɂ́AVN)
		(#h ͂ǂȂ́H킩Ȃ́H)
		(ȂقǂˁA #l ƂƂ)
		)>
	;
<c #o (#h  :#l)>
	<#rand = ::sys<random _> % 2> <is #rand 1>
	<d #o (
		(#h ɂ͂ǂ̂悤ȖړÍH)
		(|Cg #h )
		(#h ͑؂)
		(#h 𓚂Ă)
		(#h ͊mˁA{ˁH͂茾Ȃ)
		( #h ͊mH)
		(#h ҂)
		(#h ͂ǂȂ́H)
		(#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́H)
		(#h1  #h2 Advȃ|CgI)
		(|Cg #h1  #h2 )
		(#h1  #h2 ɂĘbĂ)
		(#h1  #h2 ͑؂)
		(#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)
		()
		(Ȃ)
		(ɂĂˁACC)
		)>
	;
<c #o (  :#l)>
	<d #o (
		(H)
		(H)
		(񂽂́A #l)
		(܂ŁH)
		)>
	;
<c #o (꣎q :#l)>
	<d #o (
		(꣎q́A}V)
		(꣎q́AAI)
		(꣎q́AfJgŏĂ)
		(꣎qfJǵA񃍃WbNvO~O)
		(꣎q́A񂽂̖܂)
		(ƂŃfJgmĂH)
		(꣎q|͂ȂH)
		(꣎qAlX~)
		)>
	;
<c #o (#h )>
	<d #o #h (
		(񂽂 #h)
		(񂽂͐MĂ)
		(񂽂͐MĂȂ́H)
		(Ԃ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)
		(ŁAǂȂ́H[A[IȂB)
		(킩)
		([)
		(Ȃ̂)
		(邶Ȃ)
		()
		(ǂȂ̂A͂肵ȂI)
		(ǂȂ̂)
		(ǂ悤)
		(ǂꂽ́H)
		(RȂ̂)
		(v킹Ԃ)
		(Ȃ̂A)
		(񂽂ˁI)
		()
		(͂͂)
		(ււ)
		(ӂӂ)
		(͂I)
		(͂͂)
		()
		(ց[)
		(ւ[)
		()
		([)
		)>
	;
<c #o (#l1 : #l2)>
	<c #o #l2>
	;
	

? <Eliza>;
