/[bison]/bison/src/parse-skel.y
ViewVC logotype

Diff of /bison/src/parse-skel.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by Zastai, Mon Jan 7 23:00:39 2002 UTC revision 1.8 by akim, Wed Jan 9 13:03:45 2002 UTC
# Line 44  Line 44 
44     typed access to it.  */     typed access to it.  */
45  #define yycontrol ((skel_control_t *) skel_control)  #define yycontrol ((skel_control_t *) skel_control)
46    
 char* prefix = NULL;  
47  FILE* parser = NULL;  FILE* parser = NULL;
48    
49  size_t output_line;  size_t output_line;
# Line 87  static void yyprint (FILE *file, const y Line 86  static void yyprint (FILE *file, const y
86  %token LINE  %token LINE
87  %token SLINE  %token SLINE
88    
 %token YACC  
89  %token SECTION  %token SECTION
90    
91  %token GUARDS  %token GUARDS
92  %token TOKENS  %token TOKENS
93  %token ACTIONS  %token ACTIONS
94    
95  %type <boolean> section.yacc  %type <string> string.1 string
96    
97  %start input  %start input
98    
# Line 110  skeleton : /* Empty.  */    { } Line 108  skeleton : /* Empty.  */    { }
108  section : section.header section.body { }  section : section.header section.body { }
109  ;  ;
110    
111  section.header : SECTION BLANKS MUSCLE BLANKS STRING BLANKS section.yacc '\n'  section.header : SECTION BLANKS string '\n'
112  {  {
113    char *name = 0;    char *name = $3;
   char *limit = 0;  
   char *suffix = $5;  
114    
115    /* Close the previous parser.  */    /* Close the previous parser.  */
116    if (parser)    if (parser)
117      parser = (xfclose (parser), NULL);      parser = (xfclose (parser), NULL);
118    
   /* If the following section should be named with the yacc-style, and it's  
      suffix is of the form 'something.h' or 'something.c', then add '.tab' in  
      the middle of the suffix.  */  
   if (tab_extension && $7 && (strsuffix (suffix, ".h") ||  
                               strsuffix (suffix, ".c")))  
     {  
       size_t prefix_len = strlen (prefix);  
       size_t suffix_len = strlen (suffix);  
   
       /* Allocate enough space to insert '.tab'.  */  
       name = XMALLOC (char, prefix_len + suffix_len + 5);  
       limit = strrchr (suffix, '.');  
       if (!limit)  
         limit = suffix;  
   
       /* Prefix is 'X', suffix is 'Y.Z'.  Name will be 'XY.tab.Z'.  */  
       {  
         char* cp = 0;  
         cp = stpcpy (name, prefix);  
         cp = stpncpy (cp, suffix, limit - suffix);  
         cp = stpcpy (cp, ".tab");  
         cp = stpcpy (cp, limit);  
       }  
     }  
   else  
     name = stringappend (prefix, suffix);  
   
119    /* Prepare the next parser to be output.  */    /* Prepare the next parser to be output.  */
120    parser = xfopen (name, "w");    parser = xfopen (name, "w");
121    MUSCLE_INSERT_STRING ("parser-file-name", name);    MUSCLE_INSERT_STRING ("parser-file-name", name);
# Line 156  section.header : SECTION BLANKS MUSCLE B Line 125  section.header : SECTION BLANKS MUSCLE B
125  }  }
126  ;  ;
127    
128  section.yacc : /* Empty.  */ { $$ = 0; }  /* Either a literal string, or a muscle value.  */
129               | YACC          { $$ = 1; }  string.1:
130  ;      STRING { $$ = $1; }
131      | MUSCLE { $$ = xstrdup (muscle_find ($1)); }
132      ;
133    
134    /* Either a literal string, or a muscle value, or the concatenation of
135       them.  */
136    string:
137        string.1
138        { $$ = $1; }
139      | string BLANKS string.1
140        { $$ = stringappend ($1, $3); free ($1); free ($3); }
141      ;
142    
143  section.body  section.body
144  : /* Empty.  */ { }  : /* Empty.  */ { }
# Line 210  yyprint (FILE *file, Line 190  yyprint (FILE *file,
190      case CHARACTER:      case CHARACTER:
191        fprintf (file, " = '%c'", value->character);        fprintf (file, " = '%c'", value->character);
192        break;        break;
   
     case YACC:  
       fprintf (file, " = %s", value->boolean ? "true" : "false");  
       break;  
193      }      }
194  }  }
195    
# Line 238  skel_error (skel_control_t *control, Line 214  skel_error (skel_control_t *control,
214  void  void
215  process_skeleton (const char* skel)  process_skeleton (const char* skel)
216  {  {
   /* Compute prefix.  Actually, it seems that the processing I need here is  
      done in compute_base_names, and the result stored in short_base_name.  */  
   prefix = short_base_name;  
   
217    /* Prepare a few things.  */    /* Prepare a few things.  */
218    output_line = 1;    output_line = 1;
219    skeleton_line = 1;    skeleton_line = 1;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26