Index: Singular/ChangeLog
===================================================================
--- Singular/ChangeLog	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/ChangeLog	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -1,2 +1,5 @@
+Thu Apr 15 19:26:07 MET DST 1999 hannes
+  * start to implement debugger (sdb.h,sdb.cc, febase*, iplib,cc, scanner)
+
 Tue Mar 16 15:54:02 MET 1999 hannes
   * introduced new routine ERROR(string) (iparith.cc, tok.h)
Index: Singular/Makefile.in
===================================================================
--- Singular/Makefile.in	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/Makefile.in	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -72,5 +72,5 @@
     comm.cc kstd1.cc kstd2.cc kutil.cc lists.cc \
     longalg.cc longrat.cc longrat0.cc \
-    maps.cc matpol.cc misc.cc \
+    maps.cc matpol.cc misc.cc sdb.cc \
     mminit.cc modulop.cc sparsmat.cc \
     fglm.cc fglmzero.cc fglmvec.cc fglmgauss.cc fglmhom.cc fglmcomb.cc \
@@ -94,5 +94,5 @@
 	numbers.h stype.h clapconv.h ipconv.h maps.h page.h \
 	subexpr.h clapsing.h ipid.h matpol.h polys.h syz.h \
-	cntrlc.h ipprint.h ring.h timer.h \
+	cntrlc.h ipprint.h ring.h timer.h sdb.h \
 	febase.h ipshell.h shortfl.h tok.h \
 	mmemory.h mmprivate.h mmheap.h mmpage.h page.h \
@@ -130,5 +130,5 @@
      mpsr_Error.o mpsr_Put.o mpsr_PutPoly.o mpsr_GetPoly.o \
      mpsr_Get.o mpsr_GetMisc.o ndbm.o spSpolyLoop.o libparse.o \
-     find_exec.o getopt.o fereadl.o  mod_raw.o \
+     find_exec.o getopt.o fereadl.o  mod_raw.o sdb.o \
 	pcv.o
 
@@ -343,5 +343,5 @@
      sing_mp.og fglm.og fglmzero.og fglmvec.og fglmgauss.og fglmhom.og\
      algmap.og clapconv.og  clapmem.og clapsing.og \
-     cntrlc.og  \
+     cntrlc.og  sdb.og\
      mpsr_Error.og mpsr_Put.og mpsr_PutPoly.og mpsr_GetPoly.og \
      mpsr_Get.og mpsr_GetMisc.og \
@@ -419,5 +419,5 @@
      sing_mp.op fglm.op fglmzero.op fglmvec.op fglmgauss.op fglmhom.op\
      algmap.op clapconv.op  clapmem.op clapsing.op \
-     cntrlc.op  \
+     cntrlc.op  sdb.op\
      mpsr_Error.op mpsr_Put.op mpsr_PutPoly.op mpsr_GetPoly.op \
      mpsr_Get.op mpsr_GetMisc.op \
@@ -445,5 +445,5 @@
      sing_mp.ob fglm.ob fglmzero.ob fglmvec.ob fglmgauss.ob fglmhom.ob\
      algmap.ob clapconv.ob  clapmem.ob clapsing.ob \
-     cntrlc.ob  \
+     cntrlc.ob  sdb.ob \
      mpsr_Error.ob mpsr_Put.ob mpsr_PutPoly.ob mpsr_GetPoly.ob \
      mpsr_Get.ob mpsr_GetMisc.ob \
