basic.g 17 KB

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