A BASIC interpretor (Part 4 of 4)

sources-request at genrad.UUCP sources-request at genrad.UUCP
Thu Aug 1 13:06:36 AEST 1985


Mod.sources:  Volume 2, Issue 26
Submitted by: ukma!david (David Herron)


#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	bs2/bstokens.h
#	bs2/lex.c
#	bs2/makefile
#	bs2/mkop.c
#	bs2/mkop.sh
#	bs2/mkrbop.c
#	bs2/mksop.c
#	bstest/tary.bs
#	bstest/tdata.bs
#	bstest/tdata.int
#	bstest/tf.int
#	bstest/tfor.bs
#	bstest/tfor.int
#	bstest/tgs.bs
#	bstest/tgs.int
#	bstest/tif.bs
#	bstest/tif.int
#	bstest/tloop.bs
#	bstest/tloop.int
#	bstest/trp.bs
#	bstest/trp.int
#	bstest/tst6.bs
#	bstest/tst6.int
#	bstest/twh.bs
#	bstest/twh.int
# This archive created: Tue Jul 30 13:03:40 1985
export PATH; PATH=/bin:$PATH
if test ! -d 'bs2'
then
	echo shar: creating directory "'bs2'"
	mkdir 'bs2'
fi
echo shar: extracting "'bs2/bstokens.h'" '(1017 characters)'
if test -f 'bs2/bstokens.h'
then
	echo shar: will not over-write existing file "'bs2/bstokens.h'"
else
sed 's/^X//' << \SHAR_EOF > 'bs2/bstokens.h'
# define EQUAL 257
# define NEQ 258
# define LE 259
# define LT 260
# define GE 261
# define WHILE 262
# define GT 263
# define OR 264
# define AND 265
# define NOT 266
# define RET 267
# define REPEAT 268
# define IF 269
# define THEN 270
# define ELSE 271
# define GOTO 272
# define GOSUB 273
# define UNTIL 274
# define STOP 275
# define END 276
# define INTEGER 277
# define REAL 278
# define SCONST 279
# define ELIHW 280
# define LET 281
# define SWORD 282
# define PRINT 283
# define INPUT 284
# define DATA 285
# define CFOR 286
# define FOR 287
# define TO 288
# define STEP 289
# define READ 290
# define WRITE 291
# define NEXT 292
# define DEFINE 293
# define LFUN 294
# define SFUN 295
# define FDEF 296
# define SYMBOL 297
# define DIM 298
# define VALUE 299
# define IWORD 300
# define RWORD 301
# define ROFC 302
# define LOOP 303
# define EXITIF 304
# define ITOR 305
# define RTOI 306
# define ITOA 307
# define RTOA 308
# define LEAVE 309
# define CONTINUE 310
# define POOL 311
# define UNARY 312
SHAR_EOF
if test 1017 -ne "`wc -c < 'bs2/bstokens.h'`"
then
	echo shar: error transmitting "'bs2/bstokens.h'" '(should have been 1017 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bs2/lex.c'" '(3933 characters)'
if test -f 'bs2/lex.c'
then
	echo shar: will not over-write existing file "'bs2/lex.c'"
else
sed 's/^X//' << \SHAR_EOF > 'bs2/lex.c'
/* lex.c -- tokeniser
 */

#include <stdio.h>
#include <ctype.h>
#include "bstokens.h"

#define gather(c)	{ yytext[yyleng++] = c; }
#define getdig(c)	{ for(;isdigit(c);c=input()) gather(c); }

#define ERROR (-1) /* yacc won't know what -1 is, gaurantees a syntax error */

#define YYTXTSIZ	200
char yytext[YYTXTSIZ];
int yyleng;
extern char *yylval;	/* to return values to Yacc with */
extern FILE *bsin;

