697 |
238, 255, 264, 266, 286, 300, 302, 322, 334, 338, |
238, 255, 264, 266, 286, 300, 302, 322, 334, 338, |
698 |
339, 340, 341, 342, 343, 344, 345, 346, 361, 367, |
339, 340, 341, 342, 343, 344, 345, 346, 361, 367, |
699 |
368, 370, 388, 394, 395, 397, 415, 418, 421, 422, |
368, 370, 388, 394, 395, 397, 415, 418, 421, 422, |
700 |
433, 444, 446, 458, 460, 461, 464, 484, 491, 492, |
433, 444, 446, 448, 451, 452, 455, 475, 482, 483, |
701 |
493, 514 |
484, 505 |
702 |
|
|
703 |
} ; |
} ; |
704 |
|
|
789 |
} |
} |
790 |
|
|
791 |
|
|
|
|
|
792 |
static int braces_level = 0; |
static int braces_level = 0; |
793 |
static int percent_percent_count = 0; |
static int percent_percent_count = 0; |
794 |
|
|
795 |
static void handle_action_dollar PARAMS ((char *cp, location_t location)); |
static void handle_dollar PARAMS ((braced_code_t code_kind, |
796 |
static void handle_destructor_dollar PARAMS ((char *cp, location_t location)); |
char *cp, location_t location)); |
797 |
static void handle_at PARAMS ((char *cp)); |
static void handle_at PARAMS ((braced_code_t code_kind, |
798 |
|
char *cp, location_t location)); |
799 |
|
|
800 |
#define SC_COMMENT 1 |
#define SC_COMMENT 1 |
801 |
|
|
1705 |
case 83: |
case 83: |
1706 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1707 |
#line 446 "scan-gram.l" |
#line 446 "scan-gram.l" |
1708 |
{ |
{ handle_dollar (current_braced_code, |
1709 |
switch (current_braced_code) |
yytext, *yylloc); } |
|
{ |
|
|
case action_braced_code: |
|
|
handle_action_dollar (yytext, *yylloc); |
|
|
break; |
|
|
|
|
|
case destructor_braced_code: |
|
|
handle_destructor_dollar (yytext, *yylloc); |
|
|
break; |
|
|
} |
|
|
} |
|
1710 |
YY_BREAK |
YY_BREAK |
1711 |
case 84: |
case 84: |
1712 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1713 |
#line 458 "scan-gram.l" |
#line 448 "scan-gram.l" |
1714 |
{ handle_at (yytext); } |
{ handle_at (current_braced_code, |
1715 |
|
yytext, *yylloc); } |
1716 |
YY_BREAK |
YY_BREAK |
1717 |
case 85: |
case 85: |
1718 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1719 |
#line 460 "scan-gram.l" |
#line 451 "scan-gram.l" |
1720 |
YY_OBS_GROW; |
YY_OBS_GROW; |
1721 |
YY_BREAK |
YY_BREAK |
1722 |
case 86: |
case 86: |
1723 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1724 |
#line 461 "scan-gram.l" |
#line 452 "scan-gram.l" |
1725 |
YY_OBS_GROW; YY_LINES; |
YY_OBS_GROW; YY_LINES; |
1726 |
YY_BREAK |
YY_BREAK |
1727 |
/* A lose $, or /, or etc. */ |
/* A lose $, or /, or etc. */ |
1728 |
case 87: |
case 87: |
1729 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1730 |
#line 464 "scan-gram.l" |
#line 455 "scan-gram.l" |
1731 |
YY_OBS_GROW; |
YY_OBS_GROW; |
1732 |
YY_BREAK |
YY_BREAK |
1733 |
case YY_STATE_EOF(SC_BRACED_CODE): |
case YY_STATE_EOF(SC_BRACED_CODE): |
1734 |
#line 466 "scan-gram.l" |
#line 457 "scan-gram.l" |
1735 |
{ |
{ |
1736 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
1737 |
fprintf (stderr, ": unexpected end of file in a braced code\n"); |
fprintf (stderr, ": unexpected end of file in a braced code\n"); |
1749 |
|
|
1750 |
case 88: |
case 88: |
1751 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1752 |
#line 484 "scan-gram.l" |
#line 475 "scan-gram.l" |
1753 |
{ |
{ |
1754 |
yy_pop_state (); |
yy_pop_state (); |
1755 |
YY_OBS_FINISH; |
YY_OBS_FINISH; |
1759 |
YY_BREAK |
YY_BREAK |
1760 |
case 89: |
case 89: |
1761 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1762 |
#line 491 "scan-gram.l" |
#line 482 "scan-gram.l" |
1763 |
YY_OBS_GROW; |
YY_OBS_GROW; |
1764 |
YY_BREAK |
YY_BREAK |
1765 |
case 90: |
case 90: |
1766 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1767 |
#line 492 "scan-gram.l" |
#line 483 "scan-gram.l" |
1768 |
YY_OBS_GROW; |
YY_OBS_GROW; |
1769 |
YY_BREAK |
YY_BREAK |
1770 |
case 91: |
case 91: |
1771 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1772 |
#line 493 "scan-gram.l" |
#line 484 "scan-gram.l" |
1773 |
YY_OBS_GROW; YY_LINES; |
YY_OBS_GROW; YY_LINES; |
1774 |
YY_BREAK |
YY_BREAK |
1775 |
case YY_STATE_EOF(SC_PROLOGUE): |
case YY_STATE_EOF(SC_PROLOGUE): |
1776 |
#line 495 "scan-gram.l" |
#line 486 "scan-gram.l" |
1777 |
{ |
{ |
1778 |
LOCATION_PRINT (stderr, *yylloc); |
LOCATION_PRINT (stderr, *yylloc); |
1779 |
fprintf (stderr, ": unexpected end of file in a prologue\n"); |
fprintf (stderr, ": unexpected end of file in a prologue\n"); |
1792 |
|
|
1793 |
case 92: |
case 92: |
1794 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1795 |
#line 514 "scan-gram.l" |
#line 505 "scan-gram.l" |
1796 |
YY_OBS_GROW; |
YY_OBS_GROW; |
1797 |
YY_BREAK |
YY_BREAK |
1798 |
case YY_STATE_EOF(SC_EPILOGUE): |
case YY_STATE_EOF(SC_EPILOGUE): |
1799 |
#line 516 "scan-gram.l" |
#line 507 "scan-gram.l" |
1800 |
{ |
{ |
1801 |
yy_pop_state (); |
yy_pop_state (); |
1802 |
YY_OBS_FINISH; |
YY_OBS_FINISH; |
1807 |
|
|
1808 |
case 93: |
case 93: |
1809 |
YY_RULE_SETUP |
YY_RULE_SETUP |
1810 |
#line 525 "scan-gram.l" |
#line 516 "scan-gram.l" |
1811 |
YY_FATAL_ERROR( "flex scanner jammed" ); |
YY_FATAL_ERROR( "flex scanner jammed" ); |
1812 |
YY_BREAK |
YY_BREAK |
1813 |
#line 1823 "lex.yy.c" |
#line 1814 "lex.yy.c" |
1814 |
case YY_STATE_EOF(INITIAL): |
case YY_STATE_EOF(INITIAL): |
1815 |
yyterminate(); |
yyterminate(); |
1816 |
|
|
2700 |
return 0; |
return 0; |
2701 |
} |
} |
2702 |
#endif |
#endif |
2703 |
#line 525 "scan-gram.l" |
#line 516 "scan-gram.l" |
2704 |
|
|
2705 |
|
|
2706 |
/*------------------------------------------------------------------. |
/*------------------------------------------------------------------. |
2711 |
| Output to the STRING_OBSTACK a reference to this semantic value. | |
| Output to the STRING_OBSTACK a reference to this semantic value. | |
2712 |
`------------------------------------------------------------------*/ |
`------------------------------------------------------------------*/ |
2713 |
|
|
2714 |
static void |
static inline void |
2715 |
handle_action_dollar (char *cp, location_t location) |
handle_action_dollar (char *cp, location_t location) |
2716 |
{ |
{ |
2717 |
const char *type_name = NULL; |
const char *type_name = NULL; |
2775 |
} |
} |
2776 |
|
|
2777 |
|
|
2778 |
/*---------------------------------------------------------------. |
/*---------------------------------------. |
2779 |
| CP is pointing to $$ in a destructor. This should probably be | |
| CP is pointing to $$ in a destructor. | |
2780 |
| done once the grammar completely parsed, instead of during its | |
`---------------------------------------*/ |
|
| parsing, since that means %type must be specified before | |
|
|
| %destructor. | |
|
|
`---------------------------------------------------------------*/ |
|
2781 |
|
|
2782 |
static void |
static inline void |
2783 |
handle_destructor_dollar (char *cp, location_t location) |
handle_destructor_dollar (char *cp, location_t location) |
2784 |
{ |
{ |
2785 |
++cp; |
++cp; |
2786 |
if (*cp == '$') |
if (*cp == '$') |
2787 |
{ |
{ |
2788 |
/* FIXME: We should find something more robust. */ |
obstack_sgrow (&string_obstack, "]b4_dollar_dollar["); |
|
obstack_sgrow (&string_obstack, "b4_dollar_dollar"); |
|
2789 |
} |
} |
2790 |
else |
else |
2791 |
{ |
{ |
2795 |
} |
} |
2796 |
} |
} |
2797 |
|
|
2798 |
/*-------------------------------------------------------. |
|
2799 |
| CP is pointing to a location (i.e., a `@'). Output to | |
/*-----------------------------------------------------------------. |
2800 |
| STRING_OBSTACK a reference to this location. | |
| Dispatch onto handle_action_dollar, or handle_destructor_dollar, | |
2801 |
`-------------------------------------------------------*/ |
| depending upon CODE_KIND. | |
2802 |
|
`-----------------------------------------------------------------*/ |
2803 |
|
|
2804 |
static void |
static void |
2805 |
handle_at (char *cp) |
handle_dollar (braced_code_t braced_code_kind, |
2806 |
|
char *text, location_t location) |
2807 |
|
{ |
2808 |
|
switch (braced_code_kind) |
2809 |
|
{ |
2810 |
|
case action_braced_code: |
2811 |
|
handle_action_dollar (text, location); |
2812 |
|
break; |
2813 |
|
|
2814 |
|
case destructor_braced_code: |
2815 |
|
handle_destructor_dollar (text, location); |
2816 |
|
break; |
2817 |
|
} |
2818 |
|
} |
2819 |
|
|
2820 |
|
|
2821 |
|
/*------------------------------------------------------. |
2822 |
|
| TEXT is a location token (i.e., a `@...'). Output to | |
2823 |
|
| STRING_OBSTACK a reference to this location. | |
2824 |
|
`------------------------------------------------------*/ |
2825 |
|
|
2826 |
|
static inline void |
2827 |
|
handle_action_at (char *text, location_t location) |
2828 |
{ |
{ |
2829 |
locations_flag = 1; |
locations_flag = 1; |
2830 |
++cp; |
++text; |
2831 |
|
|
2832 |
if (*cp == '$') |
if (*text == '$') |
2833 |
{ |
{ |
2834 |
obstack_sgrow (&string_obstack, "]b4_lhs_location["); |
obstack_sgrow (&string_obstack, "]b4_lhs_location["); |
2835 |
} |
} |
2836 |
else if (isdigit (*cp) || *cp == '-') |
else if (isdigit (*text) || *text == '-') |
2837 |
{ |
{ |
2838 |
/* RULE_LENGTH is the number of values in the current rule so |
/* RULE_LENGTH is the number of values in the current rule so |
2839 |
far, which says where to find `$0' with respect to the top of |
far, which says where to find `$0' with respect to the top of |
2840 |
the stack. It is not the same as the rule->length in the |
the stack. It is not the same as the rule->length in the |
2841 |
case of mid rule actions. */ |
case of mid rule actions. */ |
2842 |
int rule_length = symbol_list_length (current_rule->next); |
int rule_length = symbol_list_length (current_rule->next); |
2843 |
int n = strtol (cp, &cp, 10); |
int n = strtol (text, &text, 10); |
2844 |
|
|
2845 |
if (n > rule_length) |
if (n > rule_length) |
2846 |
complain (_("invalid value: %s%d"), "@", n); |
complain_at (location, _("invalid value: %s%d"), "@", n); |
2847 |
else |
else |
2848 |
obstack_fgrow2 (&string_obstack, "]b4_rhs_location([%d], [%d])[", |
obstack_fgrow2 (&string_obstack, "]b4_rhs_location([%d], [%d])[", |
2849 |
rule_length, n); |
rule_length, n); |
2851 |
else |
else |
2852 |
{ |
{ |
2853 |
char buf[] = "@c"; |
char buf[] = "@c"; |
2854 |
buf[1] = *cp; |
buf[1] = *text; |
2855 |
complain (_("%s is invalid"), quote (buf)); |
complain_at (location, _("%s is invalid"), quote (buf)); |
2856 |
} |
} |
2857 |
} |
} |
2858 |
|
|
2859 |
|
|
2860 |
|
/*--------------------------------------------. |
2861 |
|
| TEXT is expexted tp be @$ in a destructor. | |
2862 |
|
`--------------------------------------------*/ |
2863 |
|
|
2864 |
|
static inline void |
2865 |
|
handle_destructor_at (char *text, location_t location) |
2866 |
|
{ |
2867 |
|
++text; |
2868 |
|
if (*text == '$') |
2869 |
|
{ |
2870 |
|
obstack_sgrow (&string_obstack, "]b4_at_dollar["); |
2871 |
|
} |
2872 |
|
else |
2873 |
|
{ |
2874 |
|
char buf[] = "$c"; |
2875 |
|
buf[1] = *text; |
2876 |
|
complain_at (location, _("%s is invalid"), quote (buf)); |
2877 |
|
} |
2878 |
|
} |
2879 |
|
|
2880 |
|
|
2881 |
|
/*-------------------------------------------------------------------. |
2882 |
|
| Dispatch onto handle_action_at, or handle_destructor_at, depending | |
2883 |
|
| upon CODE_KIND. | |
2884 |
|
`-------------------------------------------------------------------*/ |
2885 |
|
|
2886 |
|
static void |
2887 |
|
handle_at (braced_code_t braced_code_kind, |
2888 |
|
char *text, location_t location) |
2889 |
|
{ |
2890 |
|
switch (braced_code_kind) |
2891 |
|
{ |
2892 |
|
case action_braced_code: |
2893 |
|
handle_action_at (text, location); |
2894 |
|
break; |
2895 |
|
|
2896 |
|
case destructor_braced_code: |
2897 |
|
handle_destructor_at (text, location); |
2898 |
|
break; |
2899 |
|
} |
2900 |
|
} |
2901 |
|
|
2902 |
|
|
2903 |
|
/*-------------------------. |
2904 |
|
| Initialize the scanner. | |
2905 |
|
`-------------------------*/ |
2906 |
|
|
2907 |
void |
void |
2908 |
scanner_initialize (void) |
scanner_initialize (void) |
2909 |
{ |
{ |
2911 |
} |
} |
2912 |
|
|
2913 |
|
|
2914 |
|
/*-----------------------------------------------. |
2915 |
|
| Free all the memory allocated to the scanner. | |
2916 |
|
`-----------------------------------------------*/ |
2917 |
|
|
2918 |
void |
void |
2919 |
scanner_free (void) |
scanner_free (void) |
2920 |
{ |
{ |