Index: modules/tools/misc.cc
===================================================================
--- modules/tools/misc.cc	(revision 740e1f7291b169d818475089a70366a328feb8d1)
+++ modules/tools/misc.cc	(revision 6c87725945caa48b135d716568d9cf8b968ba527)
@@ -2,5 +2,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: misc.cc,v 1.4 1999-03-24 13:04:20 krueger Exp $ */
+/* $Id: misc.cc,v 1.5 1999-03-31 22:03:22 krueger Exp $ */
 /*
 * ABSTRACT: lib parsing
@@ -28,5 +28,5 @@
 #define SYSTYP_HPUX10 3
 
-#if 0
+#if 1
 #  define logx printf
 #else
@@ -75,4 +75,11 @@
   if( strcmp(n, "SELF") == 0) {
     tok = SELF_CMD;
+    logx("IsCmd: [%d] %s\n", tok, n);
+    return tok;
+  }
+  
+  if( strcmp(n, "none") == 0) {
+    tok = NONE;
+    logx("IsCmd: [%d] %s\n", tok, n);
     return tok;
   }
@@ -225,5 +232,6 @@
   }
   module->revision = (char *)malloc(strlen(libnamebuf)+1);
-  strcpy(module->revision, libnamebuf);
+  memset(module->revision, '\0', strlen(libnamebuf)+1);
+  memcpy(module->revision, libnamebuf, strlen(libnamebuf));
 }
 
@@ -257,5 +265,4 @@
 
 /*========================================================================*/
-/*  procdefv Add2proclist(procdefv pi, char *name)*/
 void Add2proclist(
   moddefv module,
@@ -270,15 +277,20 @@
   
   memset((void *)&pnew, '\0', sizeof(procdef));
+
   pnew.procname = (char *)malloc(strlen(name)+1);
   if(pnew.procname==NULL) printf("Error 1\n");
+  memset(pnew.procname, '\0', strlen(name)+1);
+  memcpy(pnew.procname, name, strlen(name));
+
   pnew.funcname = (char *)malloc(strlen(name)+1);
+  if(pnew.funcname==NULL) printf("Error 1\n");
   memset(pnew.funcname, '\0', strlen(name)+1);
-  memset(pnew.procname, '\0', strlen(name)+1);
+  memcpy(pnew.funcname, name, strlen(name));
+
   pnew.param = NULL;
   (pnew).is_static = 0;
   (pnew).paramcnt = 0;
-  strcpy(pnew.procname, name);
-  strcpy(pnew.funcname, name);
-
+  pnew.c_code = NULL;
+  
   pnew.return_val.name = (char *)malloc(strlen(ret_val)+1);
   memset(pnew.return_val.name, '\0', strlen(ret_val)+1);
@@ -442,4 +454,23 @@
 }
 
