File: ctparse.h

package info (click to toggle)
libconvert-binary-c-perl 0.74-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 9,100 kB
  • ctags: 21,416
  • sloc: ansic: 63,666; perl: 18,582; yacc: 2,143; makefile: 44
file content (167 lines) | stat: -rw-r--r-- 4,813 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*******************************************************************************
*
* HEADER: ctparse.h
*
********************************************************************************
*
* DESCRIPTION: Parser interface routines
*
********************************************************************************
*
* $Project: /Convert-Binary-C $
* $Author: mhx $
* $Date: 2009/03/15 04:10:49 +0100 $
* $Revision: 44 $
* $Source: /ctlib/ctparse.h $
*
********************************************************************************
*
* Copyright (c) 2002-2009 Marcus Holland-Moritz. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the same terms as Perl itself.
*
*******************************************************************************/

#ifndef _CTLIB_CTPARSE_H
#define _CTLIB_CTPARSE_H

/*===== GLOBAL INCLUDES ======================================================*/

/*===== LOCAL INCLUDES =======================================================*/

#include "ctlib/arch.h"
#include "ctlib/cttype.h"
#include "ctlib/layout.h"
#include "util/list.h"
#include "util/hash.h"


/*===== DEFINES ==============================================================*/


/*===== TYPEDEFS =============================================================*/

struct CPP;

typedef struct {
  char          *buffer;
  unsigned long  pos, length;
} Buffer;

typedef struct {
  LayoutParam layout;

  ErrorGTI (*get_type_info)(const LayoutParam *, const TypeSpec *,
                            const Declarator *, const char *, ...);

  void (*layout_compound)(const LayoutParam *, Struct *);

  /* boolean options */
  unsigned unsigned_chars     : 1;
  unsigned unsigned_bitfields : 1;
  unsigned issue_warnings     : 1;
  unsigned disable_parser     : 1;
  unsigned has_cpp_comments   : 1;
  unsigned has_macro_vaargs   : 1;
  unsigned has_std_c          : 1;
  unsigned has_std_c_hosted   : 1;
  unsigned is_std_c_hosted    : 1;

  long int std_c_version;

  u_32 keywords;

#define HAS_KEYWORD_AUTO     0x00000001U
#define HAS_KEYWORD_CONST    0x00000002U
#define HAS_KEYWORD_DOUBLE   0x00000004U
#define HAS_KEYWORD_ENUM     0x00000008U
#define HAS_KEYWORD_EXTERN   0x00000010U
#define HAS_KEYWORD_FLOAT    0x00000020U
#define HAS_KEYWORD_INLINE   0x00000040U
#define HAS_KEYWORD_LONG     0x00000080U
#define HAS_KEYWORD_REGISTER 0x00000100U
#define HAS_KEYWORD_RESTRICT 0x00000200U
#define HAS_KEYWORD_SHORT    0x00000400U
#define HAS_KEYWORD_SIGNED   0x00000800U
#define HAS_KEYWORD_STATIC   0x00001000U
#define HAS_KEYWORD_UNSIGNED 0x00002000U
#define HAS_KEYWORD_VOID     0x00004000U
#define HAS_KEYWORD_VOLATILE 0x00008000U
#define HAS_KEYWORD_ASM      0x00010000U

#define HAS_ALL_KEYWORDS     0x0001FFFFU

  LinkedList disabled_keywords;
  LinkedList includes;
  LinkedList defines;
  LinkedList assertions;

  HashTable  keyword_map;
} CParseConfig;

typedef struct {
  LinkedList enums;
  LinkedList structs;
  LinkedList typedef_lists;
  HashTable  htEnumerators;
  HashTable  htEnums;
  HashTable  htStructs;
  HashTable  htTypedefs;
  HashTable  htFiles;
  HashTable  htPredefined;
  LinkedList errorStack;
  struct CPP *pp;
  unsigned   available : 1;
  unsigned   ready     : 1;
} CParseInfo;

typedef struct {
  void       *arg;
  const char *name;
  const char *definition;
  size_t      definition_len;
} CMacroInfo;

#define CMIF_WITH_DEFINITION 0x00000001
#define CMIF_NO_PREDEFINED   0x00000002
typedef unsigned CMIFlags;


/*===== FUNCTION PROTOTYPES ==================================================*/

#define parse_buffer CTlib_parse_buffer
int parse_buffer(const char *filename, const Buffer *pBuf,
                 const CParseConfig *pCPC, CParseInfo *pCPI);

#define init_parse_info CTlib_init_parse_info
void init_parse_info(CParseInfo *pCPI);

#define free_parse_info CTlib_free_parse_info
void free_parse_info(CParseInfo *pCPI);

#define reset_preprocessor CTlib_reset_preprocessor
void reset_preprocessor(CParseInfo *pCPI);

#define reset_parse_info CTlib_reset_parse_info
void reset_parse_info(CParseInfo *pCPI);

#define update_parse_info CTlib_update_parse_info
void update_parse_info(CParseInfo *pCPI, const CParseConfig *pCPC);

#define clone_parse_info CTlib_clone_parse_info
void clone_parse_info(CParseInfo *pDest, const CParseInfo *pSrc);

#define macro_is_defined CTlib_macro_is_defined
int macro_is_defined(CParseInfo *pCPI, const char *name);

#define macro_get_def CTlib_macro_get_def
char *macro_get_def(CParseInfo *pCPI, const char *name, size_t *plen);

#define macro_free_def CTlib_macro_free_def
void macro_free_def(char *p);

#define macro_iterate_defs CTlib_macro_iterate_defs
void macro_iterate_defs(CParseInfo *pCPI, void (*func)(const CMacroInfo *),
                        void *arg, CMIFlags flags);

#endif