* amd/get_args.c (get_args): call conf_parse() using conf_in.
authorErez Zadok <ezk@cs.sunysb.edu>
Sun, 7 Aug 2005 00:00:12 +0000 (00:00 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Sun, 7 Aug 2005 00:00:12 +0000 (00:00 +0000)
* amd/amd.h: use renamed parser symbols (yyparse -> conf_parse;
yyin -> conf_in).

* ylwrap: Enhance wrapper to avoid the #define hacks done by Gdb,
and suggested by the Automake manual.  This enhanced parser will
prefix each conflicting yacc/lex symbol with a unique name
produced from INPUT.  For example, if INPUT is foo_parse.y, then
yyparse() becomes foo_parse().  This requires that both your .l
and corresponding .y files have the same prefix (e.g., foo_parse.y
and foo_tok.l).

* amd/Makefile.am (BUILT_SOURCES): define which yacc/lex .h/.c
source files are built automatically, and therefore should not be
in the distro (IMHO), and should be cleaned upon "make clean".
(amd_SOURCES): include new sun_map_parse.y and sun_map_tok.l files.

* ylwrap: new file needed because we have two parsers now.

* amd/sun_map_{parse.y,tok.l}: cleanup and formatting.

ChangeLog
amd/Makefile.am
amd/amd.h
amd/get_args.c
amd/sun_map_parse.y
amd/sun_map_tok.l
ylwrap

index 7959441bb9a60610aee49470fb141357cb6be2bb..7259015db01c7d11b1a3ab22c0e8e3598c3a3271 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2005-08-06  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * amd/get_args.c (get_args): call conf_parse() using conf_in.
+
+       * amd/amd.h: use renamed parser symbols (yyparse -> conf_parse;
+       yyin -> conf_in).
+
+       * ylwrap: Enhance wrapper to avoid the #define hacks done by Gdb,
+       and suggested by the Automake manual.  This enhanced parser will
+       prefix each conflicting yacc/lex symbol with a unique name
+       produced from INPUT.  For example, if INPUT is foo_parse.y, then
+       yyparse() becomes foo_parse().  This requires that both your .l
+       and corresponding .y files have the same prefix (e.g., foo_parse.y
+       and foo_tok.l).
+
+       * amd/Makefile.am (BUILT_SOURCES): define which yacc/lex .h/.c
+       source files are built automatically, and therefore should not be
+       in the distro (IMHO), and should be cleaned upon "make clean".
+       (amd_SOURCES): include new sun_map_parse.y and sun_map_tok.l files.
+
+
+       * ylwrap: new file needed because we have two parsers now.
+
+       * amd/sun_map_{parse.y,tok.l}: cleanup and formatting.
+
 2005-08-06  Daniel P. Ottavio  <dottavio@ic.sunysb.edu>
 
        * amd/Makefile.am: Added new files sun_map.h, sun_map.c,
index bc5e4253f19be51f06cc7e7b9143c6c46b5e7f2e..49a0d099eb4657909406284f41a194bb6288e130 100644 (file)
@@ -15,6 +15,12 @@ TESTS = test1.sh
 # headers this depends on, not to be installed
 noinst_HEADERS = amd.h sun_map.h
 
+# sources which get auto-built (from yacc/lex)
+BUILT_SOURCES =                \
+       conf_parse.c conf_parse.h conf_tok.c    \
+       sun_map_parse.c sun_map_parse.h sun_map_tok.c
+AM_YFLAGS = -d
+
 # *.y must be listed before *.l, because of a bug in automake-1.2
 # which will not generate the .h needs for the lex file from the yacc file.
 # I took out the conf .y/.l files b/c of bad interaction between bsd44 make
@@ -24,7 +30,9 @@ noinst_HEADERS = amd.h sun_map.h
 # get_args.c is handled separately
 amd_SOURCES =                  \
        conf_parse.y            \
+       sun_map_parse.y         \
        conf_tok.l              \
+       sun_map_tok.l           \
        \
        am_ops.c                \
        amd.c                   \
@@ -95,37 +103,25 @@ EXTRA_amd_SOURCES =        \
 # filesystem types this system supports.
 # AMD_INFO_OBJS: a list of info_*.o objects added, depending on which map
 # types this system supports.
-EXTRA_amd_OBJECTS = @AMD_FS_OBJS@ @AMD_INFO_OBJS@ sun_map_parse.o sun_map_tok.o
+EXTRA_amd_OBJECTS = @AMD_FS_OBJS@ @AMD_INFO_OBJS@
 LDADD = $(EXTRA_amd_OBJECTS) get_args.o ../libamu/libamu.la
 # must manually add f/lex library to LIBS, and not to LDADD.
 LIBS = @LIBS@ @LEXLIB@ @WRAPLIB@
 
-# custom yacc/lex rules for the Sun map parser
-sun_map_parse.o : sun_map_parse.c
-
-sun_map_parse.c : sun_map_parse.y
-       $(YACC) -d -psun_map_ -o$@ $<
-
-sun_map_tok.o : sun_map_tok.c
-
-sun_map_tok.c : sun_map_tok.l
-       $(LEX) -Psun_map_ -o$@ $<
-
 # additional files to distribute and clean
 EXTRA_DIST = ops_TEMPLATE.c $(man_MANS) $(TESTS)
-CLEANFILES = conf_tok.c conf_parse.c conf_parse.h sun_map_parse.c sun_map_tok.c sun_map_parse.h
+CLEANFILES = $(BUILT_SOURCES)
 DISTCLEANFILES = build_version.h
 
 # do not distribute files that should be generated by lex/yacc locally
 dist-hook:
-       (cd $(distdir) && rm -f conf_parse.c conf_parse.h conf_tok.c)
+       (cd $(distdir) && rm -f $(BUILT_SOURCES))
 
 INCLUDES = -I$(top_srcdir)/include
 
 # allow users to add their own flags via "configure --enable-am-flags=ARG"
 AMU_CFLAGS = @AMU_CFLAGS@
 AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS)
