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