struct word {
    int val;
    char *name;
} words[] = {
	OR,"or",	AND,"and",	NOT,"not",	RET,"return",
	IF,"if",	THEN,"then",	ELSE,"else",	WHILE,"while",
	GOTO,"goto",	GOSUB,"gosub",	STOP,"stop",	END,"end",
	LET,"let",	PRINT,"print",	INPUT,"input",	FOR,"for",
	TO,"to",	STEP,"step",	READ,"read",	WRITE,"write",
	NEXT,"next",	DATA,"data",	ELIHW,"elihw",	REPEAT,"repeat",
	UNTIL,"until",	DEFINE,"define", LFUN,"longf",	SFUN,"shortf",
	FDEF,"file",	DIM,"dim",	SYMBOL,"symbol", VALUE,"value",
	ITOR,"itor",	ITOA,"itoa",	RTOI,"rtoi",	RTOA,"rtoa",
	CONTINUE,"continue",		LEAVE,"leave",
	LOOP,"loop",	EXITIF,"exitif",	POOL,"pool",
	-1,0
};

int yylex()
{
    char c;
    int i,j,typ;

    yylval = &yytext[0];
loop:
    c=input();
			/* tab, or space */
    if(c=='\t' || c==' ')
	goto loop;
			/* numbers start with a digit or a dot */
    else if(isdigit(c) || c=='.')
    {
	yyleng=0;
	typ=INTEGER;
	getdig(c);
	if(c == '.')
	{
	    typ = REAL;
	    gather(c);
	    c = input();
	    getdig(c);
	}
	/* at this point, SOME digits must have been read, or else error */
	if(yyleng==1 && yytext[0]=='.') goto reterr; /* only "." read */
	if(yyleng == 0) goto reterr;
	j = yyleng;		/* save end of first part */
	if(c=='e' || c=='E')	/* number raised to something */
	{
	    typ = REAL;
	    gather(c);
	    c = input();
	    if(c=='-' || c=='+') {gather(c); c=input(); }
	    getdig(c);
		/* if no digits read since end of first part,
		 * then there is an error
		 */
	    for(i=yyleng; i>=j; i--)
		if(isdigit(yytext[i]))
		    break;
	    if(i <= j) goto reterr;
	}
	unput(c);
	gather('\0');
	yylval = malloc(yyleng);
	strcpy(yylval,yytext);
	return(typ);
reterr:
	yyerror("badly formed number\n");
	return(ERROR);
    }
			/* word of some kind */
    else if(isalpha(c))
    {
	yyleng=0;
	gather(c);
	for(c=input(); isalpha(c) || isdigit(c) || c=='$' || c=='%'; c=input())
	    gather(c);
	unput(c);
	gather('\0');

	fold(yytext);
	for(i=0; words[i].val!=-1; i++)
		if(strcmp(yytext,words[i].name)==0)
			break;
	yylval = malloc(yyleng);
	strcpy(yylval,yytext);
	if(words[i].val != -1)
	    return(words[i].val);
	else
	    switch(yytext[yyleng-2]) {
		case '$': return(SWORD);
		case '%': return(IWORD);
		default: return(RWORD);
	    }
    }
			/* string constant */
    else if(c == '\"')
    {
	yyleng=0;
	for(c=input(); ;c=input())
	{
	    if(c == '\"')
		if((c=input()) == '\"')
		{
		    gather('\\');
		    gather('\"');
		}
		else break;
	    else if(c == '\\')
	    {
		gather('\\');
		c=input();
		gather(c);
		if(c == '\n') rdlin(bsin);
	    }
	    else if(c == '\n')
	    {
		fprintf(stderr,"unclosed string constant: %s\n",yytext);
		rdlin(bsin);
		return(ERROR);
	    }
	    else gather(c);
	}
	unput(c);
	gather('\0');
	yylval = malloc(yyleng);
	strcpy(yylval,yytext);
	return(SCONST);
    }
    else if(c == '=')
				/* EQUAL == '==' */
	if((c=input()) == '=')
	    return(EQUAL);
				/* ASSIGN == '=' */
	else
	    { unput(c); return('='); }
    else if(c == '<')
				/* NEQ == '<>' */
	if((c=input()) == '>')
	    return(NEQ);
				/* LE == '<=' */
	else if(c == '=')
	    return(LE);
				/* LT == '<' */
	else
	    { unput(c); return(LT); }
    else if(c == '>')
				/* GE == '>=' */
	if((c=input()) == '=')
	    return(GE);
				/* GT == '>' */
	else
	    { unput(c); return(GT); }
			/* anything else */
    else return(c);
}

/* fold(s) -- change string to all lower-case letters.
 */
