basic.g 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. %token ILLEGAL ;
  6. %token ASSYM ;
  7. %token BASESYM ;
  8. %token CALLSYM ;
  9. %token CLEARSYM ;
  10. %token CLOSESYM ;
  11. %token DATASYM ;
  12. %token DEFINTSYM ;
  13. %token DEFSNGSYM ;
  14. %token DEFDBLSYM ;
  15. %token DEFSTRSYM ;
  16. %token DEFSYM ;
  17. %token DIMSYM ;
  18. %token ELSESYM ;
  19. %token ERRSYM ;
  20. %token ERLSYM ;
  21. %token ERRORSYM ;
  22. %token FIELDSYM ;
  23. %token FORSYM ;
  24. %token FUNCTION ;
  25. %token FUNCTID ;
  26. %token INKEYSYM ;
  27. %token GETSYM ;
  28. %token GOSUBSYM ;
  29. %token GOTOSYM ;
  30. %token IFSYM ;
  31. %token INPUTSYM ;
  32. %token LETSYM ;
  33. %token LINESYM ;
  34. %token LSETSYM ;
  35. %token MIDSYM ;
  36. %token NEXTSYM ;
  37. %token ONSYM ;
  38. %token OPENSYM ;
  39. %token OPTIONSYM ;
  40. %token PRINTSYM ;
  41. %token POKESYM ;
  42. %token PUTSYM ;
  43. %token RANDOMIZESYM ;
  44. %token READSYM ;
  45. %token REMSYM ;
  46. %token RESTORESYM ;
  47. %token RETURNSYM ;
  48. %token ENDSYM ;
  49. %token STOPSYM ;
  50. %token STEPSYM ;
  51. %token SWAPSYM ;
  52. %token THENSYM ;
  53. %token TOSYM ;
  54. %token TRONOFFSYM ;
  55. %token USINGSYM ;
  56. %token USRSYM ;
  57. %token WHILESYM ;
  58. %token WENDSYM ;
  59. %token WRITESYM ;
  60. /* special tokens */
  61. %token EOLN ;
  62. %token INTVALUE ;
  63. %token FLTVALUE ;
  64. %token DBLVALUE ;
  65. %token STRVALUE ;
  66. %token UNARYSYM ;
  67. %token IDENTIFIER ;
  68. %token ANDSYM ;
  69. %token ORSYM ;
  70. %token IMPSYM ;
  71. %token EQVSYM ;
  72. %token XORSYM ;
  73. %token VARPTR ;
  74. /* Those were originally %left */
  75. %token BOOLOP ;
  76. %token NOTSYM ;
  77. %token RELOP ;
  78. %token MODSYM ;
  79. /* Some contstant declared as tokens (?) */
  80. %token LESYM ;
  81. %token GESYM ;
  82. %token NESYM ;
  83. %token UNARYMINUS ;
  84. {
  85. #define YYDEBUG
  86. #include <stdlib.h>
  87. #include <stdio.h>
  88. #include "bem.h"
  89. #include "llmess.c"
  90. typedef union {
  91. int integer ;
  92. Symbol *Sptr ;
  93. char *cptr ;
  94. } YYSTYPE ;
  95. int basicline;
  96. int yydebug;
  97. YYSTYPE yylval;
  98. int ival;
  99. char *dval;
  100. char *sval;
  101. int in_data = 0; /* set if processing DATA statement */
  102. char *formatstring; /* formatstring used for printing */
  103. Symbol *s; /* Symbol dummy */
  104. #include "yylexp.c"
  105. #include "basic.lex"
  106. }
  107. %lexical yylexp;
  108. %start LLparse,programline ;
  109. programline
  110. : INTVALUE
  111. { basicline = ival;newblock(ival); newemblock(ival); }
  112. stmts EOLN
  113. | '#' INTVALUE STRVALUE EOLN
  114. | EOLN
  115. ;
  116. stmts : singlestmt
  117. [ %while ( LLsymb == ':' ) ':' singlestmt ]*
  118. ;
  119. singlestmt { int d2 ; }
  120. : callstmt
  121. | clearstmt
  122. | CLOSESYM closestmt
  123. | datastmt
  124. | defstmt
  125. | defvarstmt
  126. | dimstmt
  127. | ERRORSYM expression(&d2) { errorstmt(d2); }
  128. | fieldstmt
  129. | forstmt
  130. | getstmt
  131. | gosubstmt
  132. | onstmt
  133. | ifstmt
  134. | illegalstmt
  135. | inputstmt
  136. | letstmt
  137. | lineinputstmt
  138. | lsetstmt
  139. | midstmt
  140. | NEXTSYM nextstmt
  141. | GOTOSYM INTVALUE { gotostmt(ival); }
  142. | openstmt
  143. | optionstmt
  144. | pokestmt
  145. | printstmt
  146. | randomizestmt
  147. | readstmt
  148. | REMSYM
  149. | restorestmt
  150. | returnstmt
  151. | ENDSYM { C_loc((arith) 0 );
  152. C_cal("_hlt");
  153. C_asp((arith) BEMINTSIZE);
  154. }
  155. | STOPSYM { C_cal("_stop"); }
  156. | swapstmt
  157. | TRONOFFSYM { tronoff=yylval.integer; }
  158. | whilestmt
  159. | wendstmt
  160. | writestmt
  161. | /* EMPTY STATEMENT */
  162. ;
  163. illegalstmt: ILLEGAL { illegalcmd(); }
  164. ;
  165. callstmt { Symbol *id; int i; }
  166. : CALLSYM
  167. IDENTIFIER { id = yylval.Sptr; }
  168. [ parmlist(&i)
  169. { C_cal(id->symname);
  170. C_asp((arith) (i*BEMPTRSIZE));
  171. }
  172. | /* empty */
  173. { C_cal(id->symname); }
  174. ]
  175. ;
  176. parmlist(int *ip;) { int var ; }
  177. : '('
  178. variable(&var) { *ip = 1; }
  179. [ ',' variable(&var) { *ip = *ip + 1; } ]*
  180. ')'
  181. ;
  182. clearstmt { int exp; }
  183. : CLEARSYM [ ',' expression(&exp) ]*2
  184. { warning("statement ignored"); }
  185. ;
  186. closestmt: filelist
  187. | /* empty */ { C_cal("_close"); }
  188. ;
  189. filelist { int intv; }
  190. : cross
  191. intvalue(&intv)
  192. { C_loc((arith) ival);
  193. C_cal("_clochn");
  194. C_asp((arith) BEMINTSIZE);
  195. }
  196. [ ','
  197. cross
  198. intvalue(&intv)
  199. { C_loc((arith) ival);
  200. C_cal("_clochn");
  201. C_asp((arith) BEMINTSIZE);
  202. }
  203. ]* ;
  204. datastmt: DATASYM { datastmt(); in_data = 1;}
  205. datalist { fprint(datfile,"\n"); in_data = 0; }
  206. ;
  207. dataelm : INTVALUE { fprint(datfile,"%d",ival); }
  208. | '-' [ INTVALUE { fprint(datfile,"%d",-ival); }
  209. | FLTVALUE { fprint(datfile,"-%s",dval); }
  210. ]
  211. | FLTVALUE { fprint(datfile,dval); }
  212. | STRVALUE { fprint(datfile,"\"%s\"",sval); }
  213. | IDENTIFIER { fprint(datfile,"\"%s\"",sval); }
  214. ;
  215. datalist: dataelm
  216. [ ',' { fprint(datfile,","); }
  217. dataelm ]*
  218. ;
  219. defstmt : DEFSYM
  220. [ deffnstmt
  221. | defusrstmt
  222. ]
  223. ;
  224. deffnstmt { int exp; }
  225. : heading '=' expression(&exp)
  226. { endscope(exp); }
  227. ;
  228. heading : FUNCTID { newscope(yylval.Sptr); }
  229. [ '(' idlist ')' ]? { heading(); }
  230. ;
  231. idlist : IDENTIFIER { dclparm(yylval.Sptr); }
  232. [ ',' IDENTIFIER { dclparm(yylval.Sptr); }
  233. ]*
  234. ;
  235. defvarstmt: DEFINTSYM { setdefaulttype( INTTYPE); }
  236. | DEFSNGSYM { setdefaulttype( FLOATTYPE); }
  237. | DEFDBLSYM { setdefaulttype( DOUBLETYPE); }
  238. | DEFSTRSYM { setdefaulttype( STRINGTYPE); }
  239. ;
  240. defusrstmt: USRSYM ':' { illegalcmd(); }
  241. ;
  242. dimstmt { Symbol *symp; }
  243. : DIMSYM arraydcl(&symp) ')' { dclarray(symp); }
  244. [ ',' arraydcl(&symp) ')' { dclarray(symp); }
  245. ]*
  246. ;
  247. arraydcl(Symbol **sympp;)
  248. : IDENTIFIER { *sympp = s = yylval.Sptr; }
  249. '('
  250. INTVALUE
  251. {
  252. s->dimlimit[s->dimensions]=ival;
  253. s->dimensions++;
  254. }
  255. [ ','
  256. INTVALUE
  257. {
  258. if(s->dimensions<MAXDIMENSIONS) {
  259. s->dimlimit[s->dimensions]=ival;
  260. s->dimensions++;
  261. } else error("too many dimensions");
  262. }
  263. ]* ;
  264. fieldstmt { int intv; }
  265. : FIELDSYM cross intvalue(&intv)
  266. { setchannel(ival); }
  267. ',' fieldlist { notyetimpl(); }
  268. ;
  269. fieldlist { int intv; int var; }
  270. : intvalue(&intv) ASSYM variable(&var)
  271. [ ',' intvalue(&intv) ASSYM variable(&var) ]*
  272. ;
  273. forstmt { int exp; }
  274. : FORSYM IDENTIFIER { forinit(yylval.Sptr); }
  275. '=' expression(&exp) { forexpr(exp); }
  276. TOSYM expression(&exp) { forlimit(exp); }
  277. step
  278. ;
  279. step { int exp; }
  280. : STEPSYM expression(&exp) { forstep(exp); }
  281. | /*EMPTY*/ {
  282. C_loc((arith) 1);
  283. forstep(INTTYPE);
  284. }
  285. ;
  286. nextstmt: [ IDENTIFIER { nextstmt(yylval.Sptr); }
  287. | /* empty */ { nextstmt((Symbol *)0); }
  288. ]
  289. [ ',' IDENTIFIER { nextstmt(yylval.Sptr); }
  290. ]*
  291. ;
  292. getstmt { char *cp; int intv; }
  293. : getput(&cp)
  294. [ /* empty */
  295. { C_loc((arith) 0);
  296. C_cal(cp);
  297. C_asp((arith) BEMINTSIZE);
  298. }
  299. | ',' intvalue(&intv)
  300. { C_loc((arith) ival);
  301. C_cal(cp);
  302. C_asp((arith) BEMINTSIZE);
  303. }
  304. ]
  305. ;
  306. getput(char **cpp;) { int intv; }
  307. : GETSYM cross intvalue(&intv)
  308. { setchannel(ival);
  309. *cpp = "$_getrec";
  310. }
  311. | PUTSYM cross intvalue(&intv)
  312. { setchannel(ival);
  313. *cpp = "$_putsym";
  314. }
  315. ;
  316. gosubstmt: GOSUBSYM INTVALUE { gosubstmt(ival); }
  317. ;
  318. returnstmt: RETURNSYM { returnstmt(); }
  319. ;
  320. ifstmt { int exp; int d1; }
  321. : IFSYM expression(&exp) { d1=ifstmt(exp); }
  322. thenpart { d1=thenpart(d1); }
  323. elsepart { elsepart(d1); }
  324. ;
  325. thenpart: THENSYM [ INTVALUE { gotostmt(ival); }
  326. | stmts
  327. ]
  328. | GOTOSYM INTVALUE { gotostmt(ival); }
  329. ;
  330. elsepart: %prefer ELSESYM
  331. [ INTVALUE { gotostmt(ival); }
  332. | stmts
  333. ]
  334. | /* empty */
  335. ;
  336. inputstmt { int intv; }
  337. : INPUTSYM [ semiprompt readlist
  338. | '#' intvalue(&intv)
  339. { setchannel(ival); }
  340. ',' readlist
  341. ]
  342. ;
  343. semiprompt { int str; }
  344. : semi STRVALUE { str = yylval.integer; }
  345. [ ';' { loadstr(str);
  346. prompt(1);
  347. }
  348. | ',' { loadstr(str);
  349. prompt(0);
  350. }
  351. ]
  352. | /*EMPTY*/
  353. { setchannel(-1);
  354. C_cal("_qstmark");
  355. }
  356. ;
  357. semi : ';'
  358. | /* empty */
  359. ;
  360. letstmt { int var; int exp; }
  361. : LETSYM
  362. variable(&var) { save_address(); }
  363. '=' expression(&exp) { assign(var,exp); }
  364. |
  365. variable(&var) { save_address(); }
  366. '=' expression(&exp) { assign(var,exp); }
  367. ;
  368. lineinputstmt { int var; int intv; }
  369. : LINESYM
  370. [ INPUTSYM
  371. semiprompt { setchannel(-1); }
  372. variable(&var) { linestmt(var); }
  373. | '#'
  374. intvalue(&intv) { setchannel(ival); }
  375. ','
  376. variable(&var) { linestmt(var); }
  377. ]
  378. ;
  379. readlist: readelm
  380. [ ',' readelm ]*
  381. ;
  382. readelm { int var; }
  383. : variable(&var) { readelm(var); }
  384. ;
  385. lsetstmt { int var; int exp; }
  386. : LSETSYM variable(&var) '=' expression(&exp)
  387. { notyetimpl(); }
  388. ;
  389. midstmt { int exp; }
  390. : MIDSYM '$' midparms '=' expression(&exp)
  391. { C_cal("_midstmt");
  392. C_asp((arith) (2*BEMINTSIZE + 2*BEMPTRSIZE));
  393. }
  394. ;
  395. midparms: '(' midfirst midsec midthird ')'
  396. ;
  397. midfirst { int exp; }
  398. : expression(&exp) { conversion(exp,STRINGTYPE); }
  399. ;
  400. midsec { int exp; }
  401. : ',' expression(&exp) { conversion(exp,INTTYPE); }
  402. ;
  403. midthird { int exp; }
  404. : ',' expression(&exp) { conversion(exp,INTTYPE); }
  405. | /* empty */ { C_loc((arith) -1); }
  406. ;
  407. onstmt : ONSYM
  408. [ exceptionstmt
  409. | ongotostmt
  410. ]
  411. ;
  412. exceptionstmt: ERRORSYM GOTOSYM INTVALUE { exceptstmt(ival); }
  413. ;
  414. ongotostmt { int exp; }
  415. : expression(&exp)
  416. [ GOSUBSYM constantlist { ongosubstmt(exp); }
  417. | GOTOSYM constantlist { ongotostmt(exp); }
  418. ]
  419. ;
  420. constantlist: INTVALUE { jumpelm(ival); }
  421. [ ',' INTVALUE { jumpelm(ival); }
  422. ]*
  423. ;
  424. openstmt { int exp; }
  425. : OPENSYM mode openchannel expression(&exp)
  426. { conversion(exp,STRINGTYPE); }
  427. [ /* empty */ { openstmt(0); }
  428. | INTVALUE { openstmt(ival); }
  429. ]
  430. ;
  431. openchannel: cross INTVALUE ',' { setchannel(ival); }
  432. ;
  433. mode { int exp; }
  434. : expression(&exp) ',' { conversion(exp,STRINGTYPE); }
  435. | ',' { C_lae_dnam("_iomode",(arith)0); }
  436. ;
  437. optionstmt { int intv; }
  438. : OPTIONSYM BASESYM intvalue(&intv) { optionbase(ival); }
  439. ;
  440. printstmt { int plist; }
  441. : PRINTSYM
  442. [ /* empty */ { setchannel(-1);
  443. C_cal("_nl");
  444. }
  445. | file format printlist(&plist)
  446. { if(plist)
  447. C_cal("_nl");
  448. }
  449. ]
  450. ;
  451. file { int intv; }
  452. : '#' intvalue(&intv) ',' { setchannel(ival); }
  453. | /* empty */ { setchannel(-1); }
  454. ;
  455. format { int var ; }
  456. : USINGSYM
  457. [ STRVALUE { loadstr(yylval.integer); } ';'
  458. | variable(&var) ';'
  459. { if(var!=STRINGTYPE)
  460. error("string variable expected");
  461. }
  462. ]
  463. | /* empty */ { formatstring=0; }
  464. ;
  465. printlist(int *ip;) { int exp; }
  466. : [ expression(&exp) { printstmt(exp); *ip=1; }
  467. | ',' { zone(1); *ip=0; }
  468. | ';' { zone(0); *ip=0; }
  469. ]+
  470. ;
  471. pokestmt { int exp1; int exp2 ; }
  472. : POKESYM
  473. expression(&exp1)
  474. ','
  475. expression(&exp2) { pokestmt(exp1,exp2); }
  476. ;
  477. randomizestmt { int exp; }
  478. : RANDOMIZESYM
  479. [ /* empty */ { C_cal("_randomi"); }
  480. | expression(&exp)
  481. { conversion(exp,INTTYPE);
  482. C_cal("_setrand");
  483. C_asp((arith) BEMINTSIZE);
  484. }
  485. ]
  486. ;
  487. readstmt { int var; }
  488. : READSYM { setchannel(0); }
  489. variable(&var) { readelm(var); }
  490. [ ',' variable(&var) { readelm(var); }
  491. ]*
  492. ;
  493. restorestmt : RESTORESYM
  494. [ INTVALUE { restore(ival); }
  495. | /* empty */ { restore(0); }
  496. ]
  497. ;
  498. swapstmt { int var1; int var2; }
  499. : SWAPSYM
  500. variable(&var1)
  501. ','
  502. variable(&var2) { swapstmt(var1,var2); }
  503. ;
  504. whilestmt { int exp; }
  505. : WHILESYM { whilestart(); }
  506. expression(&exp) { whiletst(exp); }
  507. ;
  508. wendstmt : WENDSYM { wend(); }
  509. ;
  510. writestmt: WRITESYM
  511. [ /* empty */ { setchannel(-1);
  512. C_cal("_wrnl");
  513. }
  514. | file writelist { C_cal("_wrnl"); }
  515. ]
  516. ;
  517. writelist { int exp; }
  518. : expression(&exp) { writestmt(exp,0); }
  519. [ ',' expression(&exp) { writestmt(exp,1); }
  520. ]*
  521. ;
  522. cross: '#' | /* empty */ ;
  523. intvalue(int *ip;)
  524. : INTVALUE { *ip = yylval.integer; }
  525. ;
  526. variable(int *ip;) { Symbol *symp; int exp; }
  527. : identifier(&symp)
  528. [ %avoid /* empty */ { *ip = loadaddr(symp); }
  529. | '(' { newarrayload(symp); }
  530. expression(&exp) { loadarray(exp); }
  531. [ ',' expression(&exp) { loadarray(exp); } ]*
  532. ')' { *ip = endarrayload(); }
  533. ]
  534. | ERRSYM { C_lae_dnam("_errsym",(arith) 0);
  535. *ip = INTTYPE;
  536. }
  537. | ERLSYM { C_lae_dnam("_erlsym",(arith) 0);
  538. *ip = INTTYPE;
  539. }
  540. ;
  541. expression(int *ip;) { int neg; } /* NIEUW */
  542. : expression1(&neg) { *ip = neg; }
  543. [
  544. IMPSYM
  545. expression(&neg) { *ip = boolop(*ip,neg,IMPSYM); }
  546. ]?
  547. ;
  548. expression1(int *ip;) { int neg; }
  549. : expression2(&neg) { *ip = neg; }
  550. [ EQVSYM
  551. expression2(&neg) { *ip = boolop(*ip,neg,EQVSYM); }
  552. ]*
  553. ;
  554. expression2(int *ip;) { int neg; }
  555. : expression3(&neg) { *ip = neg; }
  556. [ XORSYM
  557. expression3(&neg) { *ip = boolop(*ip,neg,XORSYM); }
  558. ]*
  559. ;
  560. expression3(int *ip;) { int neg; }
  561. : expression4(&neg) { *ip = neg; }
  562. [ ORSYM
  563. expression4(&neg) { *ip = boolop(*ip,neg,ORSYM); }
  564. ]*
  565. ;
  566. expression4(int *ip;) { int neg; }
  567. : negation(&neg) { *ip = neg; }
  568. [ ANDSYM
  569. negation(&neg) { *ip = boolop(*ip,neg,ANDSYM); }
  570. ]*
  571. ;
  572. negation(int *ip;) { int comp; }
  573. : NOTSYM compare(&comp) { *ip=boolop(comp,0,NOTSYM); }
  574. | compare(ip)
  575. ;
  576. compare(int *ip;) { int sum1,sum2,rel; }
  577. : sum(&sum1)
  578. [ /* empty */ { *ip = sum1; }
  579. | RELOP { rel=yylval.integer; }
  580. sum(&sum2) { *ip=relop(sum1,sum2,rel); }
  581. | '=' sum(&sum2) { *ip=relop(sum1,sum2,'='); }
  582. ]
  583. ;
  584. sum(int *ip;) { int term1; }
  585. : term(&term1) { *ip = term1; }
  586. [ %while(1)
  587. '-' term(&term1) { *ip=plusmin(*ip,term1,'-'); }
  588. | '+' term(&term1) { *ip=plusmin(*ip,term1,'+'); }
  589. ]*
  590. ;
  591. term(int *ip;) { int fac1; }
  592. : factor(&fac1) { *ip = fac1; }
  593. [ '*' factor(&fac1) { *ip=muldiv(*ip,fac1,'*'); }
  594. | '\\' factor(&fac1) { *ip=muldiv(*ip,fac1,'\\'); }
  595. | '/' factor(&fac1) { *ip=muldiv(*ip,fac1,'/'); }
  596. | MODSYM factor(&fac1) { *ip=muldiv(*ip,fac1,MODSYM); }
  597. ]*
  598. ;
  599. factor(int *ip;)
  600. : '-' factor(ip) { *ip=negate(*ip); }
  601. | factor1(ip)
  602. ;
  603. factor1(int *ip;) { int mant,exp; }
  604. : factor2(&mant)
  605. [ /* empty */ { *ip = mant; }
  606. | '^' factor1(&exp) { *ip = power(mant,exp); }
  607. ]
  608. ;
  609. factor2(int *ip;)
  610. { int var,func,expl,funcc,exp,intv,funcn,inpt; int typetable[10]; }
  611. : INTVALUE { *ip=loadint(ival); }
  612. | '(' expression(&exp) ')' { *ip=exp; }
  613. | FLTVALUE { *ip=loaddbl(dval); }
  614. | STRVALUE
  615. { *ip= STRINGTYPE;
  616. loadstr(yylval.integer);
  617. }
  618. | variable(&var)
  619. { *ip=var;
  620. loadvar(var);
  621. }
  622. | INKEYSYM '$' { C_cal("_inkey");
  623. C_lfr((arith) BEMPTRSIZE);
  624. *ip= STRINGTYPE;
  625. }
  626. | VARPTR '(' '#' intvalue(&intv) ')'
  627. { warning("Not supported");
  628. *ip=INTTYPE;
  629. }
  630. | FUNCTION { func=yylval.integer; }
  631. [ %avoid /* empty */ { *ip= callfcn(yylval.integer,0, typetable); }
  632. | '(' cross exprlist(&expl, typetable) ')'
  633. { *ip=callfcn(func,expl, typetable); }
  634. ]
  635. | funcname(&funcn)
  636. [ %avoid /* empty */ { *ip=fcnend(0); }
  637. | funccall(&funcc) ')' { *ip=fcnend(funcc); }
  638. ]
  639. | MIDSYM '$' midparms
  640. {
  641. C_cal("_mid");
  642. C_asp((arith) (2*BEMINTSIZE+BEMPTRSIZE));
  643. C_lfr((arith) BEMPTRSIZE);
  644. *ip= STRINGTYPE;
  645. }
  646. | INPUTSYM '$' '(' expression(&exp) inputtail(&inpt)
  647. { /*waar worden inpt en exp gebruikt?*/
  648. C_cal("_inpfcn");
  649. C_asp((arith) (2*BEMINTSIZE+BEMPTRSIZE));
  650. *ip= STRINGTYPE;
  651. }
  652. ;
  653. inputtail(int *ip;) { int exp; }
  654. : ',' cross expression(&exp) ')'
  655. { conversion(exp,INTTYPE);
  656. *ip= INTTYPE;
  657. }
  658. | ')'
  659. { C_loc((arith) -1);
  660. *ip= INTTYPE;
  661. }
  662. ;
  663. funcname(int *ip;)
  664. : FUNCTID { *ip=fcncall(yylval.Sptr); }
  665. ;
  666. funccall(int *ip;) { int exp; }
  667. : '(' expression(&exp) { callparm(0,exp);*ip=1; }
  668. [ ',' expression(&exp) { callparm(*ip,exp);
  669. *ip = *ip+1;
  670. }
  671. ]*
  672. ;
  673. identifier(Symbol **ident;)
  674. : IDENTIFIER { dcltype(yylval.Sptr);
  675. *ident=yylval.Sptr;
  676. }
  677. ;
  678. exprlist(int *ip; int *typetable;) { int exp; }
  679. : expression(&exp) { typetable[0]=exp;
  680. *ip=1;
  681. }
  682. [ ',' expression(&exp) { typetable[*ip]=exp;
  683. *ip = *ip+1;
  684. }
  685. ]*
  686. ;
  687. {
  688. #ifndef NORCSID
  689. static char rcs_id[] = "$Id$" ;
  690. #endif
  691. }