-AM_YFLAGS = -d
 
 # dependencies
 $(PROGRAMS): $(LDADD)
index 0e431290ef0fbdafab08fcbf4c1f93b2665dc0c5..6c41f9ca002c0a86083ba4899fa77f48ccfe8dd0 100644 (file)
--- a/amd/amd.h
+++ b/amd/amd.h
@@ -533,7 +533,8 @@ extern cf_map_t *find_cf_map(const char *name);
 extern int set_conf_kv(const char *section, const char *k, const char *v);
 extern int mount_node(opaque_t arg);
 extern int unmount_mp(am_node *mp);
-extern int yyparse (void);
+extern int conf_parse(void);   /* "yyparse" renamed */
+extern FILE *conf_in;          /* "yyin" renamed */
 
 extern void amfs_mkcacheref(mntfs *mf);
 extern int amfs_mount(am_node *mp, mntfs *mf, char *opts);
@@ -626,7 +627,6 @@ extern void wakeup_task(int, int, wchan_t);
 /*
  * Global variables.
  */
-extern FILE *yyin;
 extern SVCXPRT *current_transp; /* For nfs_quick_reply() */
 extern char *conf_tag;
 extern char *opt_gid;
index b8c5ddbc32d83d4f14c28ae982aebb6d3358f5a2..33d46d2cc5463e7de96da3db16aa376548a293af 100644 (file)
@@ -330,8 +330,8 @@ get_args(int argc, char *argv[])
       perror(buf);
       exit(1);
     }
-    yyin = fp;
-    yyparse();
+    conf_in = fp;
+    conf_parse();
     fclose(fp);
     if (process_all_regular_maps() != 0)
       exit(1);
index 1f70c266f38a4260a2de098d56216dd433106829..53fa8ab46907ff90fd7b1f212b5eec7659b9a73e 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2005 Daniel Ottavio
  * Copyright (c) 1997-2005 Erez Zadok
+ * Copyright (c) 2005 Daniel P. Ottavio
  * Copyright (c) 1990 Jan-Simon Pendry
  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  * Copyright (c) 1990 The Regents of the University of California.
@@ -85,7 +85,7 @@ static struct sun_list *get_sun_entry_list();
 }
 
 %token NEWLINE COMMENT WSPACE
-%token <strval> WORD 
+%token <strval> WORD
 
 %%
 
@@ -96,7 +96,7 @@ file : new_lines entries
      | entries
      ;
 