fold(s) char *s;
{
    int i;
    for(i=0; s[i]!='\0'; i++)
	if(isupper(s[i]))
	    s[i] = s[i] + ('a'-'A');
    return(s);
}
SHAR_EOF
if test 3933 -ne "`wc -c < 'bs2/lex.c'`"
then
	echo shar: error transmitting "'bs2/lex.c'" '(should have been 3933 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bs2/makefile'" '(651 characters)'
if test -f 'bs2/makefile'
then
	echo shar: will not over-write existing file "'bs2/makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'bs2/makefile'
OFILES = lex.o bsint.o action.o operat.o bslib.o errors.o
PRSO= bsgram.o lex.o bslib.o
INTO= bsint.o action.o operat2.o operat.o bslib.o errors.o

all: prs int
prs: ${PRSO}
	cc -s ${PRSO} -o prs
bsgram.o: bsgram.c bsdefs.h
	cc -c bsgram.c
bsgram.c: bsgram.y
	yacc -d bsgram.y
	mv y.tab.c bsgram.c
	mv y.tab.h bstokens.h

int: ${INTO}
	cc ${INTO} -o int

${OFILES}: bsdefs.h

operat2.o: mkop.c mkrbop.c mksop.c mkop.sh bsdefs.h
	cc mkop.c -o op
	cc mkrbop.c -o rop
	cc mksop.c -o sop
	mkop.sh >operat2.c
	cc -c operat2.c
	rm operat2.c op sop rop

pr:
	pr bsgram.y lex.c bsdefs.h bslib.c bsint.c action.c operat.c mkop.c mkrbop.c mksop.c errors.c | lpr
SHAR_EOF
if test 651 -ne "`wc -c < 'bs2/makefile'`"
then
	echo shar: error transmitting "'bs2/makefile'" '(should have been 651 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bs2/mkop.c'" '(1199 characters)'
if test -f 'bs2/mkop.c'
then
	echo shar: will not over-write existing file "'bs2/mkop.c'"
else
sed 's/^X//' << \SHAR_EOF > 'bs2/mkop.c'
/* mkop.c -- make operator function for bs.
 *
 *	USAGE: op name type oper tag
 *
 * where:	name: name of function generated.
 *		type: data type of operation.
 *		oper: operator for operation.
 *		tag: structure tag name.
 *
 * This will only work with T_INT and T_DBL operators, T_CHR operations
 * do not boil down to a simple operation.
 */
#include <stdio.h>

main(argc,argv)
char **argv;
int argc;
{
    char *name,*type,*oper,*tag;

    if(argc != 5) {
	fprintf(stderr,"arg count\n");
	exit(1);
    }
    name = argv[1]; type = argv[2]; oper = argv[3]; tag = argv[4];

    printf("_%s(l,p)\n",name);
    printf("int (*l[])(),p;\n");
    printf("{\n");
    printf("    union value rg1,rg2,result;\n");
    printf("\n");
    printf("    switch(status&XMODE) {\n");
    printf("	case M_READ: dtype = T_%s;\n",type);
    printf("	case M_EXECUTE:\n");
    printf("	    rg2 = pop();\n");
    printf("	    rg1 = pop();\n");
    printf("	    result.%s = rg1.%s %s rg2.%s;\n",tag,tag,oper,tag);
    printf("	    push(result);\n");
    printf("	case M_FIXUP:\n");
    printf("	case M_COMPILE: return(p);\n");
    printf("	default: STerror(\"%s\");\n",name);
    printf("    }\n");
    printf("}\n");
}
SHAR_EOF
if test 1199 -ne "`wc -c < 'bs2/mkop.c'`"
then
	echo shar: error transmitting "'bs2/mkop.c'" '(should have been 1199 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bs2/mkop.sh'" '(791 characters)'
if test -f 'bs2/mkop.sh'
then
	echo shar: will not over-write existing file "'bs2/mkop.sh'"
