summaryrefslogtreecommitdiff
path: root/gcc/gengtype-lex.l
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2007-03-26 20:55:10 +0000
committerZack Weinberg <zack@gcc.gnu.org>2007-03-26 20:55:10 +0000
commit95161faf6d635df17a7792840aa73600624b11fb (patch)
tree70749f6a010e63bca65e3197ff3b0ff5b77be848 /gcc/gengtype-lex.l
parent4a399aef3a4ddd508c25f73320646d03dfc08660 (diff)
gengtype.h (struct type): Replace 'sc' with boolean, scalar_is_char.
* gengtype.h (struct type): Replace 'sc' with boolean, scalar_is_char. (string_type): Don't declare. (do_scalar_typedef): Declare. (create_scalar_type): Update prototype. * gengtype.c (string_type): Make static. (scalar_nonchar, scalar_char): New. (do_scalar_typedef): Export. Always use scalar_nonchar for the type. (resolve_typedef): Use scalar_nonchar for error recovery. (create_scalar_type): Remove name_len field. Return scalar_char or scalar_nonchar as appropriate. (adjust_field_type): Look at scalar_is_char boolean to decide whether to use string_type. (throughout): Use scalar_nonchar instead of calling create_scalar_type, whenever possible. (main): Initialize scalar_char and scalar_nonchar before calling gen_rtx_next. * gengtype-lex.l: Adjust for removal of second argument to create_scalar_type. Use yylval.s instead of yylval.t when returning SCALAR. * gengtype-yacc.y: Type of SCALAR is string. Call create_scalar_type from type:SCALAR rule. Adjust for removal of second argument to create_scalar_type. From-SVN: r123231
Diffstat (limited to 'gcc/gengtype-lex.l')
-rw-r--r--gcc/gengtype-lex.l20
1 files changed, 8 insertions, 12 deletions
diff --git a/gcc/gengtype-lex.l b/gcc/gengtype-lex.l
index ad4b1d54512..1d136251e10 100644
--- a/gcc/gengtype-lex.l
+++ b/gcc/gengtype-lex.l
@@ -95,7 +95,6 @@ ITYPE {IWORD}({WS}{IWORD})*
char *namestart;
size_t namelen;
- struct type *t;
char *typestart;
size_t typelen;
@@ -112,9 +111,10 @@ ITYPE {IWORD}({WS}{IWORD})*
ISSPACE (typestart[typelen-1]);
typelen--)
;
+ typestart[typelen] = '\0';
- t = create_scalar_type (typestart, typelen);
- do_typedef ((const char *) xmemdup (namestart, namelen, namelen+1), t,
+ do_typedef ((const char *) xmemdup (namestart, namelen, namelen+1),
+ create_scalar_type (typestart),
&lexer_line);
update_lineno (yytext, yyleng);
}
@@ -122,7 +122,6 @@ ITYPE {IWORD}({WS}{IWORD})*
[^[:alnum:]_]typedef{WS}{ID}{WS}{ID}{WS}"(" {
char *namestart;
size_t namelen;
- struct type *t;
for (namestart = yytext + yyleng - 2; ISSPACE (*namestart); namestart--)
;
@@ -130,16 +129,14 @@ ITYPE {IWORD}({WS}{IWORD})*
;
namestart -= namelen - 1;
- t = create_scalar_type ("function type", sizeof ("function type")-1);
- do_typedef ((const char *) xmemdup (namestart, namelen, namelen+1), t,
- &lexer_line);
+ do_scalar_typedef ((const char *) xmemdup (namestart, namelen, namelen+1),
+ &lexer_line);
update_lineno (yytext, yyleng);
}
[^[:alnum:]_]typedef{WS}{ID}{WS}?"*"?{WS}?"("{WS}?"*"{WS}?{ID}{WS}?")"{WS}?"(" {
char *namestart;
size_t namelen;
- struct type *t;
for (namestart = yytext + yyleng - 2; !ISIDNUM (*namestart); namestart--)
;
@@ -147,9 +144,8 @@ ITYPE {IWORD}({WS}{IWORD})*
;
namestart -= namelen - 1;
- t = create_scalar_type ("function type", sizeof ("function type")-1);
- do_typedef ((const char *) xmemdup (namestart, namelen, namelen+1), t,
- &lexer_line);
+ do_scalar_typedef ((const char *) xmemdup (namestart, namelen, namelen+1),
+ &lexer_line);
update_lineno (yytext, yyleng);
}
@@ -270,7 +266,7 @@ ITYPE {IWORD}({WS}{IWORD})*
for (len = yyleng; ISSPACE (yytext[len-1]); len--)
;
- yylval.t = create_scalar_type (yytext, len);
+ yylval.s = (const char *) xmemdup (yytext, len, len+1);
update_lineno (yytext, yyleng);
return SCALAR;
}