-entries : entry 
+entries : entry
         | entry new_lines
         | entry new_lines entries
         ;
@@ -109,11 +109,11 @@ entry : locations {
 
   struct sun_list *list;
   struct sun_entry *entry;
-  
+
   /* allocate an entry */
   entry = sun_entry_alloc();
-  
-  /* 
+
+  /*
    * Assign the global location list to this entry and reset the
    * global pointer.  Reseting the global pointer will create a new
    * list instance next time get_sun_location_list() is called.
@@ -121,7 +121,7 @@ entry : locations {
   list = get_sun_location_list();
   entry->location_list = (struct sun_location *)list->first;
   sun_location_list = NULL;
-  
+
    /* Add this entry to the entry list. */
   sun_list_add(get_sun_entry_list(),(qelem *)entry);
 }
@@ -130,7 +130,7 @@ entry : locations {
 
   struct sun_list *list;
   struct sun_entry *entry;
-  
+
   entry = sun_entry_alloc();
 
   /* An fstype may have been defined in the 'options'. */
@@ -138,8 +138,8 @@ entry : locations {
     entry->fstype = tmpFsType;
     tmpFsType = NULL;
   }
-    
-  /* 
+
+  /*
    * Assign the global location list to this entry and reset the
    * global pointer.  Reseting the global pointer will create a new
    * list instance next time get_sun_location_list() is called.
@@ -147,8 +147,8 @@ entry : locations {
   list = get_sun_location_list();
   entry->location_list = (struct sun_location *)list->first;
   sun_location_list = NULL;
-  
-  /* 
+
+  /*
    * Assign the global opt list to this entry and reset the global
    * pointer.  Reseting the global pointer will create a new list
    * instance next time get_sun_opt_list() is called.
@@ -161,16 +161,15 @@ entry : locations {
   sun_list_add(get_sun_entry_list(),(qelem *)entry);
 }
 
-
 | mountpoints {
 
   struct sun_list *list;
   struct sun_entry *entry;
-  
+
   /* allocate an entry */
   entry = sun_entry_alloc();
-  
-  /* 
+
+  /*
    * Assign the global mountpt list to this entry and reset the global
    * pointer.  Reseting the global pointer will create a new list
    * instance next time get_mountpt_list() is called.
@@ -187,17 +186,17 @@ entry : locations {
 
   struct sun_list *list;
   struct sun_entry *entry;
-  
+
   /* allocate an entry */
-  entry = sun_entry_alloc(); 
+  entry = sun_entry_alloc();
 
   /* An fstype may have been defined in the 'options'. */
   if(tmpFsType != NULL) {
     entry->fstype = tmpFsType;
     tmpFsType = NULL;
   }
-  
-  /* 
+
+  /*
    * Assign the global mountpt list to this entry and reset the global
    * pointer.  Reseting the global pointer will create a new list
    * instance next time get_mountpt_list() is called.
@@ -205,8 +204,8 @@ entry : locations {
   list = get_mountpt_list();
   entry->mountpt_list = (struct sun_mountpt *)list->first;
   mountpt_list = NULL;
-  /* 
+
+  /*
    * Assign the global opt list to this entry and reset the global
    * pointer.  Reseting the global pointer will create a new list
    * instance next time get_sun_opt_list() is called.
@@ -214,19 +213,19 @@ entry : locations {
   list = get_sun_opt_list();
   entry->opt_list = (struct sun_opt *)list->first;
   sun_opt_list = NULL;
-  
+
   /* Add this entry to the entry list. */
   sun_list_add(get_sun_entry_list(),(qelem *)entry);
 }
 
 | '+' WORD {
-  
+
   struct sun_opt *include = sun_opt_alloc();
   include->str = strdup($2);
-  
+
   sun_list_add(get_sun_include_list(),(qelem *)include);
 }
-;  
+;
 
 mountpoints : mountpoint
             | mountpoint WSPACE mountpoints
