1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
|
subroutine fact
c ======================================================================
c analyseur de facteurs
c ======================================================================
c
c Copyright INRIA
include '../stack.h'
c
parameter (nz1=nsiz-1,nz2=nsiz-2)
logical eqid,eptover
integer semi,eol,blank,r,excnt,lparen,rparen,num,name
integer id(nsiz),eye(nsiz),rand(nsiz),ones(nsiz),op,fun1
integer star,dstar,comma,quote,cconc,extrac,rconc
integer left,right,hat,dot,equal
logical recurs,compil
integer setgetmode
data star/47/,dstar/62/,semi/43/,eol/99/,blank/40/
data num/0/,name/1/,comma/52/,lparen/41/,rparen/42/
data quote/53/,left/54/,right/55/,cconc/1/,extrac/3/,rconc/4/
data hat/62/,dot/51/,equal/50/
c
data eye/672014862,nz1*673720360/
data rand/219613723,nz1*673720360/
data ones/470685464,nz1*673720360/
c
c
r = rstk(pt)
c
if (ddt .eq. 4) then
write(buf(1:12),'(3i4)') pt,r,sym
call basout(io,wte,' factor pt:'//buf(1:4)//' rstk(pt):'//
& buf(5:8)//' sym:'//buf(9:12))
endif
c
ir=r/100
if(ir.ne.3) goto 01
goto(25,26,99,29,99,51,43,48,55,62,65,66,41),r-300
goto 99
c
01 if (sym.eq.left) go to 20
if (sym.eq.quote) go to 15
if (sym.eq.num) go to 10
excnt = 0
if (sym .eq. name) go to 30
id(1) = blank
if (sym .eq. lparen) go to 36
if(err1.gt.0) then
pt=pt+1
02 pt=pt-1
r=rstk(pt)
if(int(r/100).ne.3) goto 02
goto(25,26,99,29,99,51,43,48,55,62,65,66),r-300
endif
call error(2)
c if (err .gt. 0) return
return
c
c put something on the stack
c --- single number, getsym stored it in stk(vsiz)
c
10 call getnum
if(err.gt.0) return
call getsym
go to 60
c
c --- string
c
15 call getstr
if(err.gt.0) return
call getsym
go to 60
c
c --- matrix defined by bracket operators
c
20 if(char1.eq.right) then
c create an empty matrix
call getsym
call defmat
if(err.gt.0) return
call getsym
goto 60
endif
201 if(char1.eq.eol.or.char1.eq.semi) then
call getsym
if(sym.eq.eol) then
if(lpt(4).eq.lpt(6)) then
if(comp(1).ne.0) call seteol
call getlin(0)
else
lpt(4)=lpt(4)+1
call getsym
endif
endif
if(char1.eq.right) then
c create an empty matrix
call getsym
call defmat
if(err.gt.0) return
call getsym
goto 60
endif
goto 201
endif
if (eptover(0,psiz-3)) return
pt=pt+1
rstk(pt)=0
pstk(pt)=0
c
21 continue
pt=pt+1
pstk(pt)=0
call getsym
c
22 if (sym.eq.semi .or. sym.eq.eol .or.sym.eq.right) go to 27
if (sym .eq. comma) call getsym
rstk(pt) = 301
c get next entry or block
icall=1
c *call* expr
return
c catenate entry or block with previous on the same row
25 continue
if(err1.ne.0) goto 22
pstk(pt)=pstk(pt)+1
if(pstk(pt).le.1) goto 22
pstk(pt)=1
rstk(pt)= 302
fin=cconc
rhs=2
icall=4
c *call* allops(cconc)
return
26 go to 22
27 pt=pt-1
if (sym.eq.semi .and. char1.eq.eol) call getsym
c catenate row with previous rows
if(err1.ne.0) goto 29
if(pstk(pt+1).gt.0) pstk(pt)=pstk(pt)+1
if(pstk(pt).le.1) goto 29
pstk(pt)=1
rstk(pt)= 304
fin=rconc
rhs=2
icall=4
c *call* allops(rconc)
return
29 if (sym .eq. eol) then
if(lpt(4).eq.lpt(6)) then
if(comp(1).ne.0) call seteol
call getlin(0)
else
lpt(4)=lpt(4)+1
call getsym
endif
endif
if (sym.eq.eol.and.err1.ne.0) then
pt=pt-1
go to 60
endif
if (sym .ne. right) go to 21
pt=pt-1
call getsym
go to 60
c
c --- named variable, function evaluation or matrix element x(...)
c
30 call putid(id,syn(1))
call getsym
if (sym .eq. lparen) then
c . check for blank separator in matrix definition
if(abs(lin(lpt(3)-2)).ne.blank.or.rstk(pt-2).ne.301) then
c . it is really x(....)
goto 36
endif
endif
fin=0
rhs = 0
c
if(comp(1).eq.0) then
c -- put a named variable in the stack
c check for indirect loading
fin=setgetmode(id)
call stackg(id)
if (err .gt. 0) return
if(fin.ne.0.or.err1.ne.0) goto 60
endif
c
c -- check for eye, rand ones function special call
fun1=fun
call funs(id)
if(err.gt.0) return
if(fun.eq.6.and.(fin.eq.14.or.fin.eq.13.or.fin.eq.15)) goto 53
if (fun .gt. 0) then
call putid(ids(1,pt+1),id)
call error(25)
if (err .gt. 0) return
endif
c this should never happen???
if (eqid(id,eye).or.eqid(id,rand)) then
call funs(id)
goto 53
endif
fun=fun1
c fin=0
fin=setgetmode(id)
call stackg(id)
if (err .gt. 0) return
if (fin .eq. 0) then
if(err1.ne.0) goto 60
call putid(ids(1,pt+1),id)
call error(4)
if (err .gt. 0) return
endif
go to 60
c
36 continue
c --- function evaluation or matrix element x(...)
if ( eptover(1,psiz-1)) return
c x(...) :store object or function name
rstk(pt)=0
pstk(pt)=lhs
call putid(ids(1,pt),id)
c modif ss
fun1=fun
fun=0
if(id(1).ne.blank) then
fin=-2
call funs(id)
if (fun .ne. 0) then
c name is a function name check if it is a call or a reference
else
c . allow indirect reference to variables
fun=-1
endif
endif
if(id(1).ne.blank) lhs=1
c
c eval function or variable arguments
38 call getsym
c
if(sym.eq.rparen) then
c . function has no input parameter
excnt=-1
goto 45
endif
c
fun1=fun
if(sym.eq.name.and.char1.eq.lparen) then
c . check for a function name
fun=0
fin=-2
call funs(syn)
if (fun .ne. 0) then
c name is a function name check if it is a call or a reference
else
fun=fun1
endif
endif
excnt = excnt+1
if(char1.ne.equal) goto 42
c next lines to manage named arguments (..,a=..)
fun=fun1
lpt4=lpt(4)
call getch
if(char1.eq.equal) then
c check for a==
lpt(4)=lpt4
goto 42
endif
if ( eptover(1,psiz-1)) return
ids(1,pt)=rhs
ids(2,pt)=lhs
ids(3,pt)=lct(4)
ids(4,pt)=fun
lct(4)=-1
rstk(pt)=313
lpt(4)=lpt(2)
pstk(pt)=excnt
char1=blank
icall=7
return
c *call* parse
41 continue
rhs=ids(1,pt)
lhs=ids(2,pt)
lct(4)=ids(3,pt)
excnt = pstk(pt)
fun=ids(4,pt)
pt = pt-1
c end of special code to manage named argument
goto 44
c
42 continue
c argument is a standard expression
if ( eptover(1,psiz-1)) return
pstk(pt) = excnt
ids(1,pt)=fun
ids(2,pt)=fun1
rstk(pt) = 307
icall=1
c *call* expr
return
43 excnt = pstk(pt)
fun=ids(2,pt)
pt = pt-1
c
44 continue
c one more argument ?
if (sym .eq. comma) go to 38
c end of argument sequence or recursive extraction ?
if (sym .ne. rparen) then
call error(3)
c if (err .gt. 0) return
return
endif
c
45 continue
c end of argument sequence or recursive extraction
recurs=.false.
call getsym
if(sym.eq.lparen) then
c . check for blank separator in matrix definition
if(abs(lin(lpt(3)-2)).eq.blank.and.rstk(pt-3).eq.301) then
c . end of argument sequence
goto 46
endif
c . recursive extraction
if(excnt.gt.1) then
c call error(3)
c return
if(comp(1).eq.0) then
c . form list with individual indexes
call mkindx(0,excnt)
if(err.gt.0) return
else
if (compil(19,0,excnt,0,0)) then
if (err.gt.0) return
endif
endif
excnt=1
recurs=.true.
endif
rstk(pt)=rstk(pt)-1
excnt=0
c . get one more argument of the recursive extraction
goto 38
elseif(rstk(pt).lt.0) then
c . all args of the recursive extraction have been computed
c . store them into a list
if(comp(1).eq.0) then
c . form list with individual indexes
call mkindx(1-rstk(pt),excnt)
if(err.gt.0) return
excnt=1
recurs=.true.
else
if (compil(19,1-rstk(pt),excnt,0,0)) then
if (err.gt.0) return
excnt=1
endif
endif
endif
46 continue
c all arguments evaluated
call putid(id,ids(1,pt))
lhs=pstk(pt)
pt=pt-1
if (id(1) .eq. blank) then
if(lhs.ne.excnt) then
call error(41)
if(err.gt.0) return
endif
if (recurs) then
call error(250)
return
endif
go to 60
endif
rhs = excnt
47 continue
c get function or variable to be evaluated for computed arguments
fin=0
if(comp(1).eq.0) then
fin=-2
call stackg(id)
if(err.gt.0) return
endif
if(fin.eq.0) then
c . id is not a standard variable
if (recurs) then
call error(250)
return
endif
if(err1.gt.0) goto 60
call funs(id)
if(err.gt.0) return
if(fun.gt.0) goto 53
fin=-2
call stackg(id)
if(err.gt.0) return
if(fin.eq.0) then
if(err1.gt.0) goto 60
call error(4)
if(err.gt.0) return
endif
endif
if(fin.gt.0) goto 50
if(rhs.eq.0) goto 60
c
c --- variable is a matrix or list :extraction
c
rhs=rhs+1
if ( eptover(1,psiz-1)) return
rstk(pt)=308
fin=extrac
icall=4
c *call* allops(extrac)
return
48 pt=pt-1
goto 60
c
c --- variable is macro : execution
c
50 if ( eptover(1,psiz-1)) return
call putid(id,ids(1,pt))
rstk(pt)=306
pstk(pt)=wmac
icall=5
c *call* macro
return
51 wmac=pstk(pt)
pt=pt-1
go to 60
c
c evaluate matrix function
53 if ( eptover(1,psiz-1)) return
rstk(pt) = 309
icall=9
c *call* matfns
return
55 pt = pt-1
go to 60
c
60 continue
c check for ', .' **, ^ and .^
if (sym .ne. quote) go to 63
i = lpt(3) - 2
if (abs(lin(i)) .eq. blank) go to 90
fin=quote
61 rhs=1
if ( eptover(1,psiz-1)) return
rstk(pt)=310
icall=4
c *call* allops(quote) or allops(dot+quote)
return
62 pt=pt-1
call getsym
63 if(sym.eq.hat) then
op=dstar
elseif(sym.eq.dot.and.char1.eq.hat) then
call getsym
op=dstar+dot
elseif(sym.eq.star.and.char1.eq.star) then
call getsym
op=dstar
elseif(sym.eq.dot.and.char1.eq.quote) then
call getsym
fin=dot+quote
goto 61
else
goto 90
endif
call getsym
if ( eptover(1,psiz-1)) return
rstk(pt) = 311
pstk(pt) = op
icall=3
c *call* factor
go to 01
65 rstk(pt)=312
fin=pstk(pt)
rhs=2
icall=4
c *call* allops(dstar)
return
66 pt=pt-1
goto 90
90 return
c
99 call error(22)
if (err .gt. 0) return
return
end
|