+void gen_func_param_check(
+  FILE *fp,
+  procdefv pi,
+  int i
+  )
+{
+  fprintf(fp, "  if(v==NULL) goto mod_%s_error;\n", pi->funcname);
+  fprintf(fp, "  tok = v->Typ();\n");
+  fprintf(fp, "  if((index=iiTestConvert(tok, %s))==0)\n",
+          pi->param[i].typname);
+  fprintf(fp, "     goto mod_%s_error;\n", pi->funcname);
+  fprintf(fp, "  v_save = v->next;\n");
+  fprintf(fp, "  v->next = NULL;\n");
+  fprintf(fp, "  if(iiConvert(tok, %s, index, v, res%d))\n",
+          pi->param[i].typname, i);
+  fprintf(fp, "     goto mod_%s_error;\n", pi->funcname);
+  fprintf(fp, "  v = v_save;\n");
+}
+
 void generate_function(procdefv pi, FILE *fp)
 {
@@ -450,9 +481,11 @@
   if(pi->paramcnt>0) {
     if(pi->param[0].typ==SELF_CMD) {
+      if(pi->c_code != NULL) fprintf(fp, "%s\n", pi->c_code);
+  
       fprintf(fp, "  return(%s(res,h));\n", pi->funcname);
       fprintf(fp, "}\n\n");
     }
     else {
-      fprintf(fp, "  leftv v = h;\n");
+      fprintf(fp, "  leftv v = h, v_save;\n");
       fprintf(fp, "  int tok = NONE, index = 0;\n");
       for (i=0;i<pi->paramcnt; i++)
@@ -461,22 +494,10 @@
       fprintf(fp, "\n");
     
-      for (i=0;i<pi->paramcnt; i++) {
-        fprintf(fp, "  if(v==NULL) goto mod_%s_error;\n", pi->funcname);
-        fprintf(fp, "  tok = v->Typ();\n");
-        fprintf(fp, "  printf(\"test %d.1\\n\");\n", i);
-        fprintf(fp, "  if((index=iiTestConvert(tok, %s))==0)\n",
-                pi->param[i].typname);
-        logx("==>'%s'\n", pi->param[i].typname);
-        fprintf(fp, "     goto mod_%s_error;\n", pi->funcname);
-        fprintf(fp, "  printf(\"test %d.2\\n\");\n", i);
-        fprintf(fp, "  if(iiConvert(tok, %s, index, v, res%d))\n",
-                pi->param[i].typname, cnt);
-        fprintf(fp, "     goto mod_%s_error;\n", pi->funcname);
-        fprintf(fp, "  printf(\"test %d.3\\n\");\n", i);
-        fprintf(fp, "  v = v->next;\n");
-      }
+      if(pi->c_code != NULL) fprintf(fp, "%s\n", pi->c_code);
+  
+      for (i=0;i<pi->paramcnt; i++) gen_func_param_check(fp, pi, i);
+
       fprintf(fp, "  if(v!=NULL) { tok = v->Typ(); goto mod_%s_error; }\n",
               pi->funcname);
-      fprintf(fp, "  printf(\"test before return\\n\");\n");
 
       fprintf(fp, "\n");
@@ -513,5 +534,22 @@
     }
   } else {
-      fprintf(fp, "  return(%s(res));\n}\n\n", pi->funcname);
+      switch( pi->return_val.typ) {
+          case SELF_CMD:
+            fprintf(fp, "  return(%s(res));\n}\n\n", pi->funcname);
+           break;
+
+          case NONE:
+            fprintf(fp, "  res->rtyp = %s;\n", pi->return_val.typname);
+            fprintf(fp, "  res->data = NULL;\n");
+            fprintf(fp, "  %s();\n", pi->funcname);
+            fprintf(fp, "  return FALSE;\n}\n\n");
+            break;
+            
+          default:
+            fprintf(fp, "  res->rtyp = %s;\n", pi->return_val.typname);
+            fprintf(fp, "  res->data = (void *)%s();\n", pi->funcname);
+            fprintf(fp, "  return FALSE;\n}\n\n");
+      }
+    
   }
       
@@ -613,5 +651,5 @@
   fprintf(fp, "CC\t= gcc\n");
   fprintf(fp, "CXX\t= gcc\n");
-  fprintf(fp, "CFLAGS\t= -DNDEBUG -I. -I../include\n");
+  fprintf(fp, "CFLAGS\t= -DNDEBUG -DBUILD_MODULE -I. -I../include\n");
   fprintf(fp, "#LD\t=\n");
   fprintf(fp, "\n");
Index: modules/tools/modgen.h
===================================================================
--- modules/tools/modgen.h	(revision 740e1f7291b169d818475089a70366a328feb8d1)
+++ modules/tools/modgen.h	(revision 6c87725945caa48b135d716568d9cf8b968ba527)
@@ -1,4 +1,4 @@
 /*
- *  $Id: modgen.h,v 1.3 1999-03-24 13:04:21 krueger Exp $
+ *  $Id: modgen.h,v 1.4 1999-03-31 22:03:23 krueger Exp $
  *
  */
@@ -37,4 +37,5 @@
   paramdefv param;
   int       paramcnt;
+  char *c_code;
 };
 
Index: modules/tools/scanner.l
===================================================================
--- modules/tools/scanner.l	(revision 740e1f7291b169d818475089a70366a328feb8d1)
+++ modules/tools/scanner.l	(revision 6c87725945caa48b135d716568d9cf8b968ba527)
@@ -3,5 +3,5 @@
 *  Computer Algebra System SINGULAR     *
 ****************************************/
-/* $Id: scanner.l,v 1.3 1999-03-24 13:04:21 krueger Exp $ */
+/* $Id: scanner.l,v 1.4 1999-03-31 22:03:23 krueger Exp $ */
 #include <stdio.h>
 #include <string.h>
@@ -20,7 +20,31 @@
 #include <tok.h>
 
