// unit test  token-s.txt

//to testlex =
//	lex
//	while tok != tkEOF
//		case tok
//			tkIDEN:
//				prints tokstring space
//			tkNUMBER:
//				print tokvalue space
//			tkSTRING:
//				printc 34 prints tokstring printc 34 space
//			else:
//				syscall {17 tok}
//		lex

//to testatoi =
//	a = "12345678"
//	prints a space
//	b = atoi a
//	print b nl


to dogets buf | i =
	syscall {4 buf}
	i = 0
	while buf[i] != 0
		printc buf[i]
		i = i + 1
	nl

to testgets | a =
	a = array 1000
	dogets a
	while a[0] != 255
		dogets a

to prtt a | i =
	for i a a+CLEN-1
		printc inbuf[i]

to testtoken | k =
	initlex
	startlex
	k = 1
	TP = token
	while (inbuf[TP] != 255) & (k < 200)
		prtt TP space
		TP = TP + CLEN
		TP = token
		k = k + 1

to testtoken2 =
//	initctype
	inbuf[0] = 49
	inbuf[1] = 50
	inbuf[2] = 51
	inbuf[3] = 0
//	print aatoi inbuf 0 3 nl

// print char in array ar[start] with len
to printsa ar start len | i =
	for i start start+len-1
		printc ar[i]

to printsa2 ar | i =
	i = 0
	while ar[i] != 0
		i = i + 1
	print i space
	i = 0
	while ar[i] != 0
		printc ar[i]
		i = i + 1
		if i > 100 break

// testtoken2 printsa inbuf 0 3 nl

to testlex | cnt =
	initkeysym
	initlex
	startlex
	FI = fopen "lib.som" 0
	for cnt 1 2000
		lex
		if tok == tkEOF break
//        printc 60 print tok printc 62 space
//		prtoken tok space
	fclose FI

//testlex

to testtokstr | i =
	for i 0 20
		prints tok_str+(i*3) space

//testtokstr

to main = testlex