else
sed 's/^X//' << \SHAR_EOF > 'bs2/mkop.sh'
echo "/* operat2.c -- more operators for bs.  the ones that are all alike."
echo " */"
echo ""
echo "#include \"bsdefs.h\""
echo ""
op "iadd" "INT" "+" "ival"
op "radd" "DBL" "+" "rval" 
op "isub" "INT" "-" "ival" 
op "rsub" "DBL" "-" "rval" 
op "imult" "INT" "*" "ival" 
op "rmult" "DBL" "*" "rval" 
op "idiv" "INT" "/" "ival" 
op "rdiv" "DBL" "/" "rval" 
op "imod" "INT" "%" "ival" 
op "ieq" "INT" "==" "ival" 
rop "req" "=="
sop "seq" "=="
op "ineq" "INT" "!=" "ival" 
rop "rneq" "!="
sop "sneq" "!="
op "ileq" "INT" "<=" "ival" 
rop "rleq" "<="
sop "sleq" "<="
op "ilt" "INT" "<" "ival" 
rop "rlt" "<"
sop "slt" "<"
op "igeq" "INT" ">=" "ival" 
rop "rgeq" ">="
sop "sgeq" ">="
op "igt" "INT" ">" "ival" 
rop "rgt" ">"
sop "sgt" ">"
op "or" "INT" "||" "ival" 
op "and" "INT" "&&" "ival" 
SHAR_EOF
if test 791 -ne "`wc -c < 'bs2/mkop.sh'`"
then
	echo shar: error transmitting "'bs2/mkop.sh'" '(should have been 791 characters)'
fi
chmod +x 'bs2/mkop.sh'
fi # end of overwriting check
echo shar: extracting "'bs2/mkrbop.c'" '(987 characters)'
if test -f 'bs2/mkrbop.c'
then
	echo shar: will not over-write existing file "'bs2/mkrbop.c'"
else
sed 's/^X//' << \SHAR_EOF > 'bs2/mkrbop.c'
/* mkrbop.c -- make operator functions for bs.  (real-boolean functions.)
 *
 *	USAGE: op name oper
 *
 * where:	name: name of function generated.
 *		oper: operator for operation.
 */
#include <stdio.h>

main(argc,argv)
char **argv;
int argc;
{
    char *name,*oper;

    if(argc != 3) {
	fprintf(stderr,"arg count\n");
	exit(1);
    }
    name = argv[1]; oper = argv[2];

    printf("_%s(l,p)\n",name);
    printf("int (*l[])(),p;\n");
    printf("{\n");
    printf("    union value rg1,rg2,result;\n");
    printf("\n");
    printf("    switch(status&XMODE) {\n");
    printf("	case M_READ: dtype = T_INT;\n");
    printf("	case M_EXECUTE:\n");
    printf("	    rg2 = pop();\n");
    printf("	    rg1 = pop();\n");
    printf("	    result.ival = rg1.rval %s rg2.rval;\n",oper);
    printf("	    push(result);\n");
    printf("	case M_FIXUP:\n");
    printf("	case M_COMPILE: return(p);\n");
    printf("	default: STerror(\"%s\");\n",name);
    printf("    }\n");
    printf("}\n");
}
SHAR_EOF
if test 987 -ne "`wc -c < 'bs2/mkrbop.c'`"
then
	echo shar: error transmitting "'bs2/mkrbop.c'" '(should have been 987 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bs2/mksop.c'" '(932 characters)'
if test -f 'bs2/mksop.c'
then
	echo shar: will not over-write existing file "'bs2/mksop.c'"
else
sed 's/^X//' << \SHAR_EOF > 'bs2/mksop.c'
/* mksop.c -- make string comparator functions for bs.
 *
 *	USAGE: op name oper
 *
 * where:	name: name of function generated.
 *		oper: operator for operation.
 */
#include <stdio.h>

main(argc,argv)
char **argv;
int argc;
{
    char *name,*oper;

    if(argc != 3) {
	fprintf(stderr,"arg count\n");
	exit(1);
    }
    name = argv[1]; oper = argv[2];

    printf("_%s(l,p)\n",name);
    printf("int (*l[])(),p;\n");
    printf("{\n");
    printf("    union value rg1,rg2,result;\n");
    printf("\n");
    printf("    switch(status&XMODE) {\n");
    printf("	case M_EXECUTE:\n");
    printf("	    rg2 = pop();\n");
    printf("	    rg1 = pop();\n");
    printf("	    result.sval = strcmp(rg1.sval,rg2.sval) %s 0;\n",oper);
    printf("	    push(result);\n");
    printf("	case M_FIXUP:\n");
    printf("	case M_COMPILE: return(p);\n");
    printf("	default: STerror(\"%s\");\n",name);
    printf("    }\n");
    printf("}\n");
}
SHAR_EOF
if test 932 -ne "`wc -c < 'bs2/mksop.c'`"
then
	echo shar: error transmitting "'bs2/mksop.c'" '(should have been 932 characters)'