Index: Singular/attrib.cc
===================================================================
--- Singular/attrib.cc	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/attrib.cc	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: attrib.cc,v 1.11 1999-03-16 15:33:04 Singular Exp $ */
+/* $Id: attrib.cc,v 1.12 1999-04-15 17:28:02 Singular Exp $ */
 
 /*
@@ -267,5 +267,5 @@
     procinfo *p=(procinfo *)v->Data();
     if (p->trace_flag!=0)
-      Print("trace:%d\n",p->trace_flag);
+      Print("TRACE:%d\n",p->trace_flag);
   }    
   if (hasFlag(v,FLAG_STD))
@@ -300,5 +300,5 @@
     res->data=(void *)(((ideal)v->Data())->rank);
   }
-  else if ((v->Typ()==PROC_CMD) && (strcmp(name,"trace")==0))
+  else if ((v->Typ()==PROC_CMD) && (strcmp(name,"TRACE")==0))
   {
     procinfo *p=(procinfo *)v->Data();
@@ -362,9 +362,9 @@
     I->rank=max(I->rank,(int)c->Data());
   }
-  else if ((strcmp(name,"trace")==0)&&(v->Typ()==PROC_CMD))
+  else if ((strcmp(name,"TRACE")==0)&&(v->Typ()==PROC_CMD))
   {
     if (c->Typ()!=INT_CMD)
     {
-      WerrorS("attrib `trace` must be int");
+      WerrorS("attrib `TRACE` must be int");
       return TRUE;
     }
Index: Singular/febase.inc
===================================================================
--- Singular/febase.inc	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/febase.inc	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -2,9 +2,12 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: febase.inc,v 1.20 1999-03-16 15:33:06 Singular Exp $ */
+/* $Id: febase.inc,v 1.21 1999-04-15 17:28:02 Singular Exp $ */
 /*
 * ABSTRACT: handling of 'voices'
 */
 #include <ctype.h>
+#include "sdb.h"
+
+extern int blocknest; /* scaner.l internal */
 
 int    yy_noeof=0;     // the scanner "state"
@@ -154,6 +157,4 @@
     case BT_if:
     case BT_else:
-                     yylineno = yy_blocklineno;
-                     break;
     case BT_break:
                      yylineno = yy_blocklineno-1;
@@ -401,5 +402,5 @@
       else
         Print("%s %3d%c ",currentVoice->filename,yylineno,prompt_char);
-    }
+     }
     #ifdef HAVE_TCL
     if(tclmode)
@@ -426,4 +427,10 @@
     Print("{%d}",yylineno);
     mflush();
+  }
+  if ((blocknest==0)
+  && (currentVoice->pi!=NULL)
+  && (currentVoice->pi->trace_flag&TRACE_BREAKPOINT))
+  {
+    sdb(currentVoice, anf, len_s);
   }
   prompt_char = '.';