+#define DEBUG 0
+ 
+#  define YYLP_ERR_NONE    0
+#  define YYLP_DEF_BR2     1
+#  define YYLP_BODY_BR2    2
+#  define YYLP_BODY_BR3    3
+#  define YYLP_BODY_TMBR2  4
+#  define YYLP_BODY_TMBR3  5
+#  define YYLP_EX_BR2      6
+#  define YYLP_EX_BR3      7
+#  define YYLP_BAD_CHAR    8
+#  define YYLP_MISSQUOT    9
+#  define YYLP_MISS_BR1   10
+#  define YYLP_MISS_BR2   11
+#  define YYLP_MISS_BR3   12
+
 const char sNoName[]="_";
-char       my_yylinebuf[80];
-int old_state = 0;
+int brace1 = 0;  /* { } */
+int brace2 = 0;  /* ( ) */
+int brace3 = 0;  /* [ ] */
+int quote  = 0;  /* " */
+int offset = 0;
+
+ char       my_yylinebuf[80];
+int *old_states = NULL;
+int state_level = -1;
+int state_max = 0;
 int yylineno = 1;
 int tok;
@@ -28,4 +52,36 @@
 int  traceit = 0;
 moddef module_def;
+ int yylplineno = 1;
+ int yylp_errno = 0;
+
+ long C_start;
+ long C_end;
+ char c_codetype = 0;
+#define C_CODE_NONE 0
+#define C_CODE_PROC 1
+#define C_CODE_MAIN 2
+ 
+ char string_type = 0;
+#define STRING_NONE 0
+#define STRING_INFO 1
+#define STRING_VERS 2
+ long string_start = 0;
+ long string_end = 0;
+ 
+char *yylp_buffer_start;
+
+int libread(FILE* f, char* buf, int max_size);
+int current_pos(int i);
+int read_string(char **buffer, long *start, long end);
+ 
+void push_state(int state, int new_state);
+void pop_state();
+ 
+#  undef YY_INPUT
+#  define YY_INPUT(buf,result,max_size) \
+          if ( ((result = libread( (yyin), (char *) buf, max_size )) < 0 ) \
+                  && ferror( yyin ) ) \
+                YY_FATAL_ERROR( "read in flex scanner failed" );
+
 
 extern "C"
@@ -52,4 +108,7 @@
 tos            ({taborspace}*)
 eq             (=|{tos}+=|=+{tos}|{tos}+=+{tos})
+tnl            ([ \t\n]*)
+col            (;|{tos}+;)
+eqnl           ([ \t\n]*+=[ \t\n]*)
 
 /* %start START */
@@ -57,38 +116,45 @@
 %x pdef
 %x comment
