1 /* Process source files and output type information.
2 Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_GENGTYPE_H
21 #define GCC_GENGTYPE_H
23 /* A file position, mostly for error messages.
24 The FILE element may be compared using pointer equality. */
31 /* Data types handed around within, but opaque to, the lexer and parser. */
32 typedef struct pair
*pair_p
;
33 typedef struct type
*type_p
;
34 typedef const struct type
*const_type_p
;
35 typedef struct options
*options_p
;
37 /* Variables used to communicate between the lexer and the parser. */
38 extern int lexer_toplevel_done
;
39 extern struct fileloc lexer_line
;
41 /* Print an error message. */
42 extern void error_at_line
43 (const struct fileloc
*pos
, const char *msg
, ...) ATTRIBUTE_PRINTF_2
;
45 /* Like asprintf, but calls fatal() on out of memory. */
47 xasprintf (const char *, ...)
50 /* Constructor routines for types. */
51 extern void do_typedef (const char *s
, type_p t
, struct fileloc
*pos
);
52 extern void do_scalar_typedef (const char *s
, struct fileloc
*pos
);
53 extern type_p
resolve_typedef (const char *s
, struct fileloc
*pos
);
54 extern type_p
new_structure (const char *name
, int isunion
,
55 struct fileloc
*pos
, pair_p fields
,
57 extern type_p
find_structure (const char *s
, int isunion
);
58 extern type_p
create_scalar_type (const char *name
);
59 extern type_p
create_pointer (type_p t
);
60 extern type_p
create_array (type_p t
, const char *len
);
61 extern options_p
create_option (options_p
, const char *name
,
63 extern options_p
create_nested_ptr_option (options_p
, type_p t
,
66 extern pair_p
create_field_at (pair_p next
, type_p type
,
67 const char *name
, options_p opt
,
69 extern pair_p
nreverse_pairs (pair_p list
);
70 extern type_p
adjust_field_type (type_p
, options_p
);
71 extern void note_variable (const char *s
, type_p t
, options_p o
,
73 extern void note_def_vec (const char *type_name
, bool is_scalar
,
75 extern void note_def_vec_alloc (const char *type
, const char *astrat
,
78 /* Lexer and parser routines. */
79 extern int yylex (const char **yylval
);
80 extern void yybegin (const char *fname
);
81 extern void yyend (void);
82 extern void parse_file (const char *name
);
83 extern bool hit_error
;
90 /* Per standard convention, codes in the range (0, UCHAR_MAX]
91 represent single characters with those character codes. */
93 CHAR_TOKEN_OFFSET
= UCHAR_MAX
+ 1,
94 GTY_TOKEN
= CHAR_TOKEN_OFFSET
,
116 /* print_token assumes that any token >= FIRST_TOKEN_WITH_VALUE may have
117 a meaningful value to be printed. */
118 FIRST_TOKEN_WITH_VALUE
= PARAM_IS