2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 1984-2010 - INRIA - Serge STEER
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 /*--------------------------------------------------------------------------
13 * Scilab parsing function
15 * Code automatically translated from Fortran to C
16 *------------------------------------------------------------------ */
20 /*--------------------------------------------------------------------------*/
23 #include "core_math.h"
26 #include "scilabmode.h"
27 #include "stack-def.h" /* C2F(basbrk) */
29 #include "do_error_number.h"
31 #include "storeCommand.h"
34 #include "parserConstant.h"
35 #include "ExternalObjectsFunction.h"
36 /*--------------------------------------------------------------------------*/
39 /*--------------------------------------------------------------------------*/
41 /* Table of constant values */
46 #define Pt (C2F(recu).pt)
47 /*--------------------------------------------------------------------------*/
48 extern int C2F(clause)(void);
49 extern int C2F(fact)(void);
50 extern int C2F(expr)(void);
51 extern int C2F(terme)(void);
52 extern int C2F(stackp)(int *, int *);
53 extern int C2F(macro)(void);
54 extern int C2F(getsym)(void);
56 extern int C2F(bexec)(char *, int *, int *);
58 extern int C2F(findequal)(int *);
59 extern int C2F(print)(int *, int *, int *);
60 extern int C2F(createref1)(int *);
61 extern int C2F(command)(int *, int *);
62 extern int C2F(getlin)(int *, int *);
63 extern int C2F(mrknmd)(void);
64 extern int C2F(mkindx)(int *, int *);
65 extern int C2F(whatln)(int *, int *, int *, int *, int *, int *);
66 extern int C2F(prompt)(int *, int *);
67 extern int C2F(seteol)(void);
68 extern int C2F(run)(void);
69 extern int C2F(name2var)(int *);
70 extern int C2F(compil)(int *, int *, int *, int *, int *);
71 extern int C2F(ptover)(int *, int *); /* see src/fortran/ptover.f */
72 extern int C2F(eptover)(int *, int *); /* see src/fortran/eptover.f */
73 /*--------------------------------------------------------------------------*/
74 void handle_onprompt(int *n);
75 /*--------------------------------------------------------------------------*/
76 static int Compil(int code, int * val1, int val2, int val3, int val4)
78 return C2F(compil)(&code, val1, &val2, &val3, &val4);
80 /*--------------------------------------------------------------------------*/
84 return C2F(eptover)(&n, (c = psiz, &c));
86 /*--------------------------------------------------------------------------*/
90 return C2F(ptover)(&n, (c = psiz, &c));
92 /*--------------------------------------------------------------------------*/
95 /* Initialized data */
96 static int ans[6] = { 672929546, 673720360, 673720360, 673720360,
99 static int varargout[6] = { 169544223, 504893467, 673720349, 673720360,
102 /* static int catch[6] = {203229708,673720337,673720360,673720360, 673720360,673720360 };*/
104 static int *Ids = C2F(recu).ids - nsiz - 1;
105 static int *Rstk = C2F(recu).rstk - 1;
106 static int *Pstk = C2F(recu).pstk - 1;
107 static int *Lstk = C2F(vstk).lstk - 1;
108 static int *Lin = C2F(iop).lin - 1;
109 static int *Lct = C2F(iop).lct - 1;
110 static int *Lpt = C2F(iop).lpt - 1;
112 /* System generated locals */
115 /* Local variables */
116 static int iesc, ndel, ifin, ibpt;
119 static int lpts, next;
122 static int imode, schar;
123 static int itime, where_;
127 static int id[6], lb, io, ir;
130 static int nentry, lastindpos;
131 static int job, nlc, pts;
134 /* Used to manage space between prompts */
135 static int returnFromCallbackExec = FALSE;
137 /* Retrieve the current Scilab Mode */
138 /* scilabMode sciMode=getScilabMode();*/
147 if (C2F(iop).ddt == 4)
149 sprintf(tmp, " TOP pt:%d rstk(pt):%d icall: %d niv: %d err:%d",
150 Pt, Rstk[Pt], C2F(recu).icall, C2F(recu).niv, Err);
151 C2F(basout)(&io, &C2F(iop).wte, tmp, (long)strlen(tmp));
154 if (C2F(recu).icall == 5)
167 /* ------------------- */
171 if (C2F(iop).rio == -1)
180 C2F(iop).rio = C2F(iop).rte;
190 if (C2F(com).sym != eol)
194 if (C2F(com).comp[0] == 0)
198 if (Lin[Lpt[4] + 1] == eol)
204 /* ------------------- */
208 Lct[4] = -Lct[4] - 11;
212 if (Lct[4] / 2 % 2 == 1)
215 /* Manage space between two prompts */
216 if (!returnFromCallbackExec)
218 /* Space added only if Scilab does not return from a callback execution */
219 C2F(prompt)(&i__2, &iesc);
223 /* Reset the flag indicating a callback has just been executed */
224 returnFromCallbackExec = FALSE;
228 /* interrupted line acquisition (mode=7) */
233 if (C2F(recu).paus == 0 &&
234 C2F(iop).rio == C2F(iop).rte &&
251 //C2F(tksynchro)(&C2F(recu).paus);
253 C2F(getlin)(&job, &c__1);
255 ClearTemporaryPrompt();
256 //C2F(tksynchro)(&c_n1);
261 /* interrupted line acquisition */
267 /* Continuation line handling when scilab is called as a routine */
279 handle_onprompt(&where_);
291 /* Beginning of a new statement, clause expression or command */
292 /* ------------------------------------------------------------ */
294 if (ismenu() == 1 && C2F(basbrk).interruptible)
305 if (C2F(iop).ddt == 4)
307 sprintf(tmp, " parse pt:%d rstk(pt):%d top: %d niv: %d err:%d",
308 Pt, r, Top, C2F(recu).niv, Err);
309 C2F(basout)(&io, &C2F(iop).wte, tmp, (long)strlen(tmp));
313 if (! C2F(basbrk).iflag || C2F(com).comp[0] != 0 )
317 /* Handling of pauses */
323 Pstk[Pt] = C2F(iop).rio;
324 Ids[2 + Pt * nsiz] = Top;
325 C2F(iop).rio = C2F(iop).rte;
327 C2F(basbrk).iflag = FALSE;
332 Lct[4] = -Lct[4] - 11;
336 /* pauses termination */
338 C2F(iop).rio = Pstk[Pt];
339 Top = Ids[2 + Pt * nsiz];
346 /* preserve current character position */
351 if (C2F(com).sym == right || C2F(com).sym == rparen || C2F(com).sym == less ||
352 C2F(com).sym == great)
354 /* Incorrect assignment. */
358 else if (C2F(com).sym == semi || C2F(com).sym == comma || C2F(com).sym == eol)
362 else if (C2F(com).sym == cmt)
367 else if (C2F(com).sym == name)
370 /* try to avoid the command call whenever it is possible */
371 if (C2F(com).char1 == equal)
375 /* if (char1 .eq. lparen) then */
376 /* one can get this case with "if ( ) then" */
380 if (Lin[Lpt[4] - 2] == blank)
385 if (C2F(com).char1 == dot)
388 schar = C2F(com).char1;
393 else if (C2F(com).sym == left)
395 /* is there an explicit affectation */
399 C2F(com).char1 = blank;
400 C2F(findequal)(&found);
412 /* no ==> implicit lhs */
418 /* not lhs defined */
419 /* set ans for lhs */
424 C2F(putid)(&Ids[1 + Pt * nsiz], ans);
427 /* go to rhs analysis */
431 /* lhs begins with name */
432 /* ------------------------- */
433 /* check if it is a simple command like clear,... */
435 C2F(command)(C2F(com).syn, &c__0);
444 if (C2F(com).fun == 99)
448 if (C2F(com).fun != 0)
472 /* name is not a command */
476 /* IL y a p avec fin=-5 (on ne trouve pas les macros parce que l'on ne */
477 /* veut pas que les macros sans arg soient vues comme des commandes */
478 /* mais pourquoi pas il suffirait de dire que pour visualiser une macro */
479 /* il faut faire disp() */
481 C2F(funs)(C2F(com).syn);
484 /* name is a builtin name */
485 if (C2F(com).char1 == equal)
487 /* fun=expr is not allowed */
488 C2F(putid)(&Ids[1 + (Pt + 1) * nsiz], C2F(com).syn);
489 /* Bad call to primitive */
493 /* skip lhs analysis */
498 C2F(putid)(&Ids[1 + Pt * nsiz], id);
501 /* go to rhs analysis */
505 /* peek one character ahead */
506 if (C2F(com).char1 == semi || C2F(com).char1 == comma || C2F(com).char1 == eol)
508 C2F(putid)(id, C2F(com).syn);
510 if (C2F(com).char1 == lparen)
512 schar = C2F(com).char1;
515 /* instruction is just "name", skip lhs analysis */
516 /* record name as lhs */
521 C2F(putid)(&Ids[1 + Pt * nsiz], id);
524 /* go to rhs analysis */
527 /* name = expr or name == expr syntax */
528 /* ---------------------------------------- */
530 C2F(putid)(id, C2F(com).syn);
533 if (C2F(com).char1 == equal)
535 /* name == expr syntax ==> implicit lhs */
546 C2F(putid)(&Ids[1 + Pt * nsiz], id);
550 /* go to rhs analysis */
554 /* lhs is name(...) or name.x... */
555 /* ----------------------------------- */
558 C2F(putid)(id, C2F(com).syn);
560 /* looking for equal to check if it is really an lhs */
561 C2F(findequal)(&found);
570 /* It is really a lhs (insertion syntax) */
573 C2F(com).char1 = schar;
575 /* 35 call parseindexlist(excnt) */
576 /* if(err.gt.0) goto 98 */
577 if (Compil(21, &c__0, 0, 0, 0))
584 /* begin the index lists */
589 /* begin a new index list (.,..) or .name */
592 dotsep = C2F(com).sym == dot;
596 /* --> new index list is .name */
597 if (C2F(com).sym != name)
607 if (C2F(com).comp[0] != 0)
609 if (Compil(23, C2F(com).syn, 0, 0, 0))
619 C2F(name2var)(C2F(com).syn);
622 /* icount=icount+1 */
623 if (C2F(com).sym == dot)
631 /* --> new index list is (.,..) */
633 /* add a new index in index list (i,...) */
639 C2F(putid)(&Ids[1 + Pt * nsiz], id);
640 Pstk[Pt] = excnt + icount * 1000;
645 C2F(putid)(id, &Ids[1 + Pt * nsiz]);
646 icount = Pstk[Pt] / 1000;
647 excnt = Pstk[Pt] - icount * 1000;
650 if (C2F(com).sym == comma)
652 /* current syntax is (i,j,..) */
657 if (C2F(com).sym == rparen)
659 /* end of the current index list */
664 /* Waiting for right parenthesis */
673 if (C2F(com).sym == lparen || C2F(com).sym == dot)
675 /* begining of a new index list */
676 /* first memorize the previous one */
679 /* previously analysed syntax is (i,j,..)( */
680 if (C2F(com).comp[0] == 0)
682 /* form list with individual indexes i,j,.. */
683 C2F(mkindx)(&c__0, &excnt);
691 if (Compil(19, &c__0, excnt, 0, 0))
701 /* open a new index list */
703 /* icount=icount+1 */
706 /* end of all the index lists */
709 /* form list with individual indexes */
710 if (C2F(com).comp[0] == 0)
712 C2F(mkindx)(&icount, &excnt);
720 if (Compil(19, &icount, excnt, 0, 0))
730 /* end of code for recursive index */
736 if (C2F(com).sym == equal)
738 /* name(...) = expr syntax */
739 /* record name as lhs */
744 C2F(putid)(&Ids[1 + Pt * nsiz], id);
748 /* go to rhs analysis */
753 /* this should never happen. this case has been detected above */
754 /* when lookin for equal sign */
755 /* name(...) syntax ==> really an rhs */
760 C2F(putid)(&Ids[1 + Pt * nsiz], ans);
766 /* multiple lhs [a,...]= or [a(..),..] */
767 /* ---------------------------------------- */
771 C2F(com).char1 = blank;
774 /* start lhs arguments list */
777 /* begin analysis of a new lhs argument */
778 if (C2F(com).sym != name)
780 /* Instruction left hand side: waiting for a name */
784 if (C2F(eqid)(C2F(com).syn, varargout))
786 /* varargout keyword cannot be used here */
790 C2F(putid)(id, C2F(com).syn);
792 next = Lin[Lpt[4] - 2];
793 if (next == blank || C2F(com).char1 == comma || C2F(com).char1 == right)
795 /* argument followed by a blank, a comma or a ] ==> it is a simple name */
799 else if (C2F(com).char1 != lparen && C2F(com).char1 != dot)
805 /* lhs argument is name(..) or name.xx */
812 schar = C2F(com).char1;
819 /* record current lhs arg */
824 C2F(putid)(&Ids[1 + Pt * nsiz], id);
828 /* end analysis of a current lhs arg */
829 if (C2F(com).sym == right)
833 if (C2F(com).sym == comma)
837 /* loop on lhs args */
842 if (C2F(com).sym == equal && C2F(com).char1 != equal)
844 /* really found a lhs go to the rhs analysis part */
848 /* lhs revealed to be an rhs */
849 /* ------------------------------------- */
851 /* no equal symbol */
854 /* lhs is in fact an rhs */
855 /* 1 - reinititialise the parser at the instruction beginning */
859 C2F(com).char1 = blank;
862 /* if(sym.eq.comma.or.sym.eq.semi) goto 52 */
863 /* 2 - make "ans" the lhs */
868 C2F(putid)(&Ids[1 + Pt * nsiz], ans);
871 /* 3 - go to the rhs analysis part */
874 /* lhs finished, start rhs */
875 /* ---------------------------- */
881 if (Rstk[Pt - Lhs] == 313)
883 /* store new variable as "named" at the top of the stack */
884 if (C2F(com).sym == rparen || C2F(com).sym == comma)
895 /* Waiting for end of command. */
900 if (C2F(com).sym == semi || C2F(com).sym == comma || C2F(com).sym == eol || C2F(com).sym == cmt)
904 if (Rstk[Pt - Lhs] == 808) /* syntax error while in try */
906 /* set back the standard error handling ++++*/
908 C2F(errgst).errct = Ids[2 + Pt * nsiz];
909 C2F(errgst).errpt = Ids[5 + Pt * nsiz];
910 /* forgot the catch error */
911 C2F(errgst).err1 = Ids[3 + Pt * nsiz];
912 C2F(errgst).err2 = Ids[4 + Pt * nsiz];
913 C2F(com).comp[0] = 0;
915 /* Missing operator, comma, or semicolon. */
923 /* Missing operator, comma, or semicolon. */
929 /* ------------------- */
932 if (Compil(29, &(Lhs), C2F(com).sym, 0, 0))
945 lastindpos = Top - Lhs - ndel;
946 if (C2F(errgst).err1 != 0)
952 /* goto simple affectation */
953 C2F(stackp)(&Ids[1 + Pt * nsiz], &c__0);
958 if (C2F(errgst).err1 > 0)
960 if (C2F(errgst).err1 != 13 || Rstk[Pt] != 502)
967 /* topk points on the newly saved variable */
972 /* partial variable affectation (insertion) */
973 if (lastindpos + 1 != Top)
975 /* create reference variables to get index1,...,indexn, value at */
976 /* the top of the stack in this order */
977 /* create reference variables pointing to the indices */
979 for (ir = 1; ir <= i__2; ++ir)
981 i__3 = lastindpos - Rhs + ir;
982 C2F(createref1)(&i__3);
984 /* create reference variable pointing to the value */
986 C2F(createref1)(&i__2);
987 /* remind to remove the original indices */
991 /* put a reference to the lhs variable */
993 C2F(stackg)(&Ids[1 + Pt * nsiz]);
998 /* perform insertion operation */
999 /* index1,...,indexn, value ==> updated lhs value (or pointer to) */
1005 C2F(putid)(&Ids[1 + Pt * nsiz], &Ids[1 + (Pt - 1) * nsiz]);
1006 Ids[1 + (Pt - 1) * nsiz] = ndel;
1007 Ids[2 + (Pt - 1) * nsiz] = lastindpos;
1012 /* *call* allops(insert) */
1016 ndel = Ids[1 + (Pt - 1) * nsiz];
1017 lastindpos = Ids[2 + (Pt - 1) * nsiz];
1018 C2F(putid)(&Ids[1 + (Pt - 1) * nsiz], &Ids[1 + Pt * nsiz]);
1020 /* store the updated value */
1021 C2F(stackp)(&Ids[1 + Pt * nsiz], &c__0);
1026 if (C2F(errgst).err1 > 0)
1032 /* topk points on the newly saved variable */
1034 /* remove variable containing the value if required */
1035 if (lastindpos != Top)
1040 /* print if required */
1041 /* ---------------------- */
1042 if (Lct[4] < 0 || Fin == 0)
1046 if (! ((C2F(com).sym != semi && Lct[3] == 0) || (C2F(com).sym == semi &&
1052 C2F(print)(&Ids[1 + Pt * nsiz], &topk, &C2F(iop).wte);
1061 /* overloaded display, call a macro */
1067 Pstk[Pt] = C2F(com).sym;
1068 Ids[1 + Pt * nsiz] = C2F(com).sym;
1069 Ids[2 + Pt * nsiz] = ndel;
1070 Ids[3 + Pt * nsiz] = Lhs;
1071 if (C2F(com).fun == 0)
1077 C2F(com).sym = Pstk[Pt];
1078 ndel = Ids[2 + Pt * nsiz];
1079 Lhs = Ids[3 + Pt * nsiz];
1092 /* finish statement */
1093 /* --------------------- */
1106 if (C2F(iop).ddt == 4)
1108 sprintf(tmp, " finish pt:%d rstk(pt):%d pstk(pt):%d lpt(1): %d niv: %d macr:%d, paus:%d",
1109 Pt, r, p, Lpt[1], C2F(recu).niv, C2F(recu).macr, C2F(recu).paus);
1110 C2F(basout)(&io, &C2F(iop).wte, tmp, (long)strlen(tmp));
1113 ExternalObjects_goDown();
1115 if (C2F(errgst).err1 != 0)
1117 /* a catched error has occurred */
1120 /* in try instructions */
1123 else if (Ids[1 + (Pt - 1) * nsiz] != 0)
1125 /* execution is explicitly required to be stopped */
1126 if (r == 502 && Rstk[Pt - 1] == 903)
1128 /* in an execstr(...,'errcatch') instruction */
1131 else if (r == 502 && Rstk[Pt - 1] == 909)
1133 /* in an exec(function,'errcatch') instruction */
1136 else if (r == 503 && Rstk[Pt - 1] == 902)
1138 /* in an exec(file,'errcatch') instruction */
1142 if (C2F(errgst).err2 == 0)
1144 C2F(errgst).err2 = C2F(errgst).err1;
1146 if (C2F(errgst).errcatch > 0)
1148 /* running under errcatch(num,....) */
1149 C2F(errgst).err1 = 0;
1150 if (Pt < C2F(errgst).errpt)
1152 C2F(errgst).errcatch = 0;
1156 imode = (i__2 = C2F(errgst).errct / 100000, abs(i__2));
1157 if (imode - (imode / 8 << 3) == 2)
1159 C2F(basbrk).iflag = TRUE;
1163 C2F(errgst).toperr = Top;
1164 /* fin instruction */
1165 if (C2F(com).sym != eol)
1167 if (C2F(com).sym == cmt)
1169 C2F(parsecomment)();
1177 /* gestion des points d'arrets dynamiques */
1178 if (C2F(dbg).nmacs != 0) /* there are breakpoints set */
1180 int kfin = C2F(dbg).wmac - 1; /*the stack index of the current function*/
1181 /* first test if the function has breakpoints */
1184 for (kmac = 0; kmac < C2F(dbg).nmacs; kmac++) /* loop on table of functions containing breakpoints */
1186 /* does the name of the current function fit the registered name*/
1187 if (C2F(eqid)(&(C2F(vstk).idstk[kfin * nsiz]), &(C2F(dbg).macnms[kmac * nsiz]))) /* yes */
1189 /* test if there is a registered breakpoint at the current line*/
1191 C2F(whatln)(&Lpt[1], &i__2, &Lpt[6], &nlc, &l1, &ifin);
1192 i__2 = C2F(dbg).lgptrs[kmac + 1] - 1;
1193 curline = Lct[8] - nlc - 1;
1194 for (ibpt = C2F(dbg).lgptrs[kmac]; ibpt <= i__2; ++ibpt)
1196 //sciprint("la Lct[8]-nlc =%d, bptlg=%d\n",Lct[8] - nlc,C2F(dbg).bptlg[ibpt - 1]);
1197 if (curline == C2F(dbg).bptlg[ibpt - 1]) /* yes */
1199 /* display a message */
1200 C2F(cvname)(&C2F(dbg).macnms[kmac * nsiz], tmp, &c__1, nlgh);
1201 sprintf(C2F(cha1).buf, "%s %5d", tmp, curline);
1203 /* raise the interruption flag */
1204 C2F(basbrk).iflag = TRUE;
1214 if (C2F(com).comp[0] != 0)
1223 /* end of an instruction or a clause */
1224 if (C2F(com).comp[0] != 0)
1227 if (Lin[k - 1] == eol && Lin[k] == eol)
1229 /* end or else is missing... */
1234 if (Lpt[4] == Lpt[6])
1236 /* call getlin(1,0) */
1246 /* simulate recursion */
1247 /* ----------------------- */
1249 C2F(recu).icall = 0;
1255 switch ((int)C2F(recu).icall)
1305 C2F(recu).icall = 0;
1311 switch ((int)C2F(recu).icall)
1357 C2F(recu).icall = 0;
1363 switch ((int)C2F(recu).icall)
1409 C2F(recu).icall = 0;
1415 switch ((int)C2F(recu).icall)
1461 C2F(recu).icall = 0;
1462 if (C2F(com).fun == C2F(recu).krec)
1464 if (C2F(com).fun > 0)
1466 /* Recursion problems. Sorry */
1471 if (C2F(errgst).err1 != 0)
1473 if (Rstk[Pt] / 100 == 9)
1475 if (Rstk[Pt] >= 901 && Rstk[Pt] <= 909)
1491 /* compilation matfns: <100*fun rhs lhs fin> */
1492 if (Compil( C2F(com).fun * 100, &(Rhs), Lhs, Fin, 0))
1510 switch ((int)C2F(recu).icall)
1556 C2F(recu).icall = 0;
1562 switch ((int)C2F(recu).icall)
1614 C2F(recu).icall = 0;
1620 if (C2F(com).fun == 99)
1624 /* last label is used to handle return from abort */
1625 switch ((int)C2F(recu).icall)
1675 C2F(recu).icall = 0;
1681 switch ((int)C2F(recu).icall)
1727 switch ((int)(Rstk[Pt] - 700))
1753 /* command like function and macro call */
1754 /* store ans as lhs */
1759 C2F(putid)(&Ids[1 + Pt * nsiz], ans);
1763 if (C2F(com).fun > 0)
1770 if (C2F(com).comp[0] != 0)
1774 /* *call* allops(extrac) */
1779 Fin = Lstk[C2F(com).fin];
1785 /* go to store code */
1789 /* asynchronous events handling */
1790 C2F(basbrk).interruptible = C2F(getmen)(C2F(cha1).buf, &lb, &nentry) == 0;
1791 C2F(bexec)(C2F(cha1).buf, &lb, &ierr);
1802 Ids[1 + Pt * nsiz] = iret;
1806 /* Rstk[Pt] == 706 indicates we return from a callback execution */
1807 if (Rstk[Pt] == 706)
1809 returnFromCallbackExec = TRUE;
1813 C2F(basbrk).interruptible = TRUE;
1814 iret = Ids[1 + Pt * nsiz];
1822 if (Lpt[6] == Lpt[1])
1828 /* go ahead with interrupted continuation line */
1844 C2F(basbrk).interruptible = TRUE;
1845 /* error recovery */
1846 /* ------------------- */
1847 imode = abs(C2F(errgst).errct) / 100000;
1848 imode -= imode / 8 << 3;
1855 /* error in an external (niv), during compilation (comp) or in a pause */
1858 if (Rstk[Pt] == 503 && C2F(iop).rio == C2F(iop).rte)
1860 C2F(com).comp[0] = 0;
1863 if (C2F(errgst).err1 != 0 && Rstk[Pt] == 502) /* catched error while compiling */
1867 if (C2F(errgst).err1 != 0 && Rstk[Pt] == 808) /* catched error in a try */
1873 if (C2F(recu).niv > 0) /* error in an external */
1878 else if (C2F(recu).paus > 0) /* error in a pause */
1880 C2F(com).comp[0] = 0;
1886 C2F(errgst).errct = -1;
1887 C2F(errgst).errpt = 0;
1888 C2F(com).comp[0] = 0;
1893 C2F(com).comp[0] = 0;
1898 /* Recursion problems. Sorry */
1903 /*--------------------------------------------------------------------------*/
1905 * checks if an implicit execution is required on the prompt
1906 * @param where_ returned indicator
1907 * where_ = 0 : no implicit execution is required
1908 * where_ = 1 : implicit execution is a primitive
1909 * where_ = 2 : implicit execution is a Scilab function
1911 void handle_onprompt(int *where_)
1913 /* Initialized data */
1914 /* onprompt[6] internal scilab code for %onprompt variable see C2F(cvname) */
1915 static int onprompt[6] = {420943928, 420878363, 673720349, 673720360, 673720360, 673720360 };
1917 static int *Rstk = C2F(recu).rstk - 1;
1918 static int *Pstk = C2F(recu).pstk - 1;
1919 static int *Lstk = C2F(vstk).lstk - 1;
1924 /* back from %onprompt */
1925 C2F(errgst).errct = Pstk[Pt];
1927 C2F(errgst).err2 = 0;
1934 /* on prompt implicit execution */
1936 C2F(funs)(onprompt);
1941 if (C2F(com).fun <= 0 && Fin == 0)
1945 /* %onprompt function exists */
1949 Pstk[Pt] = C2F(errgst).errct;
1951 /* set error catch with mode continue */
1952 C2F(errgst).errct = -100001;
1953 C2F(errgst).errpt = 1;
1954 if (C2F(com).fun > 0)
1956 /* %onprompt is a primitive *call* matfns */
1961 /* %onprompt is a Scilab function *call* macro */
1962 C2F(com).fin = Lstk[Fin];
1967 /*--------------------------------------------------------------------------*/
1968 void C2F(parsecomment)(void)
1971 static int *Lstk = C2F(vstk).lstk - 1;
1972 static int *Lin = C2F(iop).lin - 1;
1973 static int *Lpt = C2F(iop).lpt - 1;
1974 static int *Comp = C2F(com).comp - 1;
1977 static int l, ll, lkp, l0, c1 = 1;
1980 if ( (Lin[l0] == slash) && (Lin[l0 - 1] == slash) & (Lin[l0 + 1] == eol))
1986 while (Lin[l] != eol)
1993 /* ignore all characters up to the end */
1997 /* compilation [30 number-of-char chars-vector] */
1998 lkp = C2F(com).comp[0];
1999 Err = (lkp + 2 + ll) / 2 + 1 - Lstk[Bot];
2002 /* Display the stack information */
2007 *istk(lkp + 1) = ll;
2008 C2F(icopy)(&ll, &(Lin[l0]), &c1, istk(lkp + 2), &c1);
2009 Comp[1] = lkp + 2 + ll;
2012 C2F(com).char1 = eol;
2016 /*--------------------------------------------------------------------------*/