fi
fi # end of overwriting check
if test ! -d 'bstest'
then
	echo shar: creating directory "'bstest'"
	mkdir 'bstest'
fi
echo shar: extracting "'bstest/tary.bs'" '(113 characters)'
if test -f 'bstest/tary.bs'
then
	echo shar: will not over-write existing file "'bstest/tary.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tary.bs'
10 a=1.0
20 b(3)=2.0
30 b(2)=1.0
40 b(1)=0.0
45 print rtoa(a),rtoa(b(3)),rtoa(b(2)),rtoa(b(1)),rtoa(b(5))
50 end
SHAR_EOF
if test 113 -ne "`wc -c < 'bstest/tary.bs'`"
then
	echo shar: error transmitting "'bstest/tary.bs'" '(should have been 113 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tdata.bs'" '(134 characters)'
if test -f 'bstest/tdata.bs'
then
	echo shar: will not over-write existing file "'bstest/tdata.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tdata.bs'
10 data 10,20,15,30,5,35,12,32,0
20 read i%
30 if i%==0 then goto 200
40 print itoa(i%),
50 goto 20
200 print "\nOut of data"
210 end
SHAR_EOF
if test 134 -ne "`wc -c < 'bstest/tdata.bs'`"
then
	echo shar: error transmitting "'bstest/tdata.bs'" '(should have been 134 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tdata.int'" '(397 characters)'
if test -f 'bstest/tdata.int'
then
	echo shar: will not over-write existing file "'bstest/tdata.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tdata.int'
 line 10  data  icon 10  dsep  icon 20  dsep  icon 15  dsep  icon 30  dsep  icon 5  dsep  icon 35  dsep  icon 12  dsep  icon 32  dsep  icon 0  dsep 
 line 20  pushstate 16  var 64 i%  popstate 
 line 30  var 64 i%  val 64  icon 0  i==  if  goto 200  else 
 line 40  var 64 i%  val 64  itoa  scon "" ,  print 
 line 50  goto 20 
 line 200  scon "\nOut of data"  scon "\n" ;  print 
 line 210  end 
SHAR_EOF
if test 397 -ne "`wc -c < 'bstest/tdata.int'`"
then
	echo shar: error transmitting "'bstest/tdata.int'" '(should have been 397 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tf.int'" '(223 characters)'
if test -f 'bstest/tf.int'
then
	echo shar: will not over-write existing file "'bstest/tf.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tf.int'
 line 5  scon "Start please."  scon "\n" ;  print 
 line 6  input  var 32 a$  elst 
 line 10  var 0 i  con 1  con 10000  con 0  con 0 for 
 line 20  var 0 i  next 
 line 30  scon "Done."  scon "\n" ;  print 
 line 40  end 
SHAR_EOF
if test 223 -ne "`wc -c < 'bstest/tf.int'`"
then
	echo shar: error transmitting "'bstest/tf.int'" '(should have been 223 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tfor.bs'" '(130 characters)'
if test -f 'bstest/tfor.bs'
then
	echo shar: will not over-write existing file "'bstest/tfor.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tfor.bs'
5 for j% = 1 to 10
7 print itoa(j%);"    ";
10 for i% = 1 to 10
20 print itoa(i%);"   ";
30 next i%
32 print ""
35 next j%
50 end
SHAR_EOF
if test 130 -ne "`wc -c < 'bstest/tfor.bs'`"
then
	echo shar: error transmitting "'bstest/tfor.bs'" '(should have been 130 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tfor.int'" '(565 characters)'
