125 |
|
|
126 |
int error_verbose = 0; |
int error_verbose = 0; |
127 |
|
|
128 |
|
/* Returns the number of lines of S. */ |
129 |
|
static size_t |
130 |
|
get_lines_number (const char *s) |
131 |
|
{ |
132 |
|
size_t lines = 0; |
133 |
|
|
134 |
|
size_t i; |
135 |
|
for (i = 0; s[i]; ++i) |
136 |
|
{ |
137 |
|
if (s[i] == '\n') |
138 |
|
++lines; |
139 |
|
} |
140 |
|
|
141 |
|
return lines; |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
/* FIXME. */ |
/* FIXME. */ |
146 |
|
|
147 |
static inline void |
static inline void |
536 |
`-----------------------------*/ |
`-----------------------------*/ |
537 |
|
|
538 |
static void |
static void |
539 |
actions_output (FILE *out) |
actions_output (FILE *out, size_t *line) |
540 |
{ |
{ |
541 |
int rule; |
int rule; |
542 |
for (rule = 1; rule < nrules + 1; ++rule) |
for (rule = 1; rule < nrules + 1; ++rule) |
555 |
fprintf (out, "{ %s%s }\n break;\n\n", |
fprintf (out, "{ %s%s }\n break;\n\n", |
556 |
rule_table[rule].action, |
rule_table[rule].action, |
557 |
yacc_flag ? ";" : ""); |
yacc_flag ? ";" : ""); |
558 |
|
|
559 |
|
/* We always output 5 '\n' per action. */ |
560 |
|
*line += 5; |
561 |
|
/* Get the number of lines written by the user. */ |
562 |
|
*line += get_lines_number (rule_table[rule].action); |
563 |
} |
} |
564 |
} |
} |
565 |
|
|
984 |
muscle_key = obstack_finish (&muscle_obstack); |
muscle_key = obstack_finish (&muscle_obstack); |
985 |
muscle_value = muscle_find (muscle_key); |
muscle_value = muscle_find (muscle_key); |
986 |
if (!strcmp (muscle_key, "actions")) |
if (!strcmp (muscle_key, "actions")) |
987 |
actions_output (out); |
actions_output (out, &line); |
988 |
else if (!strcmp (muscle_key, "line")) |
else if (!strcmp (muscle_key, "line")) |
989 |
fprintf (out, "%d", line + 1); |
fprintf (out, "%d", line); |
990 |
else if (muscle_value) |
else if (muscle_value) |
991 |
fputs (muscle_value, out); |
{ |
992 |
|
fputs (muscle_value, out); |
993 |
|
line += get_lines_number (muscle_value); |
994 |
|
} |
995 |
else |
else |
996 |
{ |
{ |
997 |
fputs ("%%", out); |
fputs ("%%", out); |
1022 |
skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE); |
skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE); |
1023 |
} |
} |
1024 |
muscle_insert ("skeleton", skeleton); |
muscle_insert ("skeleton", skeleton); |
1025 |
|
muscle_insert ("parser-file-name", parser_file_name); |
1026 |
|
|
1027 |
output_parser (skeleton, parser); |
output_parser (skeleton, parser); |
1028 |
xfclose (parser); |
xfclose (parser); |