@@ -239,8 +238,8 @@ mountpoint : WORD WSPACE location {
 
   /* allocate a mountpt */
   mountpt = sun_mountpt_alloc();
-  
-  /* 
+
+  /*
    * Assign the global loaction list to this entry and reset the
    * global pointer.  Reseting the global pointer will create a new
    * list instance next time get_sun_location_list() is called.
@@ -248,9 +247,9 @@ mountpoint : WORD WSPACE location {
   list = get_sun_location_list();
   mountpt->location_list = (struct sun_location *)list->first;
   sun_location_list = NULL;
-  
+
   mountpt->path = strdup($1);
-  
+
   /* Add this mountpt to the mountpt list. */
   sun_list_add(get_mountpt_list(),(qelem *)mountpt);
 }
@@ -259,11 +258,11 @@ mountpoint : WORD WSPACE location {
 
   struct sun_list *list;
   struct sun_mountpt *mountpt;
-  
+
   /* allocate a mountpt */
   mountpt = sun_mountpt_alloc();
-  
-  /* 
+
+  /*
    * Assign the global loaction list to this entry and reset the
    * global pointer.  Reseting the global pointer will create a new
    * list instance next time get_sun_location_list() is called.
@@ -271,8 +270,8 @@ mountpoint : WORD WSPACE location {
   list = get_sun_location_list();
   mountpt->location_list = (struct sun_location *)list->first;
   sun_location_list = NULL;
-  /* 
+
+  /*
    * Assign the global opt list to this entry and reset the global
    * pointer.  Reseting the global pointer will create a new list
    * instance next time get_sun_opt_list() is called.
@@ -280,27 +279,27 @@ mountpoint : WORD WSPACE location {
   list = get_sun_opt_list();
   mountpt->opt_list = (struct sun_opt *)list->first;
   sun_opt_list = NULL;
-  
+
   mountpt->path = strdup($1);
-  
+
   /* Add this mountpt to the mountpt list. */
   sun_list_add(get_mountpt_list(),(qelem *)mountpt);
 }
 ;
 
-locations : location 
+locations : location
           | location WSPACE locations
           ;
 
 location : hosts ':' WORD {
-  
+
   struct sun_list *list;
   struct sun_location *location;
-  
+
   /* allocate a new location */
   location = sun_location_alloc();
-  
-  /* 
+
+  /*
    * Assign the global opt list to this entry and reset the global
    * pointer.  Reseting the global pointer will create a new list
    * instance next time get_sun_opt_list() is called.
@@ -308,22 +307,22 @@ location : hosts ':' WORD {
   list = get_sun_host_list();
   location->host_list = (struct sun_host *)list->first;
   sun_host_list = NULL;
-  
+
   location->path = strdup($3);
-  
+
   /* Add this location to the location list. */
   sun_list_add(get_sun_location_list(),(qelem *)location);
 }
 
 | ':' WORD {
-  
+
   struct sun_location *location;
-  
+
   /* allocate a new location */
   location = sun_location_alloc();
-  
+
   location->path = strdup($2);
-  
+
   /* Add this location to the location list. */
   sun_list_add(get_sun_location_list(),(qelem *)location);
 }
@@ -334,12 +333,12 @@ hosts : host
       ;
 
 host : WORD {
-  
+
   /* allocate a new host */
   struct sun_host *host = sun_host_alloc();
-  
+
   host->name = strdup($1);
-  
+
   /* Add this host to the host list. */
   sun_list_add(get_sun_host_list(),(qelem *)host);
 }