if test -f 'bstest/tfor.int'
then
	echo shar: will not over-write existing file "'bstest/tfor.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tfor.int'
 line 5  var 64 j%  icon 1  icon 10  icon 0  rlabel FOR2 rlabel FOR1 enter icon 0 rlabel FOR1 dlabel FOR0 for 
 line 7  var 64 j%  val 64  itoa  scon "    "  ;  scon "" ;  print 
 line 10  var 64 i%  icon 1  icon 10  icon 0  rlabel FOR5 rlabel FOR4 enter icon 0 rlabel FOR4 dlabel FOR3 for 
 line 20  var 64 i%  val 64  itoa  scon "   "  ;  scon "" ;  print 
 line 30  dlabel FOR5  var 64 i%  next rlabel FOR3 goto dlabel FOR4 exitlp 
 line 32  scon ""  scon "\n" ;  print 
 line 35  dlabel FOR2  var 64 j%  next rlabel FOR0 goto dlabel FOR1 exitlp 
 line 50  end 
SHAR_EOF
if test 565 -ne "`wc -c < 'bstest/tfor.int'`"
then
	echo shar: error transmitting "'bstest/tfor.int'" '(should have been 565 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tgs.bs'" '(143 characters)'
if test -f 'bstest/tgs.bs'
then
	echo shar: will not over-write existing file "'bstest/tgs.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tgs.bs'
10 a%=0
20 while ( a%<20 )
29 print itoa(a%),
30 gosub 100
31 print itoa(a%),
40 elihw
50 print "Done."
60 stop
100 a%=a%+1
110 return
120 end
SHAR_EOF
if test 143 -ne "`wc -c < 'bstest/tgs.bs'`"
then
	echo shar: error transmitting "'bstest/tgs.bs'" '(should have been 143 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tgs.int'" '(408 characters)'
if test -f 'bstest/tgs.int'
then
	echo shar: will not over-write existing file "'bstest/tgs.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tgs.int'
 line 10  var 64 a%  icon 0  store 64 pop 
 line 20  loopto  var 64 a%  val 64  icon 20  i<  while 
 line 29  var 64 a%  val 64  itoa  scon "	" ;  print 
 line 30  gosub 100 
 line 31  var 64 a%  val 64  itoa  scon "	" ;  print 
 line 40  elihw 
 line 50  scon "Done."  scon "\n" ;  print 
 line 60  stop 
 line 100  var 64 a%  var 64 a%  val 64  icon 1  i+  store 64 pop 
 line 110  return 
 line 120  end 
SHAR_EOF
if test 408 -ne "`wc -c < 'bstest/tgs.int'`"
then
	echo shar: error transmitting "'bstest/tgs.int'" '(should have been 408 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tif.bs'" '(180 characters)'
if test -f 'bstest/tif.bs'
then
	echo shar: will not over-write existing file "'bstest/tif.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tif.bs'
10 a=3.0
20 input b
30 if a==b then goto 100 else goto 70
40 print "failed"
50 stop
70 print rtoa(a);" != ";rtoa(b)
80 goto 20
100 print rtoa(a);" == ";rtoa(b)
110 goto 20
120 end
SHAR_EOF
if test 180 -ne "`wc -c < 'bstest/tif.bs'`"
then
	echo shar: error transmitting "'bstest/tif.bs'" '(should have been 180 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tif.int'" '(538 characters)'
if test -f 'bstest/tif.int'
then
	echo shar: will not over-write existing file "'bstest/tif.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tif.int'
 line 10  var 192 a  rcon 3.0  store 192 pop 
 line 20  pushstate 4  var 192 b  popstate 
 line 30  var 192 a  val 192  var 192 b  val 192  r==  rlabel IF0 if  goto 100  rlabel IF1 go@  dlabel IF0  goto 70  dlabel IF1 
 line 40  scon "failed"  scon "\n" ;  print 
 line 50  stop 
 line 70  var 192 a  val 192  rtoa  scon " != "  ;  var 192 b  val 192  rtoa  ;  scon "\n" ;  print 
 line 80  goto 20 
 line 100  var 192 a  val 192  rtoa  scon " == "  ;  var 192 b  val 192  rtoa  ;  scon "\n" ;  print 
 line 110  goto 20 
 line 120  end 
SHAR_EOF
if test 538 -ne "`wc -c < 'bstest/tif.int'`"
then
	echo shar: error transmitting "'bstest/tif.int'" '(should have been 538 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tloop.bs'" '(164 characters)'
