PIPS
preprocessor.h
Go to the documentation of this file.
1 /* Warning! Do not modify this file that is automatically generated! */
2 /* Modify src/Libs/preprocessor/preprocessor-local.h instead, to add your own modifications. */
3 
4 /* header file built by cproto */
5 
6 #ifndef preprocessor_header_included
7 #define preprocessor_header_included
8 /* preprocessor-local.h */
9 /*
10 
11  $Id: preprocessor-local.h 23662 2023-07-10 11:46:59Z coelho $
12 
13  Copyright 1989-2016 MINES ParisTech
14 
15  This file is part of PIPS.
16 
17  PIPS is free software: you can redistribute it and/or modify it
18  under the terms of the GNU General Public License as published by
19  the Free Software Foundation, either version 3 of the License, or
20  any later version.
21 
22  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
23  WARRANTY; without even the implied warranty of MERCHANTABILITY or
24  FITNESS FOR A PARTICULAR PURPOSE.
25 
26  See the GNU General Public License for more details.
27 
28  You should have received a copy of the GNU General Public License
29  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
30 
31 */
32 /* Preprocessing and splitting of Fortran and C files
33  */
34 
35 /* the name of the environment variable where source files are searched for. */
36 #define SRCPATH "PIPS_SRCPATH"
37 
38 /* pre-processor and added options from environment
39  */
40 #define CPP_PIPS_ENV "PIPS_CPP"
41 #define CPP_PIPS_OPTIONS_ENV "PIPS_CPP_FLAGS"
42 #define FPP_PIPS_ENV "PIPS_FPP"
43 #define FPP_PIPS_OPTIONS_ENV "PIPS_FPP_FLAGS"
44 
45 /* default preprocessor and basic options
46  * -C: do not discard comments...
47  * -P: inhibit linemakers (# 1 "file.c")
48  * -ffreestanding: ignore "stdc-predef.h"
49  */
50 // alternative values: "gcc -E -C"
51 // force c99 for gcc/clang validation compatibility
52 #define CPP_CPP "cpp -C -std=c99"
53 /* #define CPP_CPPFLAGS " -P -D__PIPS__ -D__HPFC__ " */
54 /* -U__GNUC__ seems to be still useful to avoid spoiling the libC files
55  with too many GCC extensions: */
56 //#define CPP_CPPFLAGS " -D__PIPS__ -D__HPFC__ "
57 #define CPP_CPPFLAGS " -D__PIPS__ -D__HPFC__ -U__GNUC__ "
58 
59 /** The preprocessor to use for Fortran files.
60 
61  Alternative values: "gcc -E -C" or "fpp". The issue with cpp or gcc -E
62  is that they don't undestand Fortran and chokes on unbalanced strings
63  in Fortran comments and so on.
64 */
65 #define FPP_CPP "gfortran -E"
66 
67 /** The default preprocessor flags to use with Fortran files */
68 #define FPP_CPPFLAGS " -P -D__PIPS__ -D__HPFC__ "
69 
70 #define DEFAULT_PIPS_FLINT "gfortran -Wall"
71 
72 /* See necessary definitions in pipsmake-rc.tex */
73 //#define DEFAULT_PIPS_CC "gcc -std=c99 -D__PIPS__ -D__HPFC__ "
74 #define DEFAULT_PIPS_CC "gcc -std=c99 -D__PIPS__ -D__HPFC__ -U__GNUC__ "
75 #define DEFAULT_PIPS_CC_FLAGS " -Wall "
76 
77 /* Define some functions from the .l or .y since cproto cannot dig them out: */
78 void MakeTypedefStack();
79 void ResetTypedefStack();
80 
81 #define csplit_parser_warning(...) \
82  csplit_parser_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, \
83  __VA_ARGS__)
84 
85 /* symbols exported by lex / yacc */
86 typedef size_t yy_size_t;
87 
88 extern char * splitc_text;
89 extern FILE * splitc_in;
90 extern int splitc_lex();
91 extern int splitc_lex_destroy();
92 extern int splitc_parse();
93 extern void splitc_error(const char*);
94 /* cproto-generated files */
95 /* source_file.c */
96 extern void pips_get_workspace_list(gen_array_t /*array*/);
97 extern void pips_get_fortran_list(gen_array_t /*array*/);
98 extern string hpfc_generate_path_name_of_file_name(const char */*file_name*/);
99 extern int hpfc_get_file_list(gen_array_t /*file_names*/, char **/*hpfc_directory_name*/);
100 extern string pips_change_directory(const char */*dir*/);
101 extern void pips_srcpath_set(string /*path*/);
102 extern string pips_srcpath_append(string /*pathtoadd*/);
103 extern void init_processed_include_cache(void);
104 extern void close_processed_include_cache(void);
105 extern bool filter_file(string /*mod_name*/);
107 extern string preprocessed_to_user_file(string /*preprocessed_user_file*/);
108 extern bool dot_F_file_p(string /*name*/);
109 extern bool dot_f_file_p(string /*name*/);
110 extern bool dot_f90_file_p(string /*name*/);
111 extern bool dot_f95_file_p(string /*name*/);
112 extern bool dot_c_file_p(string /*name*/);
113 extern language workspace_language(gen_array_t /*files*/);
114 extern int find_eol_coding(string /*name*/);
116 extern bool process_user_file(string /*file*/);
117 extern bool flag_as_stub(const string /*module_name*/);
118 extern bool bootstrap_stubs(const string /*module_name*/);
119 /* split_file.c */
120 extern char fsplit_copyright[];
121 extern char fsplit_sccsid[];
122 extern char *fsplit(char */*dir_name*/, char */*file_name*/, FILE */*out*/);
123 extern char *process_bang_comments_and_hollerith(FILE */*in*/, FILE */*out*/);
124 /* csplit_file.c */
125 extern char *current_include_file_path;
126 extern char *current_file_path;
127 extern void init_module_name_list(void);
128 extern void reset_module_name_list(void);
129 extern void error_reset_module_name_list(void);
130 extern string get_splitc_input_file_name(void);
131 extern void reset_current_input_line(void);
132 extern void csplit_open_compilation_unit(string /*input_file_name*/);
133 extern void csplit_close_compilation_unit(void);
134 extern void copy_between_2_fd_up_to_offset(FILE */*source*/, FILE */*destination*/, unsigned long long /*up_to_offset*/, bool /*greedy_spaces*/);
135 extern void csplit_append_to_compilation_unit(int /*last_line*/, unsigned long long /*last_offset*/);
136 extern void csplit_copy(const char */*module_name*/, string /*signature*/, int /*first_line*/, int /*last_line*/, size_t /*first_offset*/, size_t /*last_offset*/, int /*user_first_line*/, bool /*is_static_p*/);
137 extern void keep_track_of_typedef(string /*type_name*/);
138 extern void csplit_error_handler(void);
139 extern void csplit_reset(void);
140 extern void csplit_close_files(string /*file_name*/);
142 extern string current_file_name;
143 extern string csplit(char */*dir_name*/, char */*file_name*/, FILE */*out*/);
144 /* f95split_file.c */
145 extern char *f95split(char */*dir_name*/, char */*file_name*/, FILE **/*out*/);
146 /* splitc.c */
147 extern int csplit_is_external;
148 extern int csplit_is_function;
149 extern string csplit_current_function_name;
150 extern string csplit_current_function_name2;
151 extern string csplit_definite_function_name;
153 extern bool csplit_is_static_p;
154 extern void csplit_parser_warning_func(const char */*pips_func*/, const char */*pips_file*/, const int /*pips_line*/, const string /*format*/, ...);
155 extern void csplit_parser_error(const string /*msg*/);
156 extern void MakeTypedefStack(void);
157 extern void ResetTypedefStack(void);
158 extern void ForceResetTypedefStack(void);
159 extern void init_preprocessor_scope_stack(void);
160 extern void reset_preprocessor_scope_stack(void);
161 extern void force_reset_preprocessor_scope_stack(void);
162 extern void push_new_preprocessor_scope(void);
163 extern void pop_preprocessor_scope(void);
164 extern bool preprocessor_scope_stack_empty_p(void);
165 extern string get_preprocessor_current_scope(void);
166 extern string get_preprocessor_nth_scope(int /*n*/);
167 extern int preprocessor_scope_number(void);
168 extern int check_signature_balance(void);
169 extern int splitc_char;
170 extern int splitc_nerrs;
171 extern int splitc_parse(void);
172 /* lexer.c */
173 extern int splitc_leng;
174 extern FILE *splitc_in;
175 extern FILE *splitc_out;
176 extern int splitc_lineno;
177 extern int splitc__flex_debug;
178 extern char *splitc_text;
179 extern int csplit_line_number;
180 extern int user_line_number;
181 extern size_t current_csplit_file_offset;
182 extern size_t csplit_file_offset_beginning;
184 extern void reset_csplit_line_number(void);
185 extern void reset_csplit_current_beginning(void);
186 extern int get_csplit_current_beginning(void);
187 extern int get_user_current_beginning(void);
188 extern size_t get_csplit_file_offset_beginning(void);
189 extern size_t get_current_csplit_file_offset(void);
190 extern void update_csplit_file_offset_information(void);
191 extern int splitc_lex(void);
192 extern void splitc_restart(FILE */*input_file*/);
193 extern void splitc_pop_buffer_state(void);
194 extern int splitc_get_lineno(void);
195 extern FILE *splitc_get_in(void);
196 extern FILE *splitc_get_out(void);
197 extern int splitc_get_leng(void);
198 extern char *splitc_get_text(void);
199 extern void splitc_set_lineno(int /*_line_number*/);
200 extern void splitc_set_in(FILE */*_in_str*/);
201 extern void splitc_set_out(FILE */*_out_str*/);
202 extern int splitc_get_debug(void);
203 extern void splitc_set_debug(int /*_bdebug*/);
204 extern int splitc_lex_destroy(void);
205 extern void *splitc_alloc(yy_size_t /*size*/);
206 extern void *splitc_realloc(void */*ptr*/, yy_size_t /*size*/);
207 extern void splitc_free(void */*ptr*/);
208 extern void splitc_error(const char */*msg*/);
209 extern int splitc_wrap(void);
210 #endif /* preprocessor_header_included */
size_t yy_size_t
Definition: genread_lex.c:413
gather_comment_state_t
A state-machine to gather the trailing comments of a statement with an heuristic to decide if some co...
Definition: lexer.c:1101
void csplit_copy(const char *, string, int, int, size_t, size_t, int, bool)
Create the module directory and file, copy the definition of the module and add the module name to th...
Definition: csplit_file.c:334
char * fsplit(char *, char *, FILE *)
Definition: split_file.c:474
bool flag_as_stub(const string)
Definition: source_file.c:1334
bool filter_file(string)
Definition: source_file.c:501
string get_preprocessor_nth_scope(int)
Definition: splitc.c:339
size_t csplit_file_offset_beginning
Definition: lexer.c:1093
string csplit_current_function_name
to know if this is the declaration of a function or not, to distinguish between a static variable and...
Definition: splitc.c:123
bool dot_c_file_p(string)
Test if a name ends with .c.
Definition: source_file.c:661
int splitc_get_leng(void)
void init_module_name_list(void)
Definition: csplit_file.c:58
void splitc_restart(FILE *)
int splitc_nerrs
void splitc_set_in(FILE *)
int splitc_char
void pop_preprocessor_scope(void)
Definition: splitc.c:316
size_t get_current_csplit_file_offset(void)
Get the current file position in the file to split:
Definition: lexer.c:1211
void splitc_free(void *)
char * current_file_path
Definition: csplit_file.c:52
int preprocessor_scope_number(void)
Definition: splitc.c:345
bool bootstrap_stubs(const string)
Definition: source_file.c:1344
void ForceResetTypedefStack(void)
Definition: splitc.c:259
FILE * splitc_get_in(void)
void pips_get_fortran_list(gen_array_t)
Select the true file with names ending in ".[fF]" and return a sorted arg list:
Definition: source_file.c:89
string pips_srcpath_append(string)
returns an allocated pointer to the old value
Definition: source_file.c:177
int splitc_lex_destroy()
void pips_srcpath_set(string)
Set the PIPS source path.
Definition: source_file.c:167
int get_csplit_current_beginning(void)
Definition: lexer.c:1190
string preprocessor_current_split_file_name
Split a C or Fortran file into as many files as modules.
Definition: source_file.c:584
bool csplit_is_static_p
static int enum_counter = 0;
Definition: splitc.c:143
void csplit_close_files(string)
Definition: csplit_file.c:547
void preprocessor_init_keyword_typedef_table(void)
Definition: csplit_file.c:567
int splitc_lex()
char fsplit_copyright[]
split_file.c
Definition: split_file.c:114
int csplit_is_function
to know if the variable is declared inside or outside a function
Definition: splitc.c:120
int splitc_get_lineno(void)
void keep_track_of_typedef(string)
Definition: csplit_file.c:517
int splitc_wrap(void)
int csplit_is_external
splitc.c
Definition: splitc.c:119
FILE * splitc_out
void reset_current_input_line(void)
In file just above.
Definition: csplit_file.c:93
void splitc_error(const char *)
void csplit_parser_warning_func(const char *, const char *, const int, const string,...)
Definition: splitc.c:174
string current_file_name
Split a C file into one file per module (function or procedure) plus.
Definition: csplit_file.c:640
void reset_preprocessor_scope_stack(void)
Definition: splitc.c:280
int hpfc_get_file_list(gen_array_t, char **)
Definition: source_file.c:106
FILE * splitc_get_out(void)
void update_csplit_file_offset_information(void)
Function called each time a token is read to trac file position information:
Definition: lexer.c:1218
string csplit_definite_function_signature
Definition: splitc.c:126
bool dot_f95_file_p(string)
Test if a name ends with .f95.
Definition: source_file.c:655
char * splitc_text
Definition: preprocessor.h:178
void error_reset_module_name_list(void)
No checking, to be called from a (future) error handling module.
Definition: csplit_file.c:74
string preprocessor_current_initial_file_name
The digestion of a user file by PIPS begins here.
Definition: source_file.c:1088
void init_processed_include_cache(void)
Definition: source_file.c:272
void reset_csplit_line_number(void)
Reinitialise global position numbers for a new file.
Definition: lexer.c:1124
int get_user_current_beginning(void)
Get the current line number in the file to split from the user point of view (before preprocessor exp...
Definition: lexer.c:1198
string preprocessed_to_user_file(string)
Allocate a new string containing the user file name, before preprocessing.
Definition: source_file.c:617
char * splitc_get_text(void)
char * process_bang_comments_and_hollerith(FILE *, FILE *)
processing extracted for includes...
Definition: split_file.c:836
void MakeTypedefStack()
Define some functions from the .l or .y since cproto cannot dig them out:
Definition: splitc.c:243
size_t current_csplit_file_offset
Definition: lexer.c:1092
void splitc_set_lineno(int)
bool dot_F_file_p(string)
Test if a name ends with .F.
Definition: source_file.c:637
bool process_user_file(string)
Definition: source_file.c:1090
string get_preprocessor_current_scope(void)
Definition: splitc.c:327
int splitc_leng
lexer.c
void csplit_close_compilation_unit(void)
Definition: csplit_file.c:183
void csplit_reset(void)
Definition: csplit_file.c:539
void csplit_error_handler(void)
Close open files and reset variables.
Definition: csplit_file.c:531
void ResetTypedefStack()
Definition: splitc.c:249
void csplit_parser_error(const string)
Redundant with splitc_error()?
Definition: splitc.c:188
int csplit_line_number
To be exported to the parser for splitting the preprocessed file.
Definition: lexer.c:1085
void splitc_pop_buffer_state(void)
string csplit_definite_function_name
Definition: splitc.c:125
void reset_module_name_list(void)
Definition: csplit_file.c:65
size_t get_csplit_file_offset_beginning(void)
Get the file position in the file to split where the current function begins:
Definition: lexer.c:1205
int splitc_parse()
void force_reset_preprocessor_scope_stack(void)
To be used by an error handler.
Definition: splitc.c:297
void close_processed_include_cache(void)
Definition: source_file.c:283
int splitc_get_debug(void)
void pips_get_workspace_list(gen_array_t)
cproto-generated files
Definition: source_file.c:74
FILE * splitc_in
Definition: preprocessor.h:174
string get_splitc_input_file_name(void)
Definition: csplit_file.c:84
void splitc_set_out(FILE *)
char * current_include_file_path
csplit_file.c
Definition: csplit_file.c:51
bool preprocessor_scope_stack_empty_p(void)
Definition: splitc.c:322
void csplit_open_compilation_unit(string)
Disambiguate the compilation unit base name (special character to avoid conflicts with function names...
Definition: csplit_file.c:116
string hpfc_generate_path_name_of_file_name(const char *)
Return the path of an HPFC file name relative to the current PIPS directory.
Definition: source_file.c:97
void init_preprocessor_scope_stack(void)
Definition: splitc.c:274
int check_signature_balance(void)
Definition: splitc.c:524
bool dot_f90_file_p(string)
Test if a name ends with .f90.
Definition: source_file.c:649
void csplit_append_to_compilation_unit(int, unsigned long long)
Copy the input file to the compilation unit between the function declarations up to the current funct...
Definition: csplit_file.c:262
string pips_change_directory(const char *)
Change to the given directory if it exists and return a canonical name.
Definition: source_file.c:142
int splitc__flex_debug
int user_line_number
To be exported to the parser for error messages related to the user file.
Definition: lexer.c:1087
void * splitc_realloc(void *, yy_size_t)
size_t yy_size_t
symbols exported by lex / yacc
Definition: preprocessor.h:86
string csplit(char *, char *, FILE *)
Definition: csplit_file.c:641
void push_new_preprocessor_scope(void)
Definition: splitc.c:307
void copy_between_2_fd_up_to_offset(FILE *, FILE *, unsigned long long, bool)
enum gather_comment_state_t gather_comment_state_machine
Indeed it does not work since csplit_copy() is called from splitc.y when a function definition is fou...
Definition: lexer.c:1113
void * splitc_alloc(yy_size_t)
int splitc_lineno
language workspace_language(gen_array_t)
Choose a language if all filenames in "files" have the same C or Fortran extensions.
Definition: source_file.c:667
int find_eol_coding(string)
Returns the newly allocated name if preprocessing succeeds.
Definition: source_file.c:721
void reset_csplit_current_beginning(void)
This function is called at the end of any top-level C construct:
Definition: lexer.c:1152
char * f95split(char *, char *, FILE **)
f95split_file.c
Definition: f95split_file.c:56
bool dot_f_file_p(string)
Test if a name ends with .f.
Definition: source_file.c:643
char fsplit_sccsid[]
not lint
Definition: split_file.c:120
string csplit_current_function_name2
Definition: splitc.c:124
void splitc_set_debug(int)