comparison gcc/gengtype-lex.l @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
15:561a7518be6b 16:04ced10e8804
1 /* -*- indented-text -*- */ 1 /* -*- indented-text -*- */
2 /* Process source files and output type information. 2 /* Process source files and output type information.
3 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 3 Copyright (C) 2002-2017 Free Software Foundation, Inc.
4 Free Software Foundation, Inc.
5 4
6 This file is part of GCC. 5 This file is part of GCC.
7 6
8 GCC is free software; you can redistribute it and/or modify it under 7 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free 8 the terms of the GNU General Public License as published by the Free
20 <http://www.gnu.org/licenses/>. */ 19 <http://www.gnu.org/licenses/>. */
21 20
22 %option noinput 21 %option noinput
23 22
24 %{ 23 %{
24 #ifdef HOST_GENERATOR_FILE
25 #include "config.h"
26 #define GENERATOR_FILE 1
27 #else
25 #include "bconfig.h" 28 #include "bconfig.h"
29 #endif
26 #include "system.h" 30 #include "system.h"
27 31
28 #define malloc xmalloc 32 #define malloc xmalloc
29 #define realloc xrealloc 33 #define realloc xrealloc
30 34
44 lexer_line.line++; 48 lexer_line.line++;
45 } 49 }
46 50
47 %} 51 %}
48 52
49 ID [[:alpha:]_][[:alnum:]_]* 53 CID [[:alpha:]_][[:alnum:]_]*
50 WS [[:space:]]+ 54 WS [[:space:]]+
51 HWS [ \t\r\v\f]* 55 HWS [ \t\r\v\f]*
52 IWORD short|long|(un)?signed|char|int|HOST_WIDE_INT|HOST_WIDEST_INT|bool|size_t|BOOL_BITFIELD|CPPCHAR_SIGNED_T|ino_t|dev_t|HARD_REG_SET 56 IWORD short|long|(un)?signed|char|int|HOST_WIDE_INT|uint64_t|int64_t|bool|size_t|BOOL_BITFIELD|CPPCHAR_SIGNED_T|ino_t|dev_t|HARD_REG_SET
53 ITYPE {IWORD}({WS}{IWORD})* 57 ITYPE {IWORD}({WS}{IWORD})*
58 /* Include '::' in identifiers to capture C++ scope qualifiers. */
59 ID {CID}({HWS}::{HWS}{CID})*
54 EOID [^[:alnum:]_] 60 EOID [^[:alnum:]_]
61 CXX_KEYWORD inline|public:|private:|protected:|template|operator|friend|static
55 62
56 %x in_struct in_struct_comment in_comment 63 %x in_struct in_struct_comment in_comment
57 %option warn noyywrap nounput nodefault perf-report 64 %option warn noyywrap nounput nodefault perf-report
58 %option 8bit never-interactive 65 %option 8bit never-interactive
59 %% 66 %%
77 } 84 }
78 ^{HWS}union/{EOID} { 85 ^{HWS}union/{EOID} {
79 BEGIN(in_struct); 86 BEGIN(in_struct);
80 return UNION; 87 return UNION;
81 } 88 }
89 ^{HWS}class/{EOID} {
90 BEGIN(in_struct);
91 return STRUCT;
92 }
82 ^{HWS}extern/{EOID} { 93 ^{HWS}extern/{EOID} {
83 BEGIN(in_struct); 94 BEGIN(in_struct);
84 return EXTERN; 95 return EXTERN;
85 } 96 }
86 ^{HWS}static/{EOID} { 97 ^{HWS}static/{EOID} {
87 BEGIN(in_struct); 98 BEGIN(in_struct);
88 return STATIC; 99 return STATIC;
89 } 100 }
90 101 }
91 ^{HWS}DEF_VEC_[OP]/{EOID} { 102
92 BEGIN(in_struct); 103 /* Parsing inside a struct, union or class declaration. */
93 return DEFVEC_OP;
94 }
95 ^{HWS}DEF_VEC_I/{EOID} {
96 BEGIN(in_struct);
97 return DEFVEC_I;
98 }
99 ^{HWS}DEF_VEC_ALLOC_[IOP]/{EOID} {
100 BEGIN(in_struct);
101 return DEFVEC_ALLOC;
102 }
103 }
104
105 <in_struct>{ 104 <in_struct>{
106
107 "/*" { BEGIN(in_struct_comment); } 105 "/*" { BEGIN(in_struct_comment); }
106 "//".*\n { lexer_line.line++; }
108 107
109 {WS} { update_lineno (yytext, yyleng); } 108 {WS} { update_lineno (yytext, yyleng); }
110 \\\n { lexer_line.line++; } 109 \\\n { lexer_line.line++; }
111 110
112 "const"/{EOID} /* don't care */ 111 "const"/{EOID} /* don't care */
112 {CXX_KEYWORD}/{EOID} |
113 "~" |
114 "^" |
115 "&" {
116 *yylval = XDUPVAR (const char, yytext, yyleng, yyleng + 1);
117 return IGNORABLE_CXX_KEYWORD;
118 }
113 "GTY"/{EOID} { return GTY_TOKEN; } 119 "GTY"/{EOID} { return GTY_TOKEN; }
114 "VEC"/{EOID} { return VEC_TOKEN; }
115 "union"/{EOID} { return UNION; } 120 "union"/{EOID} { return UNION; }
116 "struct"/{EOID} { return STRUCT; } 121 "struct"/{EOID} { return STRUCT; }
122 "class"/{EOID} { return STRUCT; }
123 "typedef"/{EOID} { return TYPEDEF; }
117 "enum"/{EOID} { return ENUM; } 124 "enum"/{EOID} { return ENUM; }
118 "ptr_alias"/{EOID} { return PTR_ALIAS; } 125 "ptr_alias"/{EOID} { return PTR_ALIAS; }
119 "nested_ptr"/{EOID} { return NESTED_PTR; } 126 "nested_ptr"/{EOID} { return NESTED_PTR; }
127 "user"/{EOID} { return USER_GTY; }
120 [0-9]+ { return NUM; } 128 [0-9]+ { return NUM; }
121 "param"[0-9]*"_is"/{EOID} {
122 *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
123 return PARAM_IS;
124 }
125 129
126 {IWORD}({WS}{IWORD})*/{EOID} | 130 {IWORD}({WS}{IWORD})*/{EOID} |
127 "ENUM_BITFIELD"{WS}?"("{WS}?{ID}{WS}?")" { 131 "ENUM_BITFIELD"{WS}?"("{WS}?{ID}{WS}?")" {
128 size_t len; 132 size_t len;
129 133
132 136
133 *yylval = XDUPVAR (const char, yytext, len, len+1); 137 *yylval = XDUPVAR (const char, yytext, len, len+1);
134 update_lineno (yytext, yyleng); 138 update_lineno (yytext, yyleng);
135 return SCALAR; 139 return SCALAR;
136 } 140 }
137
138 141
139 {ID}/{EOID} { 142 {ID}/{EOID} {
140 *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1); 143 *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
141 return ID; 144 return ID;
142 } 145 }
154 *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng); 157 *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng);
155 return CHAR; 158 return CHAR;
156 } 159 }
157 160
158 "..." { return ELLIPSIS; } 161 "..." { return ELLIPSIS; }
159 [(){},*:<>;=%|-] { return yytext[0]; } 162 [(){},*:<>;=%/|+\!\?\.-] { return yytext[0]; }
160 163
161 /* ignore pp-directives */ 164 /* ignore pp-directives */
162 ^{HWS}"#"{HWS}[a-z_]+[^\n]*\n {lexer_line.line++;} 165 ^{HWS}"#"{HWS}[a-z_]+[^\n]*\n {lexer_line.line++;}
163 166
164 . { 167 . {
165 error_at_line (&lexer_line, "unexpected character `%s'", yytext); 168 error_at_line (&lexer_line, "unexpected character `%s'", yytext);
166 } 169 }
167 } 170 }
168 171
169 "/*" { BEGIN(in_comment); } 172 "/*" { BEGIN(in_comment); }
173 "//".*\n { lexer_line.line++; }
170 \n { lexer_line.line++; } 174 \n { lexer_line.line++; }
171 {ID} | 175 {ID} |
172 "'"("\\".|[^\\])"'" | 176 "'"("\\".|[^\\])"'" |
173 [^"/\n] /* do nothing */ 177 [^"/\n] /* do nothing */
174 \"([^"\\]|\\.|\\\n)*\" { update_lineno (yytext, yyleng); } 178 \"([^"\\]|\\.|\\\n)*\" { update_lineno (yytext, yyleng); }
178 \n { lexer_line.line++; } 182 \n { lexer_line.line++; }
179 [^*\n]{16} | 183 [^*\n]{16} |
180 [^*\n] /* do nothing */ 184 [^*\n] /* do nothing */
181 "*"/[^/] /* do nothing */ 185 "*"/[^/] /* do nothing */
182 } 186 }
187
183 <in_comment>"*/" { BEGIN(INITIAL); } 188 <in_comment>"*/" { BEGIN(INITIAL); }
184 <in_struct_comment>"*/" { BEGIN(in_struct); } 189 <in_struct_comment>"*/" { BEGIN(in_struct); }
185 190
186 ["/] | 191 ["/] |
187 <in_struct_comment,in_comment>"*" { 192 <in_struct_comment,in_comment>"*" {