From spitbol Tue Aug 28 17:22:12 1979
Use of eval('$fred') causes strang things - syntax error
use of eval(' $fred') causes stranger things - crap printed everywhere
please see file eval.bol in test.progs
From 7719736 Wed Apr 23 11:33:45 1980
E.
	trace('the')
	trace('object')
	trace('stype')
	trace('newknow')
	&dump = 0
	&trace = 0
	&ftrace = 0
	&anchor	= 1
	&trim = 1
	blanks = (span(' ') | null)
	letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
	word = span(letters)
	opword = (word | null)
	initword = ('where' | 'the' | 'what' | null)
	terminator = ('?' | '.')
	answerno = 'no' 
	answeryes = ('yes' | 'ok')
	statement = initword . stype blanks opword . newobject blanks 'is'
+		    blanks opword . pos blanks ('the' | null) . opthe
+		    blanks word . oldobject
+		    blanks terminator . ter rpos(0)
	poslist = table(50,5)
	data('relation(the,position,object,up,down,next)')
	info = word . newobject ' ' word . pos ' ' word . oldobject 
+	       (' ' word | null) . opthe
	input(.input,4,'/dev/tty')
	input(.knowledge,5,'knowledge')
	output(.newknow,6,'knowledge -a')
	root = relation('the',,'earth',,,)
	poslist['earth'] = root
*
*
	define('append(root,value)b')			:(eappend)
append	ident(down(root))				:s(first)
	b = down(root)
loop	ident(next(b))					:s(found)
	b = next(b)					:(loop)
found	next(b) = value
fin	up(value) = root				:(return)
first	down(root) = value				:(fin)
eappend
*
*
	define('print(value)')				:(eprint)
print	ident(value)					:s(return)
	ident(up(value))				:s(return)
	ident(the(up(value)))				:s(notthe)
	print = position(value) ' the ' 
+		object(up(value)) ' ' print(up(value))	:(return)
notthe	print = position(value) ' ' object(up(value))
+		' ' print(up(value))			:(return)
eprint
*
*
	define('trav(root)a,b')				:(etrav)
trav	ident(root)					:s(return)
	a = down(root)
	b = next(root)
	ident(a)					:s(next)
	ident(b)					:s(down)
both	trav = object(a) ', ' trav(a)
+		object(b) ', ' trav(b)			:(return)
down	trav =  object(a) ', ' trav(a)			:(return)
next	ident(b)					:s(return)
	trav = object(b) ', ' trav(b)			:(return)
etrav		
*
*
	define('slice(val,num)')			:(eslice)
slice	val rtab(num) . slice				:(return)
eslice
*
*
	define('in(pos,value)a')			:(ein)
in	no = 0
	a = down(value)
loop2	ident(a)					:s(return)
	ident(position(a),pos)				:s(prints)
hop	a = next(a)					:(loop2)
prints	ident(down(a))					:s(skip)
	no = no + 2
	in = in object(a) ', ' object(down(a)) ', ' 
+	     trav(down(a))				:(hop)
skip	no = no + 1
	in = in object(a) ', ' 				:(hop)
ein
*
*
	define('enter(the,newob,posit,oldob)new')	:(eenter)
enter	new = relation(the,posit,newob,,,)			:f(freturn)
	poslist[newob] = new				:f(freturn)
	append(poslist[oldob],new)			:(return)
eenter
*
*	main :
*
get	line = knowledge				:f(start)
	count = count + 1
	line info					:f(err)
	enter(opthe,newobject,pos,oldobject)		:s(get)f(help)
err	output = 'bad input format on line ' count
+		 ' of "knowledge".'			:(get)
start	output = 'Hi, I like to learn about the relationships between objects,'
	output = 'if you know something interesting, tell me. Otherwise I will'
	output = 'try to answer any questions you may have.'
read	line = input					:f(end)
	line statement					:f(mess)
	ok = 0
	ident(poslist[oldobject])			:s(mess2)
	ident(ter,'?')					:f(dot)
	ident(stype,'where')				:s(where)
	ident(stype,'what')				:s(what)f(mess)
dot	ident(ter,'.')					:f(mess)
	ident(poslist[newobject])			:s(dthe)f(mess3)
mess	ok = ok + 1
	ident(ok,4)					:s(hop3)
	output = "I don't understand."			:(read)
hop3	output = "Do you wish to continue, we don't"
+		 " seem to be getting very far ?"
	ok = 0
again	line = input					:f(end)
	line answeryes					:s(read)
	line answerno					:s(end)
	output = "You aren't being very helpful, do"
+		 " you wish to continue ?"		:(again)
mess2	output = "I don't know about the " oldobject ".":(read)
mess3	output = 'I already know about the ' newobject
+		  "."					:(read)
dthe	enter(stype,newobject,pos,oldobject)		:f(help)
	newknow = newobject ' ' pos ' ' oldobject ' ' stype	:(read)
where	ident(the(poslist[oldobject]))			:s(nothe)
	output = 'The ' oldobject ' is ' 
+		 slice(print(poslist[oldobject]),1) '.'	:(read)
nothe	output = oldobject ' is ' slice(print(poslist[oldobject]),1)
+		 '.'					:(read)
what	temp = in(pos,poslist[oldobject])
	ident(temp)					:f(fin1)
	output = "I don't know " slice(line,1) "."		:(read)
fin1	ident(no,1)					:s(fin2)
	output = 'The ' slice(temp,2) ' are ' pos
+		 ' the ' oldobject "."			:(read)
fin2	output = 'The ' slice(temp,2) ' is ' pos
+		 ' the ' oldobject '.'			:(read)
end

