+2000-03-17 Akim Demaille <akim@epita.fr>
+
+ * reader.c (copy_comment): New function, factored out from:
+ (copy_action): Use it. Removed now unused `match', `ended',
+ `cplus_comment'.
+ (copy_guard): Likewise.
+
2000-03-17 Akim Demaille <akim@epita.fr>
* reader.c (copy_string): New function, factored out from:
putc(c, foutput);
}
+
+/* Dump the comment from FINPUT to FOUTPUT. C is either `*' or `/',
+ depending upon the type of comments used. */
+
+void
+copy_comment (FILE *finput, FILE *foutput, int c)
+{
+ int cplus_comment;
+ register int match;
+ register int ended;
+
+ cplus_comment = (c == '/');
+ putc (c, foutput);
+ c = getc (finput);
+
+ ended = 0;
+ while (!ended)
+ {
+ if (!cplus_comment && c == '*')
+ {
+ while (c == '*')
+ {
+ putc(c, foutput);
+ c = getc(finput);
+ }
+
+ if (c == '/')
+ {
+ putc(c, foutput);
+ ended = 1;
+ }
+ }
+ else if (c == '\n')
+ {
+ lineno++;
+ putc (c, foutput);
+ if (cplus_comment)
+ ended = 1;
+ else
+ c = getc(finput);
+ }
+ else if (c == EOF)
+ fatal (_("unterminated comment"));
+ else
+ {
+ putc (c, foutput);
+ c = getc (finput);
+ }
+ }
+}
+
/* After `%guard' is seen in the input file, copy the actual guard
into the guards file. If the guard is followed by an action, copy
that into the actions file. STACK_OFFSET is the number of values
register int c;
register int n;
register int count;
- register int match;
- register int ended;
register char *type_name;
int brace_flag = 0;
- int cplus_comment;
/* offset is always 0 if parser has already popped the stack pointer */
if (semantic_parser) stack_offset = 0;
break;
case '/':
- putc(c, fguard);
- c = getc(finput);
+ putc (c, fguard);
+ c = getc (finput);
if (c != '*' && c != '/')
continue;
-
- cplus_comment = (c == '/');
- putc(c, fguard);
- c = getc(finput);
-
- ended = 0;
- while (!ended)
- {
- if (!cplus_comment && c == '*')
- {
- while (c == '*')
- {
- putc(c, fguard);
- c = getc(finput);
- }
-
- if (c == '/')
- {
- putc(c, fguard);
- ended = 1;
- }
- }
- else if (c == '\n')
- {
- lineno++;
- putc(c, fguard);
- if (cplus_comment)
- ended = 1;
- else
- c = getc(finput);
- }
- else if (c == EOF)
- fatal(_("unterminated comment"));
- else
- {
- putc(c, fguard);
- c = getc(finput);
- }
- }
-
+ copy_comment (finput, fguard, c);
break;
case '$':
register int c;
register int n;
register int count;
- register int match;
- register int ended;
register char *type_name;
- int cplus_comment;
/* offset is always 0 if parser has already popped the stack pointer */
if (semantic_parser)
c = getc(finput);
if (c != '*' && c != '/')
continue;
-
- cplus_comment = (c == '/');
- putc(c, faction);
- c = getc(finput);
-
- ended = 0;
- while (!ended)
- {
- if (!cplus_comment && c == '*')
- {
- while (c == '*')
- {
- putc(c, faction);
- c = getc(finput);
- }
-
- if (c == '/')
- {
- putc(c, faction);
- ended = 1;
- }
- }
- else if (c == '\n')
- {
- lineno++;
- putc(c, faction);
- if (cplus_comment)
- ended = 1;
- else
- c = getc(finput);
- }
- else if (c == EOF)
- fatal(_("unterminated comment"));
- else
- {
- putc(c, faction);
- c = getc(finput);
- }
- }
-
+ copy_comment (finput, faction, c);
break;
case '$':