Index: Singular/grammar.y
===================================================================
--- Singular/grammar.y	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/grammar.y	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: grammar.y,v 1.57 1999-03-19 14:17:58 obachman Exp $ */
+/* $Id: grammar.y,v 1.58 1999-04-15 17:28:03 Singular Exp $ */
 /*
 * ABSTRACT: SINGULAR shell grammatik
@@ -594,35 +594,39 @@
             if(iiExprArith3(&$$,$1,&$3,&$5,&$7)) YYERROR;
           }
+        | CMD_23 '(' expr ',' expr ')'
+          {
+            if(iiExprArith2(&$$,&$3,$1,&$5,TRUE)) YYERROR;
+          }
+        | CMD_23 '(' expr ',' expr ',' expr ')'
+          {
+            if(iiExprArith3(&$$,$1,&$3,&$5,&$7)) YYERROR;
+          }
+        | CMD_12 '(' expr ')'
+          {
+            if(iiExprArith1(&$$,&$3,$1)) YYERROR;
+          }
+        | CMD_12 '(' expr ',' expr ')'
+          {
+            if(iiExprArith2(&$$,&$3,$1,&$5,TRUE)) YYERROR;
+          }
+        | CMD_123 '(' expr ')'
+          {
+            if(iiExprArith1(&$$,&$3,$1)) YYERROR;
+          }
+        | CMD_123 '(' expr ',' expr ')'
+          {
+            if(iiExprArith2(&$$,&$3,$1,&$5,TRUE)) YYERROR;
+          }
+        | CMD_123 '(' expr ',' expr ',' expr ')'
+          {
+            if(iiExprArith3(&$$,$1,&$3,&$5,&$7)) YYERROR;
+          }
         | CMD_M '(' ')'
           {
             if(iiExprArithM(&$$,NULL,$1)) YYERROR;
           }
-        | CMD_23 '(' expr ',' expr ')'
-          {
-            if(iiExprArith2(&$$,&$3,$1,&$5,TRUE)) YYERROR;
-          }
-        | CMD_23 '(' expr ',' expr ',' expr ')'
-          {
-            if(iiExprArith3(&$$,$1,&$3,&$5,&$7)) YYERROR;
-          }
-        | CMD_12 '(' expr ')'
-          {
-            if(iiExprArith1(&$$,&$3,$1)) YYERROR;
-          }
-        | CMD_12 '(' expr ',' expr ')'
-          {
-            if(iiExprArith2(&$$,&$3,$1,&$5,TRUE)) YYERROR;
-          }
-        | CMD_123 '(' expr ')'
-          {
-            if(iiExprArith1(&$$,&$3,$1)) YYERROR;
-          }
-        | CMD_123 '(' expr ',' expr ')'
-          {
-            if(iiExprArith2(&$$,&$3,$1,&$5,TRUE)) YYERROR;
-          }
-        | CMD_123 '(' expr ',' expr ',' expr ')'
-          {
-            if(iiExprArith3(&$$,$1,&$3,&$5,&$7)) YYERROR;
+        | CMD_M '(' exprlist ')'
+          {
+            if(iiExprArithM(&$$,&$3,$1)) YYERROR;
           }
         | MATRIX_CMD '(' expr ',' expr ',' expr ')'
@@ -637,8 +641,4 @@
           {
             if(iiExprArith1(&$$,&$3,INTMAT_CMD)) YYERROR;
-          }
-        | CMD_M '(' exprlist ')'
-          {
-            if(iiExprArithM(&$$,&$3,$1)) YYERROR;
           }
         | quote_start expr quote_end
@@ -1553,7 +1553,4 @@
               if (currentVoice->ifsw!=2)
               {
-                char *s=$2+strlen($2)-1;
-                while ((*s=='\0')||(*s=='\n')) s--;
-                s[1]='\0';
                 Warn("`else` without `if` in level %d",myynest);
               }
Index: Singular/iplib.cc
===================================================================
--- Singular/iplib.cc	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/iplib.cc	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: iplib.cc,v 1.53 1999-04-01 10:09:58 krueger Exp $ */
+/* $Id: iplib.cc,v 1.54 1999-04-15 17:28:04 Singular Exp $ */
 /*
 * ABSTRACT: interpreter: LIB and help
@@ -245,4 +245,6 @@
   BOOLEAN err=FALSE;
   int old_echo=si_echo;
+  char save_flags=0;
+  procinfov pi=NULL;
 
   /* init febase ======================================== */
@@ -250,20 +252,16 @@
   if (pn!=NULL)
   {
-    procinfov pi;
     pi = IDPROC(pn);
     if(pi!=NULL)
     {
+      save_flags=pi->trace_flag;
       if( pi->data.s.body==NULL )
       {
-        iiGetLibProcBuffer(IDPROC(pn));
-        if (IDPROC(pn)->data.s.body==NULL) return TRUE;
+        iiGetLibProcBuffer(pi);
+        if (pi->data.s.body==NULL) return TRUE;
       }
-      newBuffer( mstrdup(IDPROC(pn)->data.s.body), BT_proc,
-                 pi, IDPROC(pn)->data.s.body_lineno );
-    }
-    //else
-    //{ // for security only
-    //  newBuffer( mstrdup(IDSTRING(pn)), BT_proc, IDID(pn) );
-    //}
+      newBuffer( mstrdup(pi->data.s.body), BT_proc,
+                 pi, pi->data.s.body_lineno-(v!=NULL) );
+    }
   }
   /* generate argument list ======================================*/
@@ -280,11 +278,10 @@
   /* start interpreter ======================================*/
   myynest++;
