1 /* -*- indented-text -*- */
2 /* Process source files and output type information.
3 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2012
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 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
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
32 #define malloc xmalloc
33 #define realloc xrealloc
37 #define YY_DECL int yylex (const char **yylval)
38 #define yyterminate() return EOF_TOKEN
40 struct fileloc lexer_line;
41 int lexer_toplevel_done;
44 update_lineno (const char *l, size_t len)
53 ID [[:alpha:]_][[:alnum:]_]*
56 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
57 ITYPE {IWORD}({WS}{IWORD})*
60 %x in_struct in_struct_comment in_comment
61 %option warn noyywrap nounput nodefault perf-report
62 %option 8bit never-interactive
64 /* Do this on entry to yylex(): */
66 if (lexer_toplevel_done)
69 lexer_toplevel_done = 0;
72 /* Things we look for in skipping mode: */
74 ^{HWS}typedef/{EOID} {
98 "/*" { BEGIN(in_struct_comment); }
100 {WS} { update_lineno (yytext, yyleng); }
101 \\\n { lexer_line.line++; }
103 "const"/{EOID} /* don't care */
104 "GTY"/{EOID} { return GTY_TOKEN; }
105 "VEC"/{EOID} { return VEC_TOKEN; }
106 "union"/{EOID} { return UNION; }
107 "struct"/{EOID} { return STRUCT; }
108 "enum"/{EOID} { return ENUM; }
109 "ptr_alias"/{EOID} { return PTR_ALIAS; }
110 "nested_ptr"/{EOID} { return NESTED_PTR; }
111 "user"/{EOID} { return USER_GTY; }
112 [0-9]+ { return NUM; }
113 "param"[0-9]*"_is"/{EOID} {
114 *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
118 {IWORD}({WS}{IWORD})*/{EOID} |
119 "ENUM_BITFIELD"{WS}?"("{WS}?{ID}{WS}?")" {
122 for (len = yyleng; ISSPACE (yytext[len-1]); len--)
125 *yylval = XDUPVAR (const char, yytext, len, len+1);
126 update_lineno (yytext, yyleng);
132 *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
137 *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng-1);
140 /* This "terminal" avoids having to parse integer constant expressions. */
142 *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng-1);
145 "'"("\\".|[^\\])"'" {
146 *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng);
150 "..." { return ELLIPSIS; }
151 [(){},*:<>;=%|-] { return yytext[0]; }
153 /* ignore pp-directives */
154 ^{HWS}"#"{HWS}[a-z_]+[^\n]*\n {lexer_line.line++;}
157 error_at_line (&lexer_line, "unexpected character `%s'", yytext);
161 "/*" { BEGIN(in_comment); }
162 \n { lexer_line.line++; }
164 "'"("\\".|[^\\])"'" |
165 [^"/\n] /* do nothing */
166 \"([^"\\]|\\.|\\\n)*\" { update_lineno (yytext, yyleng); }
167 "/"/[^*] /* do nothing */
169 <in_comment,in_struct_comment>{
170 \n { lexer_line.line++; }
172 [^*\n] /* do nothing */
173 "*"/[^/] /* do nothing */
175 <in_comment>"*/" { BEGIN(INITIAL); }
176 <in_struct_comment>"*/" { BEGIN(in_struct); }
179 <in_struct_comment,in_comment>"*" {
180 error_at_line (&lexer_line,
181 "unterminated comment or string; unexpected EOF");
184 ^{HWS}"#"{HWS}"define"{WS}"GTY(" /* do nothing */
189 yybegin (const char *fname)
191 yyin = fopen (fname, "r");
197 lexer_line.file = input_file_by_name (fname);