gengtype-lex.l: Remove all rules and states relating to yacc input files.
* gengtype-lex.l: Remove all rules and states relating to yacc input files. * gengtype-yacc.y: Similarly. * gengtype.c (note_yacc_type): Delete function. * gengtype.h: Update prototypes. From-SVN: r123226
This commit is contained in:
parent
0227f9b9b2
commit
cff4720f62
|
@ -1,3 +1,11 @@
|
||||||
|
2007-03-26 Zack Weinberg <zackw@panix.com>
|
||||||
|
|
||||||
|
* gengtype-lex.l: Remove all rules and states relating to yacc
|
||||||
|
input files.
|
||||||
|
* gengtype-yacc.y: Similarly.
|
||||||
|
* gengtype.c (note_yacc_type): Delete function.
|
||||||
|
* gengtype.h: Update prototypes.
|
||||||
|
|
||||||
2007-03-26 Joseph Myers <joseph@codesourcery.com>
|
2007-03-26 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* tree-pretty-print.c (dump_generic_node): Report precision of
|
* tree-pretty-print.c (dump_generic_node): Report precision of
|
||||||
|
|
|
@ -57,7 +57,7 @@ WS [[:space:]]+
|
||||||
IWORD short|long|(un)?signed|char|int|HOST_WIDE_INT|HOST_WIDEST_INT|bool|size_t|BOOL_BITFIELD
|
IWORD short|long|(un)?signed|char|int|HOST_WIDE_INT|HOST_WIDEST_INT|bool|size_t|BOOL_BITFIELD
|
||||||
ITYPE {IWORD}({WS}{IWORD})*
|
ITYPE {IWORD}({WS}{IWORD})*
|
||||||
|
|
||||||
%x in_struct in_struct_comment in_comment in_yacc_escape
|
%x in_struct in_struct_comment in_comment
|
||||||
%option warn noyywrap nounput nodefault perf-report
|
%option warn noyywrap nounput nodefault perf-report
|
||||||
%option 8bit never-interactive
|
%option 8bit never-interactive
|
||||||
%%
|
%%
|
||||||
|
@ -233,12 +233,6 @@ ITYPE {IWORD}({WS}{IWORD})*
|
||||||
return ENT_EXTERNSTATIC;
|
return ENT_EXTERNSTATIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
^"%union"{WS}"{"{WS}/"GTY" {
|
|
||||||
BEGIN(in_struct);
|
|
||||||
update_lineno (yytext, yyleng);
|
|
||||||
return ENT_YACCUNION;
|
|
||||||
}
|
|
||||||
|
|
||||||
^"DEF_VEC_"[[:alnum:]_]*{WS}?"("{WS}?{ID}{WS}?(","{WS}?{ID}{WS}?)*")" {
|
^"DEF_VEC_"[[:alnum:]_]*{WS}?"("{WS}?{ID}{WS}?(","{WS}?{ID}{WS}?)*")" {
|
||||||
char *macro, *arg;
|
char *macro, *arg;
|
||||||
unsigned macro_len, arg_len;
|
unsigned macro_len, arg_len;
|
||||||
|
@ -279,8 +273,6 @@ ITYPE {IWORD}({WS}{IWORD})*
|
||||||
|
|
||||||
"/*" { BEGIN(in_struct_comment); }
|
"/*" { BEGIN(in_struct_comment); }
|
||||||
|
|
||||||
^"%{" { BEGIN(in_yacc_escape); } /* } */
|
|
||||||
|
|
||||||
{WS} { update_lineno (yytext, yyleng); }
|
{WS} { update_lineno (yytext, yyleng); }
|
||||||
|
|
||||||
"const"/[^[:alnum:]_] /* don't care */
|
"const"/[^[:alnum:]_] /* don't care */
|
||||||
|
@ -342,10 +334,6 @@ ITYPE {IWORD}({WS}{IWORD})*
|
||||||
yylval.s = (const char *) xmemdup (yytext+1, yyleng-2, yyleng-1);
|
yylval.s = (const char *) xmemdup (yytext+1, yyleng-2, yyleng-1);
|
||||||
return ARRAY;
|
return ARRAY;
|
||||||
}
|
}
|
||||||
^"%"{ID} {
|
|
||||||
yylval.s = (const char *) xmemdup (yytext+1, yyleng-1, yyleng);
|
|
||||||
return PERCENT_ID;
|
|
||||||
}
|
|
||||||
"'"("\\".|[^\\])"'" {
|
"'"("\\".|[^\\])"'" {
|
||||||
yylval.s = (const char *) xmemdup (yytext+1, yyleng-2, yyleng);
|
yylval.s = (const char *) xmemdup (yytext+1, yyleng-2, yyleng);
|
||||||
return CHAR;
|
return CHAR;
|
||||||
|
@ -362,11 +350,6 @@ ITYPE {IWORD}({WS}{IWORD})*
|
||||||
return yytext[0];
|
return yytext[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
^"%%" {
|
|
||||||
BEGIN(INITIAL);
|
|
||||||
return PERCENTPERCENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
"#define"[^\n]*\n {lexer_line.line++;}
|
"#define"[^\n]*\n {lexer_line.line++;}
|
||||||
|
|
||||||
. {
|
. {
|
||||||
|
@ -391,19 +374,6 @@ ITYPE {IWORD}({WS}{IWORD})*
|
||||||
<in_comment>"*/" { BEGIN(INITIAL); }
|
<in_comment>"*/" { BEGIN(INITIAL); }
|
||||||
<in_struct_comment>"*/" { BEGIN(in_struct); }
|
<in_struct_comment>"*/" { BEGIN(in_struct); }
|
||||||
|
|
||||||
<in_yacc_escape>{
|
|
||||||
\n { lexer_line.line++; }
|
|
||||||
[^%]{16} |
|
|
||||||
[^%] /* do nothing */
|
|
||||||
"%"/[^}] /* do nothing */
|
|
||||||
"%}" { BEGIN(in_struct); }
|
|
||||||
"%" {
|
|
||||||
error_at_line (&lexer_line,
|
|
||||||
"unterminated %%{; unexpected EOF");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
["/] |
|
["/] |
|
||||||
<in_struct_comment,in_comment>"*" {
|
<in_struct_comment,in_comment>"*" {
|
||||||
error_at_line (&lexer_line,
|
error_at_line (&lexer_line,
|
||||||
|
|
|
@ -38,7 +38,6 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
%token <t>ENT_TYPEDEF_STRUCT
|
%token <t>ENT_TYPEDEF_STRUCT
|
||||||
%token <t>ENT_STRUCT
|
%token <t>ENT_STRUCT
|
||||||
%token ENT_EXTERNSTATIC
|
%token ENT_EXTERNSTATIC
|
||||||
%token ENT_YACCUNION
|
|
||||||
%token GTY_TOKEN
|
%token GTY_TOKEN
|
||||||
%token UNION
|
%token UNION
|
||||||
%token STRUCT
|
%token STRUCT
|
||||||
|
@ -47,15 +46,13 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
%token NESTED_PTR
|
%token NESTED_PTR
|
||||||
%token <s>PARAM_IS
|
%token <s>PARAM_IS
|
||||||
%token NUM
|
%token NUM
|
||||||
%token PERCENTPERCENT "%%"
|
|
||||||
%token <t>SCALAR
|
%token <t>SCALAR
|
||||||
%token <s>ID
|
%token <s>ID
|
||||||
%token <s>STRING
|
%token <s>STRING
|
||||||
%token <s>ARRAY
|
%token <s>ARRAY
|
||||||
%token <s>PERCENT_ID
|
|
||||||
%token <s>CHAR
|
%token <s>CHAR
|
||||||
|
|
||||||
%type <p> struct_fields yacc_ids yacc_typematch
|
%type <p> struct_fields
|
||||||
%type <t> type lasttype
|
%type <t> type lasttype
|
||||||
%type <o> optionsopt options option optionseq optionseqopt
|
%type <o> optionsopt options option optionseq optionseqopt
|
||||||
%type <s> type_option stringseq
|
%type <s> type_option stringseq
|
||||||
|
@ -65,7 +62,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
start: /* empty */
|
start: /* empty */
|
||||||
| typedef_struct start
|
| typedef_struct start
|
||||||
| externstatic start
|
| externstatic start
|
||||||
| yacc_union start
|
| start
|
||||||
;
|
;
|
||||||
|
|
||||||
typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID
|
typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID
|
||||||
|
@ -116,72 +113,6 @@ semiequal: ';'
|
||||||
| '='
|
| '='
|
||||||
;
|
;
|
||||||
|
|
||||||
yacc_union: ENT_YACCUNION options struct_fields '}' yacc_typematch
|
|
||||||
PERCENTPERCENT
|
|
||||||
{
|
|
||||||
note_yacc_type ($2, $3, $5, &lexer_line);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
yacc_typematch: /* empty */
|
|
||||||
{ $$ = NULL; }
|
|
||||||
| yacc_typematch PERCENT_ID yacc_ids
|
|
||||||
{
|
|
||||||
pair_p p;
|
|
||||||
for (p = $3; p->next != NULL; p = p->next)
|
|
||||||
{
|
|
||||||
p->name = NULL;
|
|
||||||
p->type = NULL;
|
|
||||||
}
|
|
||||||
p->name = NULL;
|
|
||||||
p->type = NULL;
|
|
||||||
p->next = $1;
|
|
||||||
$$ = $3;
|
|
||||||
}
|
|
||||||
| yacc_typematch PERCENT_ID '<' ID '>' yacc_ids
|
|
||||||
{
|
|
||||||
pair_p p;
|
|
||||||
type_p newtype = NULL;
|
|
||||||
if (strcmp ($2, "type") == 0)
|
|
||||||
newtype = (type_p) 1;
|
|
||||||
for (p = $6; p->next != NULL; p = p->next)
|
|
||||||
{
|
|
||||||
p->name = $4;
|
|
||||||
p->type = newtype;
|
|
||||||
}
|
|
||||||
p->name = $4;
|
|
||||||
p->next = $1;
|
|
||||||
p->type = newtype;
|
|
||||||
$$ = $6;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
yacc_ids: /* empty */
|
|
||||||
{ $$ = NULL; }
|
|
||||||
| yacc_ids ID
|
|
||||||
{
|
|
||||||
pair_p p = XCNEW (struct pair);
|
|
||||||
p->next = $1;
|
|
||||||
p->line = lexer_line;
|
|
||||||
p->opt = XNEW (struct options);
|
|
||||||
p->opt->name = "tag";
|
|
||||||
p->opt->next = NULL;
|
|
||||||
p->opt->info = (char *)$2;
|
|
||||||
$$ = p;
|
|
||||||
}
|
|
||||||
| yacc_ids CHAR
|
|
||||||
{
|
|
||||||
pair_p p = XCNEW (struct pair);
|
|
||||||
p->next = $1;
|
|
||||||
p->line = lexer_line;
|
|
||||||
p->opt = XNEW (struct options);
|
|
||||||
p->opt->name = "tag";
|
|
||||||
p->opt->next = NULL;
|
|
||||||
p->opt->info = xasprintf ("'%s'", $2);
|
|
||||||
$$ = p;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
struct_fields: { $$ = NULL; }
|
struct_fields: { $$ = NULL; }
|
||||||
| type optionsopt ID bitfieldopt ';' struct_fields
|
| type optionsopt ID bitfieldopt ';' struct_fields
|
||||||
{
|
{
|
||||||
|
|
|
@ -810,65 +810,6 @@ adjust_field_type (type_p t, options_p opt)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a union for YYSTYPE, as yacc would do it, given a fieldlist FIELDS
|
|
||||||
and information about the correspondence between token types and fields
|
|
||||||
in TYPEINFO. POS is used for error messages. */
|
|
||||||
|
|
||||||
void
|
|
||||||
note_yacc_type (options_p o, pair_p fields, pair_p typeinfo,
|
|
||||||
struct fileloc *pos)
|
|
||||||
{
|
|
||||||
pair_p p;
|
|
||||||
pair_p *p_p;
|
|
||||||
|
|
||||||
for (p = typeinfo; p; p = p->next)
|
|
||||||
{
|
|
||||||
pair_p m;
|
|
||||||
|
|
||||||
if (p->name == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (p->type == (type_p) 1)
|
|
||||||
{
|
|
||||||
pair_p pp;
|
|
||||||
int ok = 0;
|
|
||||||
|
|
||||||
for (pp = typeinfo; pp; pp = pp->next)
|
|
||||||
if (pp->type != (type_p) 1
|
|
||||||
&& strcmp (pp->opt->info, p->opt->info) == 0)
|
|
||||||
{
|
|
||||||
ok = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (! ok)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (m = fields; m; m = m->next)
|
|
||||||
if (strcmp (m->name, p->name) == 0)
|
|
||||||
p->type = m->type;
|
|
||||||
if (p->type == NULL)
|
|
||||||
{
|
|
||||||
error_at_line (&p->line,
|
|
||||||
"couldn't match fieldname `%s'", p->name);
|
|
||||||
p->name = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p_p = &typeinfo;
|
|
||||||
while (*p_p)
|
|
||||||
{
|
|
||||||
pair_p p = *p_p;
|
|
||||||
|
|
||||||
if (p->name == NULL
|
|
||||||
|| p->type == (type_p) 1)
|
|
||||||
*p_p = p->next;
|
|
||||||
else
|
|
||||||
p_p = &p->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
do_typedef ("YYSTYPE", new_structure ("yy_union", 1, pos, typeinfo, o), pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_gc_used_type (type_p, enum gc_used_enum, type_p *);
|
static void set_gc_used_type (type_p, enum gc_used_enum, type_p *);
|
||||||
static void set_gc_used (pair_p);
|
static void set_gc_used (pair_p);
|
||||||
|
|
|
@ -144,8 +144,6 @@ extern options_p create_option (options_p, const char *name, const void *info);
|
||||||
extern type_p adjust_field_type (type_p, options_p);
|
extern type_p adjust_field_type (type_p, options_p);
|
||||||
extern void note_variable (const char *s, type_p t, options_p o,
|
extern void note_variable (const char *s, type_p t, options_p o,
|
||||||
struct fileloc *pos);
|
struct fileloc *pos);
|
||||||
extern void note_yacc_type (options_p o, pair_p fields,
|
|
||||||
pair_p typeinfo, struct fileloc *pos);
|
|
||||||
|
|
||||||
/* Lexer and parser routines, most automatically generated. */
|
/* Lexer and parser routines, most automatically generated. */
|
||||||
extern int yylex (void);
|
extern int yylex (void);
|
||||||
|
|
Loading…
Reference in New Issue