]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gengtype.h
Partial merge of 'ObjC GC' from FSF apple 'trunk' branch.
[thirdparty/gcc.git] / gcc / gengtype.h
CommitLineData
e2500fed 1/* Process source files and output type information.
66647d44 2 Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
e2500fed 3
e1b793e7 4 This file is part of GCC.
e2500fed 5
e1b793e7
BS
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
9 version.
e2500fed 10
e1b793e7
BS
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
14 for more details.
e2500fed 15
e1b793e7
BS
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/>. */
e2500fed 19
065ae611
ZW
20#ifndef GCC_GENGTYPE_H
21#define GCC_GENGTYPE_H
22
b8698a0f 23/* A file position, mostly for error messages.
e2500fed 24 The FILE element may be compared using pointer equality. */
e1b793e7
BS
25struct fileloc
26{
e2500fed
GK
27 const char *file;
28 int line;
29};
30
065ae611 31/* Data types handed around within, but opaque to, the lexer and parser. */
b453c95f
GK
32typedef struct pair *pair_p;
33typedef struct type *type_p;
e5cfc29f 34typedef const struct type *const_type_p;
065ae611 35typedef struct options *options_p;
e2500fed 36
e2500fed
GK
37/* Variables used to communicate between the lexer and the parser. */
38extern int lexer_toplevel_done;
39extern struct fileloc lexer_line;
40
41/* Print an error message. */
b8698a0f 42extern void error_at_line
e1b793e7 43(const struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2;
e2500fed 44
01d419ae 45/* Like asprintf, but calls fatal() on out of memory. */
e1b793e7
BS
46extern char *
47xasprintf (const char *, ...)
48 ATTRIBUTE_PRINTF_1;
01d419ae 49
e2500fed 50/* Constructor routines for types. */
3d7aafde 51extern void do_typedef (const char *s, type_p t, struct fileloc *pos);
95161faf 52extern void do_scalar_typedef (const char *s, struct fileloc *pos);
3d7aafde 53extern type_p resolve_typedef (const char *s, struct fileloc *pos);
0f01f026
RS
54extern type_p new_structure (const char *name, int isunion,
55 struct fileloc *pos, pair_p fields,
56 options_p o);
3d7aafde 57extern type_p find_structure (const char *s, int isunion);
95161faf 58extern type_p create_scalar_type (const char *name);
3d7aafde
AJ
59extern type_p create_pointer (type_p t);
60extern type_p create_array (type_p t, const char *len);
e1b793e7
BS
61extern options_p create_option (options_p, const char *name,
62 const void *info);
065ae611 63extern options_p create_nested_ptr_option (options_p, type_p t,
e1b793e7
BS
64 const char *from,
65 const char *to);
66extern pair_p create_field_at (pair_p next, type_p type,
67 const char *name, options_p opt,
68 struct fileloc *pos);
01d419ae 69extern pair_p nreverse_pairs (pair_p list);
3d7aafde
AJ
70extern type_p adjust_field_type (type_p, options_p);
71extern void note_variable (const char *s, type_p t, options_p o,
72 struct fileloc *pos);
8ad97cfc 73extern void note_def_vec (const char *type_name, bool is_scalar,
4a399aef
ZW
74 struct fileloc *pos);
75extern void note_def_vec_alloc (const char *type, const char *astrat,
76 struct fileloc *pos);
e2500fed 77
01d419ae
ZW
78/* Lexer and parser routines. */
79extern int yylex (const char **yylval);
80extern void yybegin (const char *fname);
81extern void yyend (void);
3d7aafde 82extern void parse_file (const char *name);
01d419ae
ZW
83extern bool hit_error;
84
85/* Token codes. */
e1b793e7
BS
86enum
87 {
88 EOF_TOKEN = 0,
89
90 /* Per standard convention, codes in the range (0, UCHAR_MAX]
91 represent single characters with those character codes. */
92
93 CHAR_TOKEN_OFFSET = UCHAR_MAX + 1,
94 GTY_TOKEN = CHAR_TOKEN_OFFSET,
95 TYPEDEF,
96 EXTERN,
97 STATIC,
98 UNION,
99 STRUCT,
100 ENUM,
101 VEC_TOKEN,
102 DEFVEC_OP,
103 DEFVEC_I,
104 DEFVEC_ALLOC,
105 ELLIPSIS,
106 PTR_ALIAS,
107 NESTED_PTR,
108 PARAM_IS,
109 NUM,
110 SCALAR,
111 ID,
112 STRING,
113 CHAR,
114 ARRAY,
115
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
119 };
065ae611 120#endif