9 static char *
rcsid=
"@(#)$Id$";
20 #define MAXTOKENLENGTH 1024 21 #define MAXSTRINGLENGTH 16384 22 #define to_upper(c) (islower(c) ? ((c)-'a'+'A') : (c)) 23 #define to_lower(c) (isupper(c) ? ((c)-'A'+'a') : (c)) 25 #define syntaxtype(ch) ((enum ch_type)(current_syntax[ch])) 186 #if IRIX || Linux_ppc 199 if (ch==EOF)
return(EOF);}
200 if (ch ==
';' && (Spevalof(QREADTABLE)->c.rdtab.macro->c.vec.v[ch]
205 if (ch==EOF)
return(EOF); }
207 goto skipblank;}
return(ch); }
214 ch=
readch(f); ch=
skip(ctx, f,ch);
return(ch);}
227 if (obj->
c.
lab.
label==labid)
return(obj);
235 {
pointer unsol, *unsolp, result,newlab;
246 #if sun3 || (!alpha && system5) || sanyo 249 #if sun4 || vax || news || mips || alpha || i386 260 #if sun3 ||( !alpha && system5 ) || sanyo 263 #if sun4 || vax || news || mips || alpha || i386 272 {
register pointer obj,element;
275 if ((element=obj->
c.
lab.
value)==UNBOUND)
return(obj);
276 else return(element);}
287 {
register pointer result,element;
294 while ((ch!=
')') && (ch!=EOF) && (i<size)) {
296 element=
read1(ctx,f);
297 if (islabref(element)) {
299 else result->
c.
vec.
v[i]=element;
303 while (i<size) result->
c.
vec.
v[i++]=element;
305 while (ch!=
')' && ch!=EOF) ch=
nextch(ctx,f);
309 while ((ch!=
')') && (ch!=EOF)) {
311 element=
read1(ctx,f);
320 else result->
c.
vec.
v[i]=element; }
326 {
register int i=0,x;
332 while (ch!=
')' && ch!=EOF) {
335 while (isdigit(ch)) { x=x*10+ch-
'0'; ch=
readch(s);}
336 if (ch==
'.') ch=
readch(s);}
346 x=(
intval(vpop())<<16) + x;
353 {
register int i=0,x;
362 while (ch!=
')' && ch!=EOF) {
378 register pointer name, klass, elem, result;
389 if (isvecclass(klass)) {
395 else if (isclass(klass)) {
401 while (ch!=
')' && ch!=EOF) {
404 if (islabref(elem)) {
406 else result->
c.
obj.
iv[i++]=elem;
415 {
register pointer name, klass, slot, elem, result, varvec, *slotp;
430 while (ch!=
')' && ch!=EOF) {
437 if (islabref(elem)) {
458 register int val,subchar;
463 while (ch!=subchar && ch!=
'#' && ch!=EOF) ch=
readch(f);
464 if (ch==EOF)
return((
pointer)EOF);
467 if (ch==
'#') {
if (--val<0)
return(UNBOUND);}
470 if (ch==subchar) { ch=
readch(f); val++;}
478 {
register int i=0,j,x,c,p,q;
481 char ch,
buf[WORD_SIZE];
484 while (i<WORD_SIZE && isxdigit(ch)) { buf[i++] =
ch; ch=
readch(f);}
491 for (j=i-1; j>=0; j--) {
493 x=(c<=
'9')?(c-
'0'):(c-
'A'+10);
494 bv[p/(WORD_SIZE-1)] |= ((x << q) & MASK);
495 if (q>=(WORD_SIZE-4)) bv[p/(WORD_SIZE-1) + 1] = x>>(WORD_SIZE-1-q);
496 p +=4; q = (q+4) % (WORD_SIZE-1);
508 char buf[WORD_SIZE/2],
ch;
510 while (i<WORD_SIZE/2 && ch>=
'0' && ch<
'8') { buf[i++] =
ch; ch=
readch(f);}
512 sscanf(buf,
"%lo",&val);
530 token[i++]=to_upper(ch); ch=
readch(f);}
540 return(
eval(ctx,p));}
546 if (issymbol(expr))
return(
memq(expr,speval(FEATURES)));
548 if (ccar(expr)==QNOT) {
551 else if (ccar(expr)==QAND) {
553 while (iscons(expr)) {
556 else expr=ccdr(expr);}
558 else if (ccar(expr)==QOR) {
560 while (iscons(expr)) {
562 if (r!=
NIL)
return(
T);
563 else expr=ccdr(expr);}
570 {
register pointer flag,result;
581 {
register pointer flag,result;
592 {
register pointer element,result,obj;
595 element=
read1(ctx,f);
597 element=speval(element);
598 if (element==UNBOUND || !isclass(element))
error(
E_NOCLASS,element);
599 obj=
read1(ctx,f); val=ckintval(obj);
600 result=makepointer(val);
601 if (classof(result)!=element)
604 while (ch!=
'>' && ch!=EOF) ch=
readch(f);
612 {
register int i=0,val=0,subchar;
617 if (
ch==EOF)
return(UNBOUND);
618 while (isdigit(
ch)) {
619 val=val*10+
ch-
'0'; ch=
nextch(ctx,f);
620 if (ch==EOF)
return(UNBOUND);}
621 subchar=to_upper(
ch);
624 if (isint(macrofunc)) {
626 result=(*intmac)(ctx,f,val,subchar,token);}
637 {
int tleng = 0, lengmax=MAXSTRINGLENGTH;
638 byte buf[MAXSTRINGLENGTH], *token, *newtoken;
644 while ((ch!=terminator) && (ch!=EOF)) {
647 if (tleng >= lengmax) {
649 newtoken=(
byte *)malloc(lengmax*2);
650 if (newtoken ==
NULL) {
651 if (malloced==
TRUE) cfree(token);
653 memcpy(newtoken,token,tleng);
654 if (malloced==
TRUE) cfree(token);
656 token=newtoken; lengmax=lengmax*2;
661 if (malloced==
TRUE) cfree(token);
667 register int leng,colon;
671 register int doublecolon=1;
681 if (doublecolon) colon--;
687 if (doublecolon)
return(
intern(ctx,&token[colon],leng-colon,pkg));
691 if (sym)
return(sym);
694 fprintf(stderr,
"%s ",token);
702 register char *str,**ptr;
706 while (isspace(*str)) str++;
708 if (ch==
'+') str++;
else if (ch==
'-') { str++; sign= -1;}
710 while (
'0'<= *str && *str<(
'0'+base)) val=val*base+(*str++)-
'0';
714 if (
'0'<= *str && *str<=
'9') val=val*base+(*str++ -
'0');
715 else if (
'A'<= *str && *str<(
'A'+base-10)) val=val*base+(*str++ -
'A'+10);
716 else if (
'a'<= *str && *str<(
'a'+base-10)) val=val*base+(*str++ -
'a'+10);
726 {
int base=
intval(Spevalof(READBASE));
727 int head,i,sign=1, k;
734 if (token[0]==
'+') { head=1;}
735 else if (token[0]==
'-') {head=1; sign= -1;}
739 for (i=head; i<len; i++) {
741 if (k>=
'0' && k<=
'9') k= k-
'0';
742 else if (k>=
'A' && k<=
'Z') k=k-
'A'+10;
743 else if (k>=
'a' && k<=
'z') k=k-
'a'+10;
744 else if (k==
'.')
continue;
751 ctx->lastalloc= vpop();
755 register int ch,base;
758 if (
ch<
'0'+base)
return(
TRUE);
760 else if (
ch<=
'9')
return(
TRUE);
761 else if (
'A'<=
ch &&
ch<
'A'+base-10)
return(
TRUE);
774 while (ch!=delim_char && ch!=EOF) {
779 element=
read2(ctx,f,0,0,1,token, -1);}
780 else if (syntaxtype(ch)==
ch_white) {
787 if (element!=UNBOUND && element!=(
pointer)EOF) ckpush(element);
789 while ((element=vpop())!=STOPPER) {
790 temp=
cons(ctx,element,result);
813 do { ch=
readch(f);}
while (ch!=
'\n' && ch!=EOF);
826 if(u<
v) {t=u; u=
v;
v=t;}
827 while(
v!=0){t=u %
v; u=
v;
v=t;}
839 if (g!=0) { num /=
g; denom /=
g;}
841 if (denom==1)
return(
makeint(num));
848 int escaped,multiescaped,i;
851 {
register int j,c, base;
858 extern double atof();
862 if (multiescaped)
goto step9;
866 if (ch==EOF)
goto step10;
867 if (ch<0) ch &= 0xff;
868 ctype=syntaxtype(ch);
874 else ch=to_upper(ch);
875 token[i++]=
ch;
goto step8;
877 token[i++]=
readch(ins); escaped=1;
goto step8;
893 ctype=syntaxtype(ch);
897 token[i++]=
ch;
goto step9;
899 ch=
readch(ins); token[i++]=
ch;
goto step9;
906 if (escaped)
return(
readsymbol(ctx,i,colon,token));
907 base=
intval(Spevalof(READBASE));
910 if ((token[j]==
'+') || (token[j]==
'-')) j++;
911 else if (token[j]==
'.' && token[j+1]==
'\0')
913 if (
is_digit(token[j],base) || token[j]==
'.') {
914 while (
is_digit(token[j],base)) j++;
915 if (token[j] ==
'.') {
916 if (++j==i)
return(
readint(ctx,token,i));
918 while (
is_digit(token[j],base)) j++;
919 c=to_upper(token[j]);
920 if (c==
'E' || c==
'D' || c==
'F' || c==
'L') {
922 if ((token[j]==
'+') || (token[j]==
'-')) j++;
923 while (
is_digit(token[j],base)) j++;
924 if (j==i) { token[c]=
'E';
return(
makeflt(atof(token)));}
926 else if (j==i)
return(
makeflt(atof(token)));
928 else if (token[j] ==
'/') {
932 while (
is_digit(token[j],base)) j++;
933 if (j==i)
return(
readratio(ctx,token,slash));
935 else if (j==i)
return(
readint(ctx,token,i));
937 c=to_upper(token[j]);
938 if (c==
'E' || c==
'D' || c==
'F' || c==
'L') {
940 if ((token[j]==
'+') || (token[j]==
'-')) j++;
941 while (
is_digit(token[j],base)) j++;
942 if (j==i) { token[c]=
'E';
return(
makeflt(atof(token)));}
944 else if (j==i)
return(
makeflt(atof(token)));
945 else return(
readsymbol(ctx,i,colon,token));} }
952 register int firstch;
953 register pointer macrofunc,result;
958 char token[MAXTOKENLENGTH];
964 if (ch==EOF)
return((
pointer)EOF);
967 ctype=syntaxtype(ch);
974 if (isint(macrofunc)) {
976 result=(*intmac)(ctx,ins,
ch,token);}
978 vpush(ins); vpush(
makeint(ch));
985 return(
read2(ctx,ins,1,0,1,token,colon));
992 else ch=to_upper(ch);
994 return(
read2(ctx,ins,0,0,1,token,colon));}}
1001 current_syntax=Spevalof(QREADTABLE)->c.rdtab.syntax->c.str.chars;
1003 if (ch==EOF)
return((
pointer)EOF);
1004 while (ch==
')') ch=
nextch(ctx,f);
1006 if (recursivep==
NIL) {
1010 else val=
read1(ctx,f);
1011 if (val==UNBOUND)
return(
NIL);
1048 Spevalof(QREADTABLE)=rdtable;
1049 for (i=0; i<256; i++) {
pointer makesymbol(context *, char *, int, pointer)
pointer intern(context *, char *, int, pointer)
static Char skip(context *ctx, pointer f, Char ch)
int strtol(char *str, char **ptr, int base)
pointer normalize_bignum()
pointer searchpkg(byte *, int)
pointer cons(context *, pointer, pointer)
static pointer read1(context *, pointer)
is_digit(int ch, int base)
static pointer readstructure(context *ctx, pointer s)
static pointer readvector(context *ctx, pointer f, int size)
pointer ufuncall(context *, pointer, pointer, pointer, struct bindframe *, int)
static pointer eval_read_cond(context *ctx, pointer expr)
static pointer findlabel(int labx)
static pointer read_cond_minus(context *ctx, pointer f)
static pointer readlabdef(context *ctx, pointer f, int labx)
pointer makevector(pointer, int)
static pointer read_cond_plus(context *ctx, pointer f)
pointer reader(context *ctx, pointer f, pointer recursivep)
static pointer read_sharp_char(context *ctx, pointer f, int val, int subchar)
enum ch_type chartype[256]
static pointer readlabref(ctx, pointer f, val, subchar)
static pointer readfvector(context *ctx, pointer s)
pointer makereadtable(context *)
static pointer readcomment(ctx, pointer f)
static pointer readrparen(ctx, f)
pointer * getobjv(pointer, pointer, pointer)
static pointer read_uninterned_symbol(context *ctx, pointer f, int val, int subchar, token)
enum ch_attr charattr[256]
static addunsolved(pointer labp, pointer *addr)
static pointer readlist(context *ctx, pointer f, char ch, token)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
pointer read_delimited_list(context *ctx, pointer f, int delim_char, token)
static pointer readivector(context *ctx, pointer s)
static pointer readsharp(context *ctx, pointer f, Char ch, token)
static pointer readsymbol(context *ctx, int leng, int colon, token)
static pointer readquote(context *ctx, pointer f)
static pointer readint(context *ctx, char *token, int len)
pointer makestring(char *, int)
static pointer readobject(context *ctx, pointer s)
static int nextch(context *ctx, pointer f)
static pointer read_sharp_comment(context *ctx, pointer f, int val, int subchar)
static pointer read_sharp_function(context *ctx, pointer f, int val, int subchar)
static pointer read_sharp_object(context *ctx, pointer f)
void complement_big(pointer x)
int unreadch(pointer, int)
pointer makeobject(pointer)
static pointer read_sharp_hex(context *ctx, pointer f, eusinteger_t val, int subchar)
static char buf[CHAR_SIZE]
static pointer read_sharp_eval(context *ctx, pointer f)
pointer eval(context *, pointer)
static pointer readstring(context *ctx, pointer f, int terminator)
static pointer readratio(context *ctx, char *token, int slash)
static pointer read2(context *, pointer, int, int, int, char *, int)
static pointer read_sharp_octal(context *ctx, pointer f, eusinteger_t val, int subchar)