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 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
|
subroutine comand(id)
C ====================================================================
C Scilab Command and Keyword
C ====================================================================
C id(nsiz) coded name of the comand
c Copyright INRIA
include '../stack.h'
logical compil
C
integer lunit,mode(2)
C
integer cmdl
parameter (cmdl = 29)
parameter (nz1 = nsiz-1, nz2 = nsiz-2, nz3 = nsiz-3)
parameter (iif=1,iwhile=2,iselect=3)
C
integer cmd(nsiz,cmdl),a,blank,name
integer id(nsiz),ennd(nsiz),sel(nsiz),while(nsiz),for(nsiz)
integer iff(nsiz),func(nsiz),endfunc(nsiz)
integer semi,comma,eol,percen,lparen,slash
integer count,equal,nchar,pchar
logical eqid,cresmat
integer iadr
common/cmds/cmd
save cmds
C
data a/10/
data eol/99/,semi/43/,comma/52/,lparen/41/,equal/50/,slash/48/
data blank/40/,name/1/,percen/56/
data ennd/671946510,nz1*673720360/
data sel/236260892,673717516,nz2*673720360/
data while/353505568,673720334,nz2*673720360/
data iff/673713938,nz1*673720360/
data for/672864271,nz1*673720360/
data func/202841615,387453469,nz2*673720360/
data endfunc/252516110,487331614,672602130,nz3*673720360/
C if, else, for, while, end, select, case, quit, return
data ((cmd(i,j), i = 1,nsiz), j = 1,10)/
& 673713938,nz1*673720360,
& 236721422,nz1*673720360,
& 672864271,nz1*673720360,
& 353505568,673720334,nz2*673720360,
& 671946510,nz1*673720360,
$ 236260892,673717516,nz2*673720360,
& 236718604,nz1*673720360,
$ 487726618,nz1*673720360,
& 487727374,nz1*673720360,
$ 505220635,673715995,nz2*673720360/
C help, what, who, pause, clear, resume, then, do, apropos, abort
data ((cmd(i,j), i = 1,nsiz), j = 11,20)/
& 420810257,nz1*673720360,
& 487199008,nz1*673720360,
& 672665888,nz1*673720360,
& 471730713,673720334,nz2*673720360,
& 168695052,673720347,nz2*673720360,
& 505155099,673713686,nz2*673720360,
& 386797853,nz1*673720360,
& 673716237,nz1*673720360,
& 404429066,672929817,nz2*673720360,
& 454560522,673720349,nz2*673720360/
C break, elseif, pwd, function, endfunction, clc, continue, try, catch
data ((cmd(i,j), i = 1,nsiz), j = 21,29)/
& 168696587,673720340,nz2*673720360,
& 236721422,673713938,nz2*673720360,
& 671948825,nz1*673720360,
& 202841615,387453469,nz2*673720360,
& 252516110,487331614,672602130,nz3*673720360,
& 671880460,nz1*673720360,
& 488052748,236853010,nz2*673720360,
& 673323805,nz1*673720360,
& 203229708,673720337,nz2*673720360/
C
iadr(l) = l + l - 1
C
if (ddt .eq. 4) then
call cvname(id,buf,1)
call basout(io,wte,' comand : '//buf(1:nlgh))
endif
C
kcont=27
kbrk=21
fun = 0
do 10 k = 1,cmdl
if (eqid(id,cmd(1,k))) then
if(k.eq.15.or.(k.ge.11.and.k.le.13).or.k.eq.19.or.
* k.eq.26) goto 11
goto 15
endif
10 continue
c form function like call
fin = 0
nchar=lin(lpt(4))
if(char1.eq.comma.or.char1.eq.semi.or.char1.eq.eol) goto 11
if (char1.eq.slash.and.lin(lpt(4)).eq.slash) goto 11
if(lpt(4).ge.2) then
pchar=lin(lpt(4)-2)
if(pchar.ne.blank) return
endif
11 continue
fin=0
if(char1.eq.lparen.or.char1.eq.equal) return
if (comp(1).eq.0) then
rhs=0
fin=-1
call stackg(id)
if (fin.gt.0) then
ityp=abs(istk(iadr(lstk(fin))))
fin=0
if (ityp.ne.11.and.ityp.ne.13.and.ityp.ne.130) return
endif
endif
call funs(id)
if(fin.eq.0) then
if(comp(1).eq.0) then
fin=-4
call funs(id)
if(fin.eq.0) return
sym=char1
call cmdstr
else
sym=char1
call cmdstr
fin=-2
call stackg(id)
if(err.gt.0) return
fun=-1
endif
else
if(char1.eq.comma.or.char1.eq.semi.or.char1.eq.eol) then
sym=char1
return
endif
if (char1.eq.slash.and.lin(lpt(4)).eq.slash) then
sym=comma
return
endif
call cmdstr
endif
return
C
15 if (fin .eq. -1) return
C
fin = 1
C mots cles if then else for do while end case selec
goto (32,33,30,31,35,36,37) k
goto (42,42) k-16
C
goto (50,55,45,16,16,16,20,16,45,16,
& 16,16,120,130,38,140,150,16,16,130,160,170) k-7
16 call error(16)
return
C
C -----
C pause
C -----
C
20 continue
c if special compilation mode skip comands
if (comp(3).eq.1) then
fin=0
fun=0
return
endif
if (char1.ne.eol .and. char1.ne.comma .and. char1.ne.semi) then
if (.not.(char1.eq.slash.and.lin(lpt(4)).eq.slash)) then
call error(16)
return
endif
endif
C compilation de pause:<12>
if (compil(12,0,0,0,0)) return
fin = 3
goto 999
C
C
C ---------------------------------------
C for, while, if, else, end, select, case, elseif
C ---------------------------------------
C
30 fin = -11
goto 999
31 fin = -12
goto 999
32 fin = -13
goto 999
33 fin = -14
if (pt .eq. 0) then
goto 42
elseif (abs(rstk(pt)) .ne. 805) then
goto 42
endif
goto 999
35 fin = -10
if (pt .eq. 0) then
goto 42
elseif (abs(rstk(pt)).ne.805 .and. abs(rstk(pt)).ne.802 .and.
& abs(rstk(pt)).ne.806 .and. abs(rstk(pt)).ne.808 ) then
goto 42
endif
goto 999
36 fin = -15
goto 999
37 fin = -16
if (pt .eq. 0) then
goto 42
elseif (abs(rstk(pt)).ne.805 .or. ids(1,pt).ne.iselect) then
goto 42
endif
goto 999
38 fin = -17
if (pt .eq. 0) then
goto 42
elseif (abs(rstk(pt)) .ne. 805) then
goto 42
endif
goto 999
C
42 call error(34)
return
C
C -------------
C return/resume
C -------------
C
45 continue
if (char1 .eq. lparen) then
C return/resume avec rhs et sans lhs --> fonction et non commande
fin = 0
goto 999
endif
C compilation return:<99>
if (compil(99,0,0,0,0)) return
46 continue
k = lpt(1) - (13+nsiz)
if (pt.eq.0 .or. k.le.0) goto 998
pt = pt + 1
47 pt = pt - 1
if (pt .eq. 0) goto 48
if (rstk(pt).eq.802 .or. rstk(pt).eq.612 .or.
& (rstk(pt).eq.805.and.ids(1,pt).eq.iselect) .or.
& (rstk(pt).eq.616.and.pstk(pt).eq.10)) top = top - 1
ir = rstk(pt) / 100
if (ir .ne. 5) goto 47
48 continue
fin = 2
lhs = 0
goto 999
C
C -------------
C quit
C -------------
C
50 continue
c if special compilation mode skip comands
if (comp(3).eq.1) then
fin=0
fun=0
return
endif
C compilation quit:<17>
if (compil(17,0,0,0,0)) return
if (paus .ne. 0) then
C quit dans une pause
paus = paus - 1
pt = pt + 1
51 pt = pt - 1
if (rstk(pt) .ne. 503) goto 51
k = lpt(1) - (13+nsiz)
lpt(1) = lin(k+1)
lpt(2) = lin(k+4)
lpt(6) = k
bot = lin(k+5)
pt = pt - 1
rio = pstk(pt)
if (rstk(pt) .eq. 701) pt = pt - 1
goto 46
else
C quit (sortie)
fun = 99
endif
goto 998
C
C -------------
C exit
C -------------
C
55 continue
c if special compilation mode skip comands
if (comp(3).eq.1) then
fin=0
fun=0
return
endif
C compilation exit:<20>
if (compil(20,0,0,0,0)) return
if (niv.gt.0) then
call sciquit
stop
endif
fun = 99
goto 998
C
C pwd
C ---
140 continue
if(char1.eq.lparen) then
fin=0
fun=0
return
endif
c if special compilation mode skip comands
if (comp(3).eq.1) then
fin=0
fun=0
return
endif
fun=13
fin=44
rhs=0
return
C
60 continue
C
C abort
C -----
C
120 continue
c if special compilation mode skip comands
if (comp(3).eq.1) then
fin=0
fun=0
return
endif
if (compil(14,0,0,0,0)) return
C compilation abort:<14>
pt = pt + 1
121 pt = pt - 1
if (pt .eq. 0) goto 122
if (int(rstk(pt)/100) .eq. 5) then
k = lpt(1) - (13+nsiz)
lpt(1) = lin(k+1)
lpt(2) = lin(k+2)
lpt(3) = lin(k+3)
lpt(4) = lin(k+4)
lct(4) = lin(k+6)
lpt(6) = k
if (rstk(pt) .le. 502) then
c . abort in a macro an execstr or external
if(pt.gt.1) then
if(rstk(pt-1).eq.1002) then
c . abort in syncexec, make current parser finish
fin = 4
fun = 99
macr=macr-1
lct(8) = 0
lct(4)=pstk(pt)
pt = pt-1
goto 999
elseif(rstk(pt-1).ne.903.and.rstk(pt-1).ne.909.and.
$ rstk(pt-1).ne.706) then
c . abort in a macro
bot = lin(k+5)
endif
else
c . abort in a macro
bot = lin(k+5)
endif
elseif (rstk(pt) .eq. 503) then
if (rio .eq. rte) then
c . abort in a pause
rio = pstk(pt-1)
paus = paus - 1
bot = lin(k+5)
else
c . abort in an exec
mode(1)=0
call clunit(-rio,buf,mode)
rio = pstk(pt-1)
endif
endif
elseif (rstk(pt) .eq. 1001) then
c . abort in an external unstack it
niv=niv-1
endif
goto 121
122 continue
lct(8) = 0
fin = 4
comp(1) = 0
if (niv .gt. 0) err = 9999999
goto 999
C
C break, continue
C------
130 continue
kcmd=k
c if special compilation mode skip comands
if (comp(3).eq.1) then
fin=0
fun=0
return
endif
if(kcmd.eq.kcont) then
C compilation de continue:<13>
if(compil(28,0,0,0,0)) return
else
C compilation de break:<13>
if (compil(13,0,0,0,0)) return
endif
count = 0
pt = pt + 1
131 pt = pt - 1
if (pt .eq. 0) then
pt = 1
call putid(ids(1,pt),cmd(1,kcmd))
call error(72)
return
endif
C
ir = rstk(pt) / 100
c 96
if (ir .eq. 5) then
call putid(ids(1,pt),cmd(1,kcmd))
call error(72)
return
endif
c
if (ir .ne. 8) goto 131
count = count + 1
if (rstk(pt) .eq. 802) then
C . break or continue in a for loop
if (kcmd.eq.kbrk) then
top = top - 1
pt = pt - 2
endif
elseif(ids(1,pt).eq.iselect) then
c . discard select variable
top = top - 1
goto 131
elseif (ids(1,pt).eq.iwhile) then
C . break or continue in a while
if (kcmd.eq.kbrk) pt = pt - 1
elseif (int(rstk(pt)/100) .eq. 5) then
call putid(ids(1,pt),cmd(1,kcmd))
call error(72)
return
else
goto 131
endif
132 continue
c call getsym
call skpins(1)
count = count - 1
if (count .gt. 0) goto 132
C char1=blank
if (kcmd.eq.kbrk) then
fin = 1
else
fin = -10
endif
return
150 if (eqid(id,func)) then
c . inline function definition
call getfunction
if(err.gt.0) return
call getsym
rhs=2
c if (.false.) then
c c . next lines for compilation option
c top=top+1
c if (.not.cresmat("getfunction",top,1,1,1)) return
c l=iadr(lstk(top))+6
c istk(l)=23
c rhs=3
c endif
c .
lhs=1
fun=5
fin=11
go to 999
endif
c
160 continue
c try
fin = -18
goto 999
c
170 continue
c catch
fin = -19
goto 999
C
C
C fin
C ---
C
998 continue
fin = 0
call getsym
fin = 1
C
999 continue
lunit = 0
end
|