@@ -352,19 +351,19 @@ host : WORD {
    * list.
    */
   struct sun_host *host = (struct sun_host *)sun_host_list->last;
-  
+
   host->name = strdup($1);
 }
 ;
 
 weight : '(' WORD ')' {
-  
+
   int val;
   /* allocate a new host */
   struct sun_host *host = sun_host_alloc();
-  
+
   val = atoi($2);
-  
+
   host->weight = val;
 
   /* Add this host to the host list. */
@@ -372,19 +371,19 @@ weight : '(' WORD ')' {
 }
 ;
 
-options : option 
+options : option
         | option ',' options
         ;
-  
+
 /* file system type option */
 option : 'fstype='WORD {
-  
+
   tmpFsType = strdup($2);
 }
 
 /* all other fs options */
 | WORD {
-  
+
   struct sun_opt *opt = sun_opt_alloc();
   opt->str = strdup($1);
 
@@ -392,20 +391,21 @@ option : 'fstype='WORD {
   sun_list_add(get_sun_opt_list(),(qelem *)opt);
 }
 
-; 
+;
 
 %%
 
-struct sun_entry *sun_map_parse_read(const char *map_data) {
-
+struct sun_entry *
+sun_map_parse_read(const char *map_data)
+{
   struct sun_entry *retval = NULL;
 
   /* pass map_data to lex */
   sun_map_tok_setbuff(map_data);
-  
+
   /* call yacc */
   sun_map_parse();
-  
+
   if (sun_entry_list != NULL) {
     /* return the first Sun entry in the list */
     retval = (struct sun_entry*)sun_entry_list->first;
@@ -413,47 +413,65 @@ struct sun_entry *sun_map_parse_read(const char *map_data) {
   else {
     plog(XLOG_ERROR,"Sun map parser did not produce data structs.");
   }
-  
+
   return retval;
 }
 
-static struct sun_list *get_sun_include_list() {
-  if(sun_include_list == NULL) {
+
+static struct sun_list *
+get_sun_include_list(void)
+{
+  if (sun_include_list == NULL) {
     sun_include_list = sun_list_alloc();
   }
   return sun_include_list;
 }
 
-static struct sun_list *get_sun_entry_list() {
-  if(sun_entry_list == NULL) {
+
+static struct sun_list *
+get_sun_entry_list(void)
+{
+  if (sun_entry_list == NULL) {
     sun_entry_list = sun_list_alloc();
   }
   return sun_entry_list;
 }
 
-static struct sun_list *get_mountpt_list() {
-  if(mountpt_list == NULL) {
+
+static struct sun_list *
+get_mountpt_list(void)
+{
+  if (mountpt_list == NULL) {
     mountpt_list = sun_list_alloc();
   }
   return mountpt_list;
 }
 
-static struct sun_list *get_sun_location_list() {
-  if(sun_location_list == NULL) {
+
+static struct sun_list *
+get_sun_location_list(void)
+{
+  if (sun_location_list == NULL) {
     sun_location_list = sun_list_alloc();
   }
   return sun_location_list;
 }
 
-static struct sun_list *get_sun_host_list() {
-  if(sun_host_list == NULL) {
+
+static struct sun_list *
+get_sun_host_list(void)
+{
+  if (sun_host_list == NULL) {
     sun_host_list = sun_list_alloc();
   }
   return sun_host_list;
 }
 
-static struct sun_list *get_sun_opt_list() {
-  if(sun_opt_list == NULL) {
+
+static struct sun_list *
+get_sun_opt_list(void)
+{
+  if (sun_opt_list == NULL) {
     sun_opt_list = sun_list_alloc();
   }
   return sun_opt_list;
index 4c7f80ece855e13a60eeff6aef062cb367c48758..9a29c826545b569adbe8297ac3a230958b9aa61b 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2005 Daniel Ottavio
  * Copyright (c) 1997-2005 Erez Zadok
+ * Copyright (c) 2005 Daniel P. Ottavio
  * Copyright (c) 1990 Jan-Simon Pendry
  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
  * Copyright (c) 1990 The Regents of the University of California.
 #endif /* HAVE_CONFIG_H */
 #include <am_defs.h>
 #include <amd.h>
-
-
-#include <string.h>
 #include <sun_map_parse.h>
 
-/* 
- * We need to configure lex to parse from a string 
+/*
+ * We need to configure lex to parse from a string
  * instead of a file. Each version of lex has it's
- * own way of doing this(sigh).
- */ 
+ * own way of doing this (sigh).
+ */
 #ifdef FLEX_SCANNER
 
 /* assign the buffer to parse */
@@ -71,17 +68,17 @@ const char *sun_map_tok_buff = NULL;
 const char *sun_map_tok_pos = NULL;
 
 /* size of the buffer */
-const char *sun_map_tok_end = NULL; 
+const char *sun_map_tok_end = NULL;
 
 /* copies the current position + maxsize into buff */
 int sun_map_yyinput(char *buff, int maxsize);
 
-# undef YY_INPUT 
+# undef YY_INPUT
 # define YY_INPUT(buff,result,maxsize) (result = sun_map_yyinput(buff,maxsize))
-#else
+#else /* not FLEX_SCANNER */
 # warning "Currently flex is the only supported version of lex."
 
-#endif /* FLEX_SCANNER */
+#endif /* not FLEX_SCANNER */
 
 int sun_map_line = 1;
 int sun_map_tokpos = 1;
@@ -94,34 +91,34 @@ WSPACE_REX     [ \t]*
 NEWLINE_REX    [ \t]*\n
 CONTINUE_REX   "\\"\n
 
-/* 
+/*
  * This option causes Solaris lex to fail.  Use flex.  See BUGS file
- * no need to use yyunput() 
+ * no need to use yyunput()
  */
 %option nounput
 
 %%
 
-{WORD_REX}      { 
-                  sun_map_tokpos += yyleng; 
-                  strncpy(sun_map_lval.strval,yytext,sizeof(sun_map_lval.strval));
-                  sun_map_lval.strval[sizeof(sun_map_lval.strval) - 1] = '\0';
+{WORD_REX}      {
+                  sun_map_tokpos += yyleng;
+                  strncpy(yylval.strval,yytext,sizeof(yylval.strval));
+                  yylval.strval[sizeof(yylval.strval) - 1] = '\0';
                   return WORD;
                 }
 
 {WSPACE_REX}    {
-                  sun_map_tokpos += yyleng; 
+                  sun_map_tokpos += yyleng;
                   return WSPACE;
-                } 
+                }
 
 {NEWLINE_REX}   {
-                  sun_map_tokpos = 0; 
-                  sun_map_line++; 
+                  sun_map_tokpos = 0;
+                  sun_map_line++;
                   return NEWLINE;
                 }
 
 {CONTINUE_REX}  {
-                  sun_map_tokpos = 0; 
+                  sun_map_tokpos = 0;
                   sun_map_line++;
                 }
 
@@ -135,26 +132,36 @@ CONTINUE_REX   "\\"\n
 
 %%
 
-int sun_map_error(const char* s) {
+
+int
+sun_map_error(const char* s)
+{
   plog(XLOG_ERROR,"sun2amd : parsing error : line %d, column %d\n",
        sun_map_line,sun_map_tokpos);
   return 1;
 }
 
-int sun_map_wrap() {
+
+int
+sun_map_wrap(void)
+{
   return 1;
 }
 
+
 #ifdef FLEX_SCANNER
-void sun_map_tok_setbuff(const char* buff) {
-  
+void
+sun_map_tok_setbuff(const char* buff)
+{
   sun_map_tok_end = buff + strlen(buff);
   sun_map_tok_pos = buff;
   sun_map_tok_buff = buff;
 }
 
-int sun_map_yyinput(char *buff, int maxsize) {
-  
+
+int
+sun_map_yyinput(char *buff, int maxsize)
+{
   int size = MIN(maxsize, (sun_map_tok_end - sun_map_tok_pos));
   if (size > 0) {
     memcpy(buff,sun_map_tok_pos,size);
diff --git a/ylwrap b/ylwrap
index 10e4368b35f1c6e009caa923f5bc8dc5ff82f196..408c1e0c5e6c7293cbb0ee853b9df2ec6dc1ed98 100755 (executable)
--- a/ylwrap
+++ b/ylwrap
@@ -54,6 +54,11 @@ Wrapper for lex/yacc invocations, renaming files as desired.
 
 Any number of OUTPUT,DESIRED pairs may be used.
 
+This wrapper will prefix each conflicting yacc/lex symbol with a unique name
+produced from INPUT.  For example, if INPUT is foo_parse.y, then yyparse()
+becomes foo_parse().  This requires that both your .l and corresponding .y
+files have the same prefix (e.g., foo_parse.y and foo_tok.l).
+
 Report bugs to <bug-automake@gnu.org>.
 EOF
     exit $?
@@ -175,9 +180,13 @@ if test $ret -eq 0; then
       TARGET=`echo "$2" | sed \
             -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
             -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
+      prefix=`echo $input | sed \
+               -e 's,^.*/,,g' \
+               -e 's/_parse.[yl]$/_/g' \
+               -e 's/_tok.[yl]$/_/g'`
 
       sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
-          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
+          -e "s,$FROM,$TARGET," "$from" | sed "s/yy/$prefix/g" > "$target" || ret=$?
 
       # Check whether header files must be updated.
       if test $first = no; then