if test -f 'bstest/tloop.bs'
then
	echo shar: will not over-write existing file "'bstest/tloop.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tloop.bs'
10 loop
20    input a,b
30 exitif a==b
40    a% = rtoi(a)
50    b% = rtoi(b)
60    print "a:";(a);" a%:";(a%);" b:";(b);" b%:";(b%)
70 pool
80 print "Done."
90 end
SHAR_EOF
if test 164 -ne "`wc -c < 'bstest/tloop.bs'`"
then
	echo shar: error transmitting "'bstest/tloop.bs'" '(should have been 164 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tloop.int'" '(618 characters)'
if test -f 'bstest/tloop.int'
then
	echo shar: will not over-write existing file "'bstest/tloop.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tloop.int'
 line 10  rlabel LP2 rlabel LP1 enter dlabel LP0 
 line 20  pushstate 4  var 192 a  var 192 b  popstate 
 line 30  var 192 a  val 192  var 192 b  val 192  r==  not rlabel LP1 if 
 line 40  var 64 a%  var 192 a  val 192  rtoi  store 64 pop 
 line 50  var 64 b%  var 192 b  val 192  rtoi  store 64 pop 
 line 60  scon "a:"  var 192 a  val 192  rtoa  ;  scon " a%:"  ;  var 64 a%  val 64  itoa  ;  scon " b:"  ;  var 192 b  val 192  rtoa  ;  scon " b%:"  ;  var 64 b%  val 64  itoa  ;  scon "\n" ;  print 
 line 70  dlabel LP2 rlabel LP0 goto dlabel LP1 exitlp 
 line 80  scon "Done."  scon "\n" ;  print 
 line 90  end 
SHAR_EOF
if test 618 -ne "`wc -c < 'bstest/tloop.int'`"
then
	echo shar: error transmitting "'bstest/tloop.int'" '(should have been 618 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/trp.bs'" '(74 characters)'
if test -f 'bstest/trp.bs'
then
	echo shar: will not over-write existing file "'bstest/trp.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/trp.bs'
10 repeat
20 print "Guess ";
30 input a
40 until ( rtoi(a) == 20 )
50 end
SHAR_EOF
if test 74 -ne "`wc -c < 'bstest/trp.bs'`"
then
	echo shar: error transmitting "'bstest/trp.bs'" '(should have been 74 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/trp.int'" '(246 characters)'
if test -f 'bstest/trp.int'
then
	echo shar: will not over-write existing file "'bstest/trp.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/trp.int'
 line 10  rlabel REP1 rlabel REP2 enter dlabel REP0 
 line 20  scon "Guess "  print 
 line 30  pushstate 4  var 192 a  popstate 
 line 40  dlabel REP1  var 192 a  val 192  rtoi  icon 20  i==  not rlabel REP0 if dlabel REP2 exitlp 
 line 50  end 
SHAR_EOF
if test 246 -ne "`wc -c < 'bstest/trp.int'`"
then
	echo shar: error transmitting "'bstest/trp.int'" '(should have been 246 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tst6.bs'" '(438 characters)'
if test -f 'bstest/tst6.bs'
then
	echo shar: will not over-write existing file "'bstest/tst6.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tst6.bs'
5 l%=32000
6 h%=-32000
9 print "trailer==0, input one number at a time."
10 input a%
20 if a%==0 then goto 100
30 if a%<l% then goto 60 
40 if a%>h% then goto 80
41 print"made it through	l:";itoa(l%);"h:";itoa(h%);"a:";itoa(a%)
50 goto 10
60 l%=a%
61 print"a<l	l:";itoa(l%);"h:";itoa(h%);"a:";itoa(a%)
70 goto 10
80 h%=a%
81 print"a>h	l:";itoa(l%);"h:";itoa(h%);"a:";itoa(a%)
90 goto 10
100 print "low=";itoa(l%),"high=";itoa(h%)
110 end
SHAR_EOF
if test 438 -ne "`wc -c < 'bstest/tst6.bs'`"
then
	echo shar: error transmitting "'bstest/tst6.bs'" '(should have been 438 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/tst6.int'" '(1399 characters)'