+%x procdef
+%x ctext
+%x string
+%x cstring
 
 %%
 (\/\/[^\n]*)|(^#![^\n]*)|([ \t]) { }
-\/\/*        { old_state = YYSTATE; BEGIN(comment); }
-
-(module+{eq}+\"+{name}\") {
+\/\/*        { push_state(YYSTATE, comment); }
+
+(module+{eqnl}+{quote}+{name}+{quote}) {
              char *buff = (char *)malloc(yyleng+4);
+             memset(buff, '\0', yyleng+4);
              sscanf( yytext, "%*[^\"]\"%[^\"]\"", buff);
              module_def.name = (char *)malloc(strlen(buff)+1);
-             strcpy(module_def.name, buff);
+             memset(module_def.name, '\0', strlen(buff)+1);
+             memcpy(module_def.name, buff, strlen(buff));
              strcat(buff, ".cc");
-             Add2files(&module_def,buff);
+             Add2files(&module_def, buff);
              free(buff);
            }
 
-(version+{eq}+\"+{strings}\") {
-             char *buff = (char *)malloc(yyleng);
-             sscanf( yytext, "%*[^\"]\"%[^\"]\"", buff);
-             module_def.version = (char *)malloc(strlen(buff)+1);
-             strcpy(module_def.version, buff);
-             make_version(module_def.version, &module_def);
-             free(buff);
-           }
-
-(helpfile+{eq}+\"+{fname}\") {
-             char *buff = (char *)malloc(yyleng);
+(version+{eqnl}+{quote}+{strings}+{quote}) {
+             yyless(4);
+             string_type = STRING_VERS;
+             push_state(YYSTATE, cstring);
+           }
+
+(helpfile+{eqnl}+{quote}+{fname}+{quote}) {
+             char *buff = (char *)malloc(yyleng+1);
+             memset(buff, '\0', yyleng+1);
              sscanf( yytext, "%*[^\"]\"%[^\"]\"", buff);
              module_def.helpfile = (char *)malloc(strlen(buff)+1);
-             strcpy(module_def.helpfile, buff);
+             memset(module_def.helpfile, '\0', strlen(buff)+1);
+             memcpy(module_def.helpfile, buff, strlen(buff));
+             printf("==>HELP:'%s'\n", module_def.helpfile);
              free(buff);
            }
 
-(cxxsource+{eq}+{fname}) {
-             char *buff = (char *)malloc(yyleng);
+(cxxsource+{eqnl}+{fname}) {
+             char *buff = (char *)malloc(yyleng+1);
+             memset(buff, '\0', yyleng+1);
              sscanf( yytext, "%*[^=]=%s", buff);
              Add2files(&module_def,buff);
@@ -96,21 +162,50 @@
            }
 
-(info+{eq}+\"+{strings}\") {
-             char *buff = (char *)malloc(yyleng);
-             sscanf( yytext, "%*[^\"]\"%[^\"]\"", buff);
-             module_def.info = (char *)malloc(strlen(buff)+1);
-             strcpy(module_def.info, buff);
-             free(buff);
-           }
-
+(info+{eqnl}+{quote}+{strings}+{quote}) {
+             yyless(4);
+             string_type = STRING_INFO;
+             push_state(YYSTATE, cstring);
+           }
+
+<cstring>{quote} { quote++; push_state(YYSTATE, string);
+                string_start = current_pos(yyleng); }
+<cstring>\n { yylplineno++; }
+<cstring>{col} {
+            switch(string_type) {
+                case STRING_INFO:                     
+                  read_string(&module_def.info, &string_start, string_end);
+                  break;
+                  
+                case STRING_VERS:                     
+                  read_string(&module_def.version, &string_start, string_end);
+                  make_version(module_def.version, &module_def);
+                  break;
+            }
+            string_type = STRING_NONE;
+            pop_state(); }
+<cstring>.  { }
+
+
+
+(proc+{tos}+{name})|({tos}+proc+{tos}+{name}) {
+             char *proc = (char *)malloc(yyleng+1);
+             memset(proc, '\0', yyleng+1);
+             push_state(YYSTATE, pdef);
+             sscanf( yytext, "%*[^p]proc %s", proc);
+             if(strlen(proc)<1) sscanf( yytext, "proc %s", proc);
+             Add2proclist(&module_def, proc, "none", "NONE", NONE);
+             free(proc);
+           }
 
 (proc+{tos}+{name}+{tos}+{name})|({tos}+proc+{tos}+{name}+{tos}+{name}) {
-             char proc[256], ret_val[256], n2[32];
+             char *proc = (char *)malloc(yyleng+1);
+             char *ret_val = (char *)malloc(yyleng+1);
+             memset(proc, '\0', yyleng+1);
+             memset(ret_val, '\0', yyleng+1);
+
+             char n2[32];
              int cmd;
-             memset(proc, '\0', 256);
-             memset(ret_val, '\0', 256);
              memset(n2, '\0', 32);
-             old_state = YYSTATE;
-             BEGIN(pdef);
+             push_state(YYSTATE, pdef);
              sscanf( yytext, "%*[^p]proc %s %s", ret_val, proc);
              if(strlen(proc)<1) sscanf( yytext, "proc %s %s", ret_val, proc);
@@ -121,22 +216,16 @@
                 Add2proclist(&module_def, proc, ret_val,
 					  decl2str(tok,n2), tok);
-             else printf("proc '%s': Invalid return parameter %s.\n",
-			 module_def.procs[module_def.proccnt-1].procname,
-                         ret_val);
-           }
-
-(proc+{tos}+{name})|({tos}+proc+{tos}+{name}) {
-             char proc[256];
-             old_state = YYSTATE;
-             BEGIN(pdef);
-             proc[0]='\0';
-             sscanf( yytext, "%*[^p]proc %s", proc);
-             if(strlen(proc)<1) sscanf( yytext, "proc %s", proc);
-             Add2proclist(&module_def, proc, "none", "NONE", 0);
+             else {
+               printf("proc '%s': Invalid return parameter %s.\n",
+                         proc, ret_val);
+               Add2proclist(&module_def, proc, "none",
+					  "NONE", NONE);
+             }
+             free(proc);
+             free(ret_val);
            }
 
 <pdef>[ \t]  { }
-<pdef>\(     {
-             }
+<pdef>"("    { }
 <pdef>{name}+, {
              char param[256], n2[32];
@@ -152,8 +241,45 @@
                          param);
            }
-<pdef>{name}+\)+{eq}+{name} {
+<pdef>{name}+")"+{tnl}+"{" {
+             char param[256], n2[32];
+             int cmd;
+             BEGIN(procdef);
+             memset(param, '\0', 256);
+             memset(n2, '\0', 32);
+             sscanf( yytext, "%[^)])", param);
+             cmd = IsCmd(param, tok);
+             if(cmd!=0)AddParam(&module_def,
+				param, decl2str(tok,n2), tok);
+             else printf("proc '%s': Invalid parameter %s.\n",
+			 module_def.procs[module_def.proccnt-1].procname,
+			 param);
+           }
+<pdef>")"+{tnl}+"{" {
+             BEGIN(procdef);
+           }
+
+<pdef>"{" {
+             BEGIN(procdef);
+           }
+
+<pdef>(")"+{eqnl}+{name})|({eq}+{name}) {
+             char funcname[256];
+             pop_state();
+             sscanf( yytext, "%*[^=]=%s", funcname);
+             if(strlen(funcname)<=0)
+                sscanf( yytext, "=%s", funcname);
+             free(module_def.procs[module_def.proccnt-1].funcname);
+             module_def.procs[module_def.proccnt-1].funcname =
+                (char *)malloc(strlen(funcname)+1);
+             memset(module_def.procs[module_def.proccnt-1].funcname,
+		    '\0', strlen(funcname)+1);
+             memcpy(module_def.procs[module_def.proccnt-1].funcname,
+		    funcname, strlen(funcname));
+           }
+
+<pdef>({name}+")"+{eqnl}+{name}) {
              char param[256], n2[32],funcname[256];
              int cmd;
-             BEGIN(old_state);
+             pop_state();
              memset(param, '\0', 256);
              memset(n2, '\0', 32);
@@ -175,29 +301,99 @@
 			 module_def.procs[module_def.proccnt-1].procname, param);
            }
-<pdef>\)+{eq}+{name}|{eq}+{tos}+{name} {
-             char funcname[256];
-             BEGIN(old_state);
-             sscanf( yytext, "%*[^=]=%s", funcname);
-             if(strlen(funcname)<=0)
-                sscanf( yytext, "=%s", funcname);
-             free(module_def.procs[module_def.proccnt-1].funcname);
-             module_def.procs[module_def.proccnt-1].funcname =
-                (char *)malloc(strlen(funcname)+1);
-             memset(module_def.procs[module_def.proccnt-1].funcname,
-		    '\0', strlen(funcname)+1);
-             memcpy(module_def.procs[module_def.proccnt-1].funcname,
-		    funcname, strlen(funcname));
-           }
 
 <pdef>.      { }
 
-<comment>\*\/            { BEGIN(old_state); }
+<procdef>"}"  { pop_state(); }
+<procdef>RETURN+{eqnl}+{name}+{col}   {
+  printf("Return:\n");}
+<procdef>function+{eqnl}+{name}+{col} {
+       char *funcname = (char *)malloc(yyleng+1);
+       memset(funcname, '\0', yyleng+1);
+       sscanf( yytext, "%*[^=]=%[^;];", funcname);
+       if(strlen(funcname)<=0)
+         sscanf( yytext, "=%[^;];", funcname);
+       free(module_def.procs[module_def.proccnt-1].funcname);
+       module_def.procs[module_def.proccnt-1].funcname =
+         (char *)malloc(strlen(funcname)+   1);
+       memset(module_def.procs[module_def.proccnt-1].funcname,
+              '\0', strlen(funcname)+1);
+       memcpy(module_def.procs[module_def.proccnt-1].funcname,
+              funcname, strlen(funcname));
+     }
+
+<procdef>checkring+{col}            {
+  printf("Do checkring\n"); }
+<procdef>C+{eqnl}+"{" {
+                push_state(YYSTATE, ctext);
+                C_start=current_pos(yyleng);
+                yyless(yyleng-1);
+                c_codetype = C_CODE_PROC;
+              }
+<procdef>.                          { printf("%s", yytext); }
+
+<comment>\*\/            { pop_state(); }
 <comment>\n              { yylineno++; }
 <comment>.               { }
 
-
-\n                       { yylineno++; }
-\r                       { }
-.                        { }
+<ctext>({comment}[^\n]*) { }
+<ctext>\/\/*   { push_state(YYSTATE, comment); }
+<ctext>{quote} { quote++; push_state(YYSTATE, string); }
+<ctext>"{"     { brace1++; }
+<ctext>"}"     {
+       brace1--;
+       if(brace2>0) {
+         yylp_errno = YYLP_BODY_BR2;
+         return(1);
+       }
+       if(brace3>0) {
+         yylp_errno = YYLP_BODY_BR3;
+         return(1);
+       }
+       if(brace1<=0) {
+         C_end = current_pos(yyleng)-1;
+         printf("Ctext: %d-%d\n", C_start, C_end);
+         switch(c_codetype) {
+             case C_CODE_PROC:
+               read_string(&(module_def.procs[module_def.proccnt-1].c_code),
+                           &C_start, C_end);
+               break;
+
+             case C_CODE_MAIN:
+               break;
+         }
+         c_codetype = C_CODE_NONE;
+         pop_state();
+       }
+     }
+<ctext>"("       { brace2++; }
+<ctext>")"       { brace2--;
+                   if(brace2<0) {
+                     yylp_errno = YYLP_BODY_TMBR2;
+                     return(1);
+                   }
+                 }
+<ctext>"["       { brace3++; }
+<ctext>"]"       { brace3--;
+                   if(brace3<0) {
+                     yylp_errno = YYLP_BODY_TMBR3;
+                     return(1);
+                   }
+                 }
+<ctext>\n  { yylineno++; }
+<ctext>.   { }
+
+<string>{quote} { quote--; string_end = current_pos(yyleng)-1; pop_state(); }
+<string>(\\\\)|(\\\") { }
+<string>\n            { yylplineno++; }
+<string>.             { }
+
+
+C+{eqnl}+"{" { push_state(YYSTATE, ctext);
+               C_start=current_pos(yyleng);
+               yyless(yyleng-1);
+             }
+\n           { yylineno++; }
+\r           { }
+.            { }
 
 %%
@@ -208,4 +404,69 @@
     return 1;
   }
+}
+
+int libread(FILE* f, char* buf, int max_size)
+{ int rc;
+
+  offset = ftell(f);
+  rc  = fread( buf, 1, max_size, f );
+#if YYLPDEBUG >2
+  printf("fread: %d of %d\n", rc, max_size);
+#endif
+  yylp_buffer_start = buf;
+  return rc;
+}
+
+int current_pos(int i)
+{
+  return(i+offset+(int)(yytext-yylp_buffer_start));
+}
+
+int read_string(char **p, long *start, long end) 
+{
+  char *buffer;
+  
+  if(*start > 0 ) {
+    long len = end - *start;
+    if(len>=0) {
+      long cur = ftell(yyin);
+      buffer = (char *)malloc(len+1);
+      memset(buffer, '\0', len+1);
+      fseek(yyin, *start, SEEK_SET);
+      fread(buffer, 1, len, yyin);
+      fseek(yyin, cur, SEEK_SET);
+      *p = buffer;
+    }
+    *start = 0;
+  }
+}
+                
+void push_state(int state, int new_state)
+{
+  state_level++;
+#if DEBUG
+  printf("====>PUSH to new state %d/%d l=%d\n", state, new_state, state_level);
+#endif
+  if(state_level>=state_max) {
+    state_max++;
+    if(old_states == NULL)
+      old_states = (int *)malloc(sizeof(int));
+    else {
+      old_states = (int *)realloc(old_states, state_max*sizeof(int));
+    }
+  }
+  old_states[state_level] = state;
+  BEGIN(new_state);
+}
+
+void pop_state()
+{
+#if DEBUG
+  printf("====>Back to old state %d, l=%d\n", old_states[state_level],
+	 state_level);
+#endif
+  BEGIN(old_states[state_level]);
+  state_level--;
+  if(state_level<0) state_level = -1;
 }
 
Index: modules/tools/typmap.h
===================================================================
--- modules/tools/typmap.h	(revision 740e1f7291b169d818475089a70366a328feb8d1)
+++ modules/tools/typmap.h	(revision 6c87725945caa48b135d716568d9cf8b968ba527)
@@ -9,4 +9,6 @@
 void init_type_conv() 
 {
+  strcpy(type_conv[NONE], "none");
+  strcpy(type_conv[NONE], "void");
   strcpy(type_conv[INT_CMD], "int");
   strcpy(type_conv[RING_CMD], "ring");
