PIPS
c_syntax-local.h
Go to the documentation of this file.
1 /*
2 
3  $Id: c_syntax-local.h 23657 2022-05-09 10:40:27Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #include "c_parser_private.h"
26 
27 extern FILE * c_in; /* the file read in by the c_lexer */
28 extern int c_lineno ;
29 extern int c_lex();
30 extern int c_parse();
31 
32 /* The labels in C have function scope... but beware of
33  inlining... and conflict with user labels */
34 /* To disambiguate labels, in case inlining is performed later and to
35  suppress the potential for conflicts with user labels.
36 
37  Temporary entities have to be generated to be replaced later by the
38  final labels. The temporary entities should be eliminated from the
39  symbol table...
40  */
41 #define get_label_prefix() "-" // a character that cannot be used in a correct
42 
43 /* These global variables are declared in ri-util/util.c */
44 extern entity DynamicArea;
45 extern entity StaticArea;
46 extern entity HeapArea;
47 extern entity StackArea;
48 extern entity AllocatableArea;
49 
50 /* Error handling */
51 #define FIRST_C_LINE_NUMBER (1)
52 #define UNDEFINED_C_LINE_NUMBER (-1)
53 
54 #define CParserError(m) c_parser_error(CURRENT_FUNCTION, m)
55 #define c_parser_user_warning(...) \
56  c_parser_user_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__)
57 
58 /* cproto workaround */
59 /* from "cyacc.y" */
60 extern entity GetFunction(void);
61 extern void reset_expression_comment(void);
62 extern string pop_block_scope(string /*old_scope*/);
63 extern string scope_to_block_scope(string /*full_scope*/);
65 extern void InitScope(void);
66 extern int ScopeStackSize(void);
67 extern string GetScope(void);
68 extern string GetParentScope(void);
69 extern void ExitScope(void);
70 extern void PushContext(c_parser_context /*c*/);
71 extern void PopContext(void);
72 extern c_parser_context GetContext(void);
73 extern c_parser_context GetContextCopy(void);
74 extern void reset_declaration_counter(void);
75 extern int get_declaration_counter(void);
76 extern void init_c_parser_scope_stack(void);
77 extern void reset_c_parser_scope_stack(void);
78 extern void force_reset_c_parser_scope_stack(void);
79 extern void push_new_c_parser_scope(void);
80 extern void pop_c_parser_scope_stack(void);
81 extern bool c_parser_scope_stack_empty_p(void);
82 extern string get_c_parser_current_scope(void);
83 extern string get_c_parser_nth_scope(int /*n*/);
84 extern int c_parser_number_of_scopes(void);
85 /* from "clex.l" */
86 extern int C_line_increment;
87 extern int get_previous_c_lineno(void);
88 extern unsigned int character_occurences_in_string(string /*s*/, char /*c*/);
89 extern int get_current_C_line_number(void);
90 extern int get_previous_C_line_number(void);
91 extern void set_current_C_line_number(void);
92 extern void push_current_C_line_number(void);
93 extern int pop_current_C_line_number(void);
94 extern void reset_current_C_line_number(void);
95 extern void error_reset_current_C_line_number(void);
96 extern void reset_token_has_been_seen_p(void);
97 extern string get_current_C_comment(void);
98 extern void push_current_C_comment(void);
99 extern string pop_current_C_comment(void);
100 extern void update_C_comment(string /*a_comment*/);
101 extern void remove_LFs_from_C_comment(int /*extra_LF*/);
102 extern void discard_C_comment(void);
103 extern void reset_C_comment(bool /*is_compilation_unit_p*/);
104 extern void error_reset_C_comment(bool /*is_compilation_unit_p*/);
105 extern void clear_C_comment(void);
106 extern void init_C_comment(void);
107 extern void c_error(char * /*msg*/);
108 extern void c_reset_lex(void);
109 extern int c_wrap(void);
string get_current_C_comment(void)
Return the current comment as a string to be freed by the caller and reset the current comment.
Definition: clexer.c:1282
void reset_expression_comment(void)
we don't want an expression comment with new lines, it is disgracefull
Definition: cyacc.tab.c:169
void PushContext(c_parser_context)
Definition: cyacc.tab.c:434
c_parser_context GetContextCopy(void)
Definition: cyacc.tab.c:476
void remove_LFs_from_C_comment(int)
Remove "extra_LF" trailing LF from C_current_comment if they can be found at the end of the comment s...
Definition: clexer.c:1398
entity DynamicArea
These global variables are declared in ri-util/util.c.
Definition: area.c:57
c_parser_context GetContext(void)
Definition: cyacc.tab.c:458
entity HeapArea
Definition: area.c:59
int get_previous_c_lineno(void)
Definition: clexer.c:1115
entity StaticArea
Definition: area.c:58
void push_new_c_parser_scope(void)
Definition: cyacc.tab.c:549
void init_c_parser_scope_stack(void)
Definition: cyacc.tab.c:514
void reset_token_has_been_seen_p(void)
Definition: clexer.c:1270
void discard_C_comment(void)
Discard a C comment because we don't know how to deal with it.
Definition: clexer.c:1426
void ExitScope(void)
Definition: cyacc.tab.c:400
string get_c_parser_current_scope(void)
Definition: cyacc.tab.c:569
void set_current_C_line_number(void)
Definition: clexer.c:1166
void push_current_C_comment(void)
Push the current C comment so that we can get it back when building the statement later.
Definition: clexer.c:1331
void reset_c_parser_scope_stack(void)
Definition: cyacc.tab.c:522
void reset_declaration_counter(void)
Definition: cyacc.tab.c:492
int c_parse()
int get_current_C_line_number(void)
Definition: clexer.c:1146
c_parser_context CreateDefaultContext(void)
Definition: cyacc.tab.c:292
FILE * c_in
Definition: c_syntax.h:291
void c_error(char *)
int ScopeStackSize(void)
Definition: cyacc.tab.c:366
int c_lex()
string get_c_parser_nth_scope(int)
Definition: cyacc.tab.c:581
string pop_current_C_comment(void)
Pop the current comment.
Definition: clexer.c:1352
int C_line_increment
from "clex.l"
Definition: c_syntax.h:296
string scope_to_block_scope(string)
Allocate a new string containing only block scope information.
Definition: cyacc.tab.c:268
unsigned int character_occurences_in_string(string, char)
Use a stack to survive to file inclusions if any.
Definition: clexer.c:1133
void init_C_comment(void)
Definition: clexer.c:1513
void reset_current_C_line_number(void)
Definition: clexer.c:1210
entity StackArea
Definition: area.c:60
void InitScope(void)
Definition: cyacc.tab.c:306
void push_current_C_line_number(void)
The line number stack, designed for structured control structure, is not used yet.
Definition: clexer.c:1194
string GetParentScope(void)
Definition: cyacc.tab.c:387
void reset_C_comment(bool)
reset and reset_error should be handled differently
Definition: clexer.c:1450
bool c_parser_scope_stack_empty_p(void)
Definition: cyacc.tab.c:564
void pop_c_parser_scope_stack(void)
Definition: cyacc.tab.c:558
string pop_block_scope(string)
The scope is moved up the scope tree and a NULL is return when there are no more scope to explore.
Definition: cyacc.tab.c:235
int c_parser_number_of_scopes(void)
Definition: cyacc.tab.c:587
void c_reset_lex(void)
void error_reset_current_C_line_number(void)
Definition: clexer.c:1224
entity AllocatableArea
Definition: area.c:61
int c_wrap(void)
void error_reset_C_comment(bool)
int get_previous_C_line_number(void)
Should be called just before get_current_C_line_number.
Definition: clexer.c:1161
string GetScope(void)
Definition: cyacc.tab.c:371
void force_reset_c_parser_scope_stack(void)
To be used by an error handler.
Definition: cyacc.tab.c:539
void clear_C_comment(void)
Definition: clexer.c:1489
void PopContext(void)
Definition: cyacc.tab.c:441
void update_C_comment(string)
Add a comment to the current one.
Definition: clexer.c:1365
int get_declaration_counter(void)
Definition: cyacc.tab.c:497
entity GetFunction(void)
cproto workaround
Definition: cyacc.tab.c:146
int pop_current_C_line_number(void)
Definition: clexer.c:1202
int c_lineno
the file read in by the c_lexer
Definition: c_syntax.h:293