if test -f 'bstest/tst6.int'
then
	echo shar: will not over-write existing file "'bstest/tst6.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/tst6.int'
 line 5  var 64 l%  icon 32000  store 64 pop 
 line 6  var 64 h%  icon 32000  icon -1 i*  store 64 pop 
 line 9  scon "trailer==0, input one number at a time."  scon "\n" ;  print 
 line 10  pushstate 4  var 64 a%  popstate 
 line 20  var 64 a%  val 64  icon 0  i==  rlabel IF0 if  rlabel LN100 goto  rlabel IF1 goto  dlabel IF0 dlabel IF1 
 line 30  var 64 a%  val 64  var 64 l%  val 64  i<  rlabel IF2 if  rlabel LN60 goto  rlabel IF3 goto  dlabel IF2 dlabel IF3 
 line 40  var 64 a%  val 64  var 64 h%  val 64  i>  rlabel IF4 if  rlabel LN80 goto  rlabel IF5 goto  dlabel IF4 dlabel IF5 
 line 41  scon "made it through	l:"  var 64 l%  val 64  itoa  ;  scon "h:"  ;  var 64 h%  val 64  itoa  ;  scon "a:"  ;  var 64 a%  val 64  itoa  ;  scon "\n" ;  print 
 line 50  rlabel LN10 goto 
 line 60  var 64 l%  var 64 a%  val 64  store 64 pop 
 line 61  scon "a<l	l:"  var 64 l%  val 64  itoa  ;  scon "h:"  ;  var 64 h%  val 64  itoa  ;  scon "a:"  ;  var 64 a%  val 64  itoa  ;  scon "\n" ;  print 
 line 70  rlabel LN10 goto 
 line 80  var 64 h%  var 64 a%  val 64  store 64 pop 
 line 81  scon "a>h	l:"  var 64 l%  val 64  itoa  ;  scon "h:"  ;  var 64 h%  val 64  itoa  ;  scon "a:"  ;  var 64 a%  val 64  itoa  ;  scon "\n" ;  print 
 line 90  rlabel LN10 goto 
 line 100  scon "low="  var 64 l%  val 64  itoa  ;  scon "high="  ,  var 64 h%  val 64  itoa  ;  scon "\n" ;  print 
 line 110  end 
SHAR_EOF
if test 1399 -ne "`wc -c < 'bstest/tst6.int'`"
then
	echo shar: error transmitting "'bstest/tst6.int'" '(should have been 1399 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/twh.bs'" '(201 characters)'
if test -f 'bstest/twh.bs'
then
	echo shar: will not over-write existing file "'bstest/twh.bs'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/twh.bs'
9 print "Guess a number ";
10 input a
20 while ( rtoi(a) <> 20)
25 gosub 100
30 elihw
40 print "You guessed it!"
100 print "Do it again ";
110 input a
111 print "number is ";rtoa(a)
120 return
200 end
SHAR_EOF
if test 201 -ne "`wc -c < 'bstest/twh.bs'`"
then
	echo shar: error transmitting "'bstest/twh.bs'" '(should have been 201 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bstest/twh.int'" '(549 characters)'
if test -f 'bstest/twh.int'
then
	echo shar: will not over-write existing file "'bstest/twh.int'"
else
sed 's/^X//' << \SHAR_EOF > 'bstest/twh.int'
 line 9  scon "Guess a number "  scon "" ;  print 
 line 10  pushstate 4  var 192 a  popstate 
 line 20  rlabel WH2 rlabel WH1 enter dlabel WH0  var 192 a  val 192  rtoi  icon 20  i<>  rlabel WH1 if 
 line 25  rlabel LN100 gosub 
 line 30  dlabel WH2 rlabel WH0 goto dlabel WH1 exitlp 
 line 40  scon "You guessed it!"  scon "\n" ;  print 
 line 100  scon "Do it again "  scon "" ;  print 
 line 110  pushstate 4  var 192 a  popstate 
 line 111  scon "number is "  var 192 a  val 192  rtoa  ;  scon "\n" ;  print 
 line 120  return 
 line 200  end 
SHAR_EOF
if test 549 -ne "`wc -c < 'bstest/twh.int'`"
then
	echo shar: error transmitting "'bstest/twh.int'" '(should have been 549 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0



More information about the Mod.sources mailing list