A=DRPSRF(V,L)
[Distributed rational polynomial special read, formula version.
V is a variable list. L is a list of terminator characters. A is
a polynomial in distributive internal canonical form.]
SAFE SL,C,TL,EL,JL,RL.
(1) $(INITIALIZE A) A=(). C=CREADB().
IF C EQ $=0 THEN
(C=CREADB(). IF LSRCH(C,L) gt 0 THEN (A=0. BKSP. RETURN)
ELSE (PRINT $(UNEXPECTED CHARACTER). GO TO 6) ).
(2) $(BEGIN NEXT TERM. ESTABLISH SIGN) TL=0. SL=1. DL=().
AL=LIST2(1,1).
IF C EQ $=- THEN (SL=-1. C=CREADB() )
ELSE IF C EQ $=+ THEN C=CREADB().
(3) $(ESTABLISH COEFFICIENT)
IF DIGIT(C) EQ 1 THEN
(TL=1. BKSP. AL=RNREAD().
IF AL EQ 0 THEN
(PRINT $(ZERO COEFFICIENT). GO TO 6).
C=CREADB() ).
IF SL LT 0 THEN AL=RNNEG(AL).
(4) $(READ MONOMIAL, IF ANY) WHILE LETTER(C) EQ 1 DO
(TL=1. EL=1. BKSP. VL=VREAD(). JL=VLSRCH(VL,V).
IF JL EQ 0 THEN (PRINT $(UNKNOWN VARIABLE). GO TO 6).
C=CREADB().
IF C EQ $=* THEN
(C=CREAD(). IF C NE $=* THEN
(PRINT $(ERROR - SINGLE ASTERISK SEEN).
GO TO 6).
C=CREADB(). IF DIGIT(C) EQ 1 THEN
(BKSP. EL=IREAD(). IF EL GE BETA THEN
(PRINT $(EXPONENT TOO LARGE).
GO TO 6) )
ELSE
(PRINT $(ILLEGAL CHARACTER IN EXPONENT).
GO TO 6).
C=CREADB() ).
DVINS(JL,EL,DL.RL,DL). IF RL EQ 0 THEN
(PRINT $(VARIABLE OCCURS TWICE IN MONOMIAL).
GO TO 6) ).
(5) $(INSERT TERM IN A. DETERMINE NEXT ACTION.)
IF TL EQ 1 THEN (DPINS(AL,DL,A.RL,A). IF RL EQ 0 THEN
(PRINT $(MONOMIAL OCCURS TWICE). GO TO 6) )
ELSE
(PRINT $(UNEXPECTED CHARACTER). GO TO 6).
IF LSRCH(C,L) gt 0 THEN (BKSP; return);
GO TO 2.
(6) $(ERROR EXIT) DIBUFF.
PRINT $(READING THROUGH NEXT terminator).
WHILE LSRCH(C,L) eq 0 DO C=CREAD(). BKSP.
PRINT $(THE (CONSTANT) POLYNOMIAL 1 RETURNED).
A=LIST2(1,()). RETURN..