567 |
} |
} |
568 |
|
|
569 |
|
|
570 |
|
/*---------------------------------------. |
571 |
|
| Output the tokens definition to OOUT. | |
572 |
|
`---------------------------------------*/ |
573 |
|
|
574 |
|
static void |
575 |
|
token_definitions_output (FILE *out, size_t *line) |
576 |
|
{ |
577 |
|
int i; |
578 |
|
for (i = 0; i < ntokens; ++i) |
579 |
|
{ |
580 |
|
bucket *symbol = symbols[i]; |
581 |
|
int number = symbol->user_token_number; |
582 |
|
|
583 |
|
if (number == SALIAS) |
584 |
|
continue; |
585 |
|
/* Skip error token. */ |
586 |
|
if (symbol->value == error_token_number) |
587 |
|
continue; |
588 |
|
if (symbol->tag[0] == '\'') |
589 |
|
continue; /* skip literal character */ |
590 |
|
if (symbol->tag[0] == '\"') |
591 |
|
{ |
592 |
|
/* use literal string only if given a symbol with an alias */ |
593 |
|
if (symbol->alias) |
594 |
|
symbol = symbol->alias; |
595 |
|
else |
596 |
|
continue; |
597 |
|
} |
598 |
|
|
599 |
|
/* Don't #define nonliteral tokens whose names contain periods |
600 |
|
or '$' (as does the default value of the EOF token). */ |
601 |
|
if (strchr (symbol->tag, '.') || strchr (symbol->tag, '$')) |
602 |
|
continue; |
603 |
|
|
604 |
|
fprintf (out, "# define %s\t%d\n", |
605 |
|
symbol->tag, number); |
606 |
|
++*line; |
607 |
|
if (semantic_parser) |
608 |
|
{ |
609 |
|
/* FIXME: This is probably wrong, and should be just as |
610 |
|
above. --akim. */ |
611 |
|
fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->value); |
612 |
|
++*line; |
613 |
|
} |
614 |
|
} |
615 |
|
} |
616 |
|
|
617 |
|
|
618 |
static void |
static void |
619 |
save_column (int symbol, int default_state) |
save_column (int symbol, int default_state) |
620 |
{ |
{ |
1011 |
guards_output (out, &output_line); |
guards_output (out, &output_line); |
1012 |
else if (!strcmp (muscle_key, "line")) |
else if (!strcmp (muscle_key, "line")) |
1013 |
fprintf (out, "%d", output_line); |
fprintf (out, "%d", output_line); |
1014 |
|
else if (!strcmp (muscle_key, "tokendef")) |
1015 |
|
token_definitions_output (out, &output_line); |
1016 |
else if (!strcmp (muscle_key, "skeleton-line")) |
else if (!strcmp (muscle_key, "skeleton-line")) |
1017 |
fprintf (out, "%d", skeleton_line); |
fprintf (out, "%d", skeleton_line); |
1018 |
else if (muscle_value) |
else if (muscle_value) |
1109 |
static void |
static void |
1110 |
header_output (void) |
header_output (void) |
1111 |
{ |
{ |
1112 |
|
size_t dummy_line; |
1113 |
FILE *out = xfopen (spec_defines_file, "w"); |
FILE *out = xfopen (spec_defines_file, "w"); |
1114 |
char *macro_name = compute_header_macro (); |
char *macro_name = compute_header_macro (); |
1115 |
|
|
1116 |
fprintf (out, "#ifndef %s\n", macro_name); |
fprintf (out, "#ifndef %s\n", macro_name); |
1117 |
fprintf (out, "# define %s\n\n", macro_name); |
fprintf (out, "# define %s\n\n", macro_name); |
1118 |
|
|
1119 |
fputs (muscle_find ("tokendef"), out); |
token_definitions_output (out, &dummy_line); |
1120 |
fprintf (out, "\ |
fprintf (out, "\ |
1121 |
#ifndef YYSTYPE\n\ |
#ifndef YYSTYPE\n\ |
1122 |
typedef %s |
typedef %s |