-  //Print("%-*.*s PStart <<%s>>, level:%d\n",2*myynest,2*myynest," ",IDID(pn),myynest);
   err=yyparse();
   killlocals(myynest);
   myynest--;
   si_echo=old_echo;
-  //Print("%-*.*s PEnd  <<%s>>, level:%d\n",2*myynest,2*myynest," ",IDID(pn),myynest);
-
+  if (pi!=NULL)
+    pi->trace_flag=save_flags;
   return err;
 }
@@ -628,7 +625,7 @@
   char libnamebuf[128];
   package pack = IDPACKAGE(packhdl);
-  
+
   if(pack->language == LANG_NONE) return FALSE;
-  
+
   FILE * fp = feFopen( pack->libname, "r", libnamebuf, FALSE);
   if (fp==NULL)
@@ -766,5 +763,5 @@
   LoadResult = iiLoadLIB(fp, libnamebuf, newlib, NULL, FALSE, tellerror);
 #endif /* HAVE_NAMESPACES */
-  
+
 #ifdef HAVE_NAMESPACES
   if(!LoadResult) IDPACKAGE(pl)->loaded = TRUE;
@@ -836,5 +833,5 @@
   fclose( yylpin );
   fp = NULL;
-  
+
 #ifdef HAVE_NAMESPACES
   namespaceroot->pop();
@@ -940,9 +937,9 @@
   int token;
   char FullName[256];
-  
+
   if( *fullname != '/' &&  *fullname != '.' )
     sprintf(FullName, "./%s", newlib);
   else strcpy(FullName, fullname);
-  
+
 
   if(IsCmd(plib, &token))
@@ -965,5 +962,5 @@
     {
       Warn("not of typ package.");
-      goto load_modules_end; 
+      goto load_modules_end;
     }
   }
@@ -974,5 +971,5 @@
     WerrorS("dynl_open failed");
     Werror("%s not found", newlib);
-    goto load_modules_end; 
+    goto load_modules_end;
   }
   else
@@ -988,5 +985,5 @@
   namespaceroot->pop();
   return RET;
-  
+
 }
 #endif /* HAVE_DYNAMIC_LOADING */
@@ -1144,5 +1141,5 @@
   FILE * fp = feFopen( newlib, "r", libnamebuf, FALSE );
   ret = stat(libnamebuf, &sb);
-  
+
   if (fp==NULL)
   {
@@ -1174,5 +1171,5 @@
   }
   if(isprint(buf[0]) || buf[0]=='\n') { LT = LT_SINGULAR; goto lib_type_end; }
-  
+
   lib_type_end:
   fclose(fp);
Index: Singular/ipshell.h
===================================================================
--- Singular/ipshell.h	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/ipshell.h	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -4,5 +4,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: ipshell.h,v 1.16 1999-03-11 15:58:07 Singular Exp $ */
+/* $Id: ipshell.h,v 1.17 1999-04-15 17:28:05 Singular Exp $ */
 /*
 * ABSTRACT
@@ -18,4 +18,6 @@
 #define TRACE_SHOW_RINGS  8
 #define TRACE_SHOW_LINE1  16
+#define TRACE_BREAKPOINT  32
+#define TRACE_TMP_BREAKPOINT  64
 extern leftv iiCurrArgs;
 extern int iiOp; /* the current operation*/
Index: Singular/scanner.l
===================================================================
--- Singular/scanner.l	(revision 1518b9cf23aa2598228863099857cedec82668c2)
+++ Singular/scanner.l	(revision 64d72907fdcd519d9718faa5bf9bae1e0153ec63)
@@ -3,5 +3,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: scanner.l,v 1.15 1999-03-19 17:42:33 obachman Exp $ */
+/* $Id: scanner.l,v 1.16 1999-04-15 17:28:06 Singular Exp $ */
 #include <stdio.h>
 #include <string.h>
@@ -19,5 +19,5 @@
 #define ALLOC(a) Alloc((a))
 int yylineno  = 0;
-static int blocknest = 0;
+int blocknest = 0;
 extern char * yytext;
 //extern unsigned char * yytext;
