- skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE);
- fskel = xfopen (skeleton, "r");
-
- /* Set LINE to 2, not 1: `#line LINENUM' -- Here LINENUM is a
- decimal integer constant. This specifies that the line number of
- the *following* line of input, in its original source file, was
- LINENUM. */
- line = 2;
-
- while (1)
- {
- enum line_type_e
- {
- regular_line,
- sync_line, /* #line. */
- actions_line /* %% actions. */
- };
- enum line_type_e line_type = regular_line;
-
- c = getc (fskel);
-
- /* Is this line special? */
- if (c == '#')
- {
- /* See if it's a `#line' line. */
- if ((c = getc (fskel)) == 'l')
- if ((c = getc (fskel)) == 'i')
- if ((c = getc (fskel)) == 'n')
- if ((c = getc (fskel)) == 'e')
- line_type = sync_line;
- else
- obstack_sgrow (&table_obstack, "#lin");
- else
- obstack_sgrow (&table_obstack, "#li");
- else
- obstack_sgrow (&table_obstack, "#l");
- else
- obstack_sgrow (&table_obstack, "#");
- }
- else if (c == '%')
- {
- /* See if it's a `%% actions' line. */
- if ((c = getc (fskel)) == '%')
- if ((c = getc (fskel)) == ' ')
- if ((c = getc (fskel)) == 'a')
- if ((c = getc (fskel)) == 'c')
- if ((c = getc (fskel)) == 't')
- if ((c = getc (fskel)) == 'i')
- if ((c = getc (fskel)) == 'o')
- if ((c = getc (fskel)) == 'n')
- if ((c = getc (fskel)) == 's')
- line_type = actions_line;
- else
- obstack_sgrow (&table_obstack, "%% action");
- else
- obstack_sgrow (&table_obstack, "%% actio");
- else
- obstack_sgrow (&table_obstack, "%% acti");
- else
- obstack_sgrow (&table_obstack, "%% act");
- else
- obstack_sgrow (&table_obstack, "%% ac");
- else
- obstack_sgrow (&table_obstack, "%% a");
- else
- obstack_sgrow (&table_obstack, "%% ");
- else
- obstack_sgrow (&table_obstack, "%%");
- else
- obstack_sgrow (&table_obstack, "%");
- }
-
- switch (line_type)
- {
- case sync_line:
- if (!no_lines_flag)
- obstack_fgrow2 (&table_obstack, "#line %d %s\n",
- line, quotearg_style (c_quoting_style, skeleton));
-
- /* Skip the end of line. */
- for (; c != '\n' && c != EOF; c = getc (fskel))
- /* nothing */;
- break;
-
- case actions_line:
- {
- size_t size = obstack_object_size (&action_obstack);
-
- actions_dumped++;
- assert (actions_dumped == 1);
- obstack_grow (&table_obstack,
- obstack_finish (&action_obstack),
- size);
- }
-
- /* Skip the end of line. */
- for (; c != '\n' && c != EOF; c = getc (fskel))
- /* nothing */;
- break;
+ sprintf (full_skeleton, "%s/%s", bison_pkgdatadir, skeleton);
+ if (trace_flag)
+ fprintf (stderr,
+ "running: %s -I %s m4sugar/m4sugar.m4 %s %s\n",
+ m4, bison_pkgdatadir, definitions, full_skeleton);
+ skel_in = readpipe (m4,
+ "-I", bison_pkgdatadir,
+ "m4sugar/m4sugar.m4",
+ definitions,
+ full_skeleton,
+ NULL);
+ XFREE (full_skeleton);
+ if (!skel_in)
+ error (EXIT_FAILURE, errno, "cannot run m4");
+ skel_lex ();
+}