PIPS
|
#include "c_parser_private.h"
Go to the source code of this file.
Macros | |
#define | get_label_prefix() "-" |
The labels in C have function scope... More... | |
#define | FIRST_C_LINE_NUMBER (1) |
Error handling. More... | |
#define | UNDEFINED_C_LINE_NUMBER (-1) |
#define | CParserError(m) c_parser_error(CURRENT_FUNCTION, m) |
#define | c_parser_user_warning(...) c_parser_user_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__) |
Functions | |
int | c_lex () |
int | c_parse () |
entity | GetFunction (void) |
cproto workaround More... | |
void | reset_expression_comment (void) |
we don't want an expression comment with new lines, it is disgracefull More... | |
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. More... | |
string | scope_to_block_scope (string) |
Allocate a new string containing only block scope information. More... | |
c_parser_context | CreateDefaultContext (void) |
void | InitScope (void) |
int | ScopeStackSize (void) |
string | GetScope (void) |
string | GetParentScope (void) |
void | ExitScope (void) |
void | PushContext (c_parser_context) |
void | PopContext (void) |
c_parser_context | GetContext (void) |
c_parser_context | GetContextCopy (void) |
void | reset_declaration_counter (void) |
int | get_declaration_counter (void) |
void | init_c_parser_scope_stack (void) |
void | reset_c_parser_scope_stack (void) |
void | force_reset_c_parser_scope_stack (void) |
To be used by an error handler. More... | |
void | push_new_c_parser_scope (void) |
void | pop_c_parser_scope_stack (void) |
bool | c_parser_scope_stack_empty_p (void) |
string | get_c_parser_current_scope (void) |
string | get_c_parser_nth_scope (int) |
int | c_parser_number_of_scopes (void) |
int | get_previous_c_lineno (void) |
unsigned int | character_occurences_in_string (string, char) |
Use a stack to survive to file inclusions if any. More... | |
int | get_current_C_line_number (void) |
int | get_previous_C_line_number (void) |
Should be called just before get_current_C_line_number. More... | |
void | set_current_C_line_number (void) |
void | push_current_C_line_number (void) |
The line number stack, designed for structured control structure, is not used yet. More... | |
int | pop_current_C_line_number (void) |
void | reset_current_C_line_number (void) |
void | error_reset_current_C_line_number (void) |
void | reset_token_has_been_seen_p (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. More... | |
void | push_current_C_comment (void) |
Push the current C comment so that we can get it back when building the statement later. More... | |
string | pop_current_C_comment (void) |
Pop the current comment. More... | |
void | update_C_comment (string) |
Add a comment to the current one. More... | |
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 string. More... | |
void | discard_C_comment (void) |
Discard a C comment because we don't know how to deal with it. More... | |
void | reset_C_comment (bool) |
reset and reset_error should be handled differently More... | |
void | error_reset_C_comment (bool) |
void | clear_C_comment (void) |
void | init_C_comment (void) |
void | c_error (char *) |
void | c_reset_lex (void) |
int | c_wrap (void) |
Variables | |
FILE * | c_in |
int | c_lineno |
the file read in by the c_lexer More... | |
entity | DynamicArea |
These global variables are declared in ri-util/util.c. More... | |
entity | StaticArea |
entity | HeapArea |
entity | StackArea |
entity | AllocatableArea |
int | C_line_increment |
from "clex.l" More... | |
#define c_parser_user_warning | ( | ... | ) | c_parser_user_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__) |
Definition at line 55 of file c_syntax-local.h.
#define CParserError | ( | m | ) | c_parser_error(CURRENT_FUNCTION, m) |
Definition at line 54 of file c_syntax-local.h.
#define FIRST_C_LINE_NUMBER (1) |
Error handling.
Definition at line 51 of file c_syntax-local.h.
#define get_label_prefix | ( | ) | "-" |
The labels in C have function scope...
but beware of inlining... and conflict with user labels To disambiguate labels, in case inlining is performed later and to suppress the potential for conflicts with user labels.
Temporary entities have to be generated to be replaced later by the final labels. The temporary entities should be eliminated from the symbol table...
Definition at line 41 of file c_syntax-local.h.
#define UNDEFINED_C_LINE_NUMBER (-1) |
Definition at line 52 of file c_syntax-local.h.
void c_error | ( | char * | ) |
int c_lex | ( | ) |
int c_parse | ( | ) |
int c_parser_number_of_scopes | ( | void | ) |
Definition at line 587 of file cyacc.tab.c.
References c_parser_scope_stack, and stack_size().
Referenced by is_c_parser_keyword_typedef().
bool c_parser_scope_stack_empty_p | ( | void | ) |
Definition at line 564 of file cyacc.tab.c.
References c_parser_scope_stack, and stack_empty_p().
void c_reset_lex | ( | void | ) |
int c_wrap | ( | void | ) |
Use a stack to survive to file inclusions if any.
I guess that it is currently not used since file inclusion is already done by the preprocessor... RK To track the absolute line number in the file that is parsed use the default flex yylineno that is renamed c_lineno here Use a stack to survive to file inclusions if any Count the number of c in s.
Definition at line 1133 of file clexer.c.
References count, and string_undefined.
void clear_C_comment | ( | void | ) |
Comments in the compilation unit and outside of function bodies are lost because they are related only to declarations and because comments on declarations are lost.
Definition at line 1489 of file clexer.c.
References C_current_comment, count, free(), pips_assert, pips_debug, string_undefined, and string_undefined_p.
c_parser_context CreateDefaultContext | ( | void | ) |
Definition at line 292 of file cyacc.tab.c.
References empty_scope(), make_c_parser_context(), NIL, pips_debug, storage_undefined, and type_undefined.
void discard_C_comment | ( | void | ) |
Discard a C comment because we don't know how to deal with it.
The comments are only made of '
', just silently discarding them
Definition at line 1426 of file clexer.c.
References C_current_comment, C_line_number, character_occurences_in_string(), free(), pips_debug, string_undefined, and string_undefined_p.
Referenced by MakeBlock().
void error_reset_C_comment | ( | bool | ) |
void error_reset_current_C_line_number | ( | void | ) |
Definition at line 1224 of file clexer.c.
References C_line_number, c_lineno, FIRST_C_LINE_NUMBER, previous_C_line_number, previous_c_lineno, and UNDEFINED_C_LINE_NUMBER.
Referenced by c_parser_error().
void ExitScope | ( | void | ) |
Definition at line 400 of file cyacc.tab.c.
References c_parser_context_qualifiers, c_parser_context_scope, c_parser_context_storage, c_parser_context_undefined_p, ContextStack, ENDP, free_c_parser_context(), pips_assert, pips_debug, pop_c_parser_scope_stack(), stack_empty_p(), stack_head(), stack_pop(), storage_undefined_p, and string_undefined_p.
void force_reset_c_parser_scope_stack | ( | void | ) |
To be used by an error handler.
Definition at line 539 of file cyacc.tab.c.
References c_parser_scope_number, c_parser_scope_stack, SCOPE_UNDEFINED, stack_free(), and stack_undefined.
Referenced by c_parser_error().
string get_c_parser_current_scope | ( | void | ) |
Definition at line 569 of file cyacc.tab.c.
References c_parser_scope_stack, c_parser_scope_stack_empty_p(), stack_head(), and string_undefined.
Referenced by c_parser_put_new_typedef(), and is_c_parser_keyword_typedef().
Definition at line 581 of file cyacc.tab.c.
References c_parser_scope_stack, and stack_nth().
Referenced by is_c_parser_keyword_typedef().
string get_current_C_comment | ( | void | ) |
Return the current comment as a string to be freed by the caller and reset the current comment.
If the current comment is undefined, returns a copy of the empty string, "".
Reset also the current comment.
If the comment begins with a new-line, it is indeed the new-line that ends the previous statement, so skip it. Quicker than strlen()
Note there won't be a memory leak since the orginal '\0' is in the malloc() bloc to be free()ed anyway...
If the comment is only an empty one, do not retain it:
Do retain it to keep the statement data structure easy to use, allowing strdup() on its text fields
Remove the trailing new-line if any since the RI is already line-oriented at the comment level: This is already done above.
It is a trailing new-line: just get rid of it:
pips_debug(3, "get_current_C_comment comment \"s"
", cc);
Definition at line 1282 of file clexer.c.
References C_current_comment, strdup(), and string_undefined.
Referenced by ExpressionToStatement(), MakeCaseStatement(), MakeDefaultStatement(), and MakeGotoStatement().
int get_current_C_line_number | ( | void | ) |
FI: I assume that get_current_C_line_number is called only by some kind of make_statement()
The PIPS preprocessed C function files contain a specific first line to convert the line number in the workspace unto a line number in the user source file.
Definition at line 1146 of file clexer.c.
References C_line_number, c_lineno, previous_C_line_number, and previous_c_lineno.
Referenced by c_parser_error(), c_parser_user_warning_alist(), ExpressionToStatement(), FindEntityFromLocalNameAndPrefix(), MakeForloop(), MakeGotoStatement(), and MakeWhileLoop().
int get_declaration_counter | ( | void | ) |
Definition at line 497 of file cyacc.tab.c.
References declaration_counter.
Referenced by set_current_dummy_parameter_number().
int get_previous_C_line_number | ( | void | ) |
Should be called just before get_current_C_line_number.
Definition at line 1161 of file clexer.c.
References previous_C_line_number.
Referenced by c_parser_user_warning_alist().
int get_previous_c_lineno | ( | void | ) |
Definition at line 1115 of file clexer.c.
References previous_c_lineno.
Referenced by c_parser_user_warning_alist().
c_parser_context GetContext | ( | void | ) |
Definition at line 458 of file cyacc.tab.c.
References c_parser_context_undefined, ContextStack, pips_debug, pips_internal_error, stack_empty_p(), stack_head(), and stack_size().
Referenced by FindOrCreateCurrentEntity().
c_parser_context GetContextCopy | ( | void | ) |
Definition at line 476 of file cyacc.tab.c.
References c_parser_context_scope, ContextStack, copy_c_parser_context(), pips_debug, stack_head(), and stack_size().
entity GetFunction | ( | void | ) |
cproto workaround
from "cyacc.y"
Definition at line 146 of file cyacc.tab.c.
References f(), FunctionStack, and stack_head().
string GetParentScope | ( | void | ) |
Definition at line 387 of file cyacc.tab.c.
References c_parser_context_scope, ContextStack, stack_empty_p(), stack_nth(), and stack_size().
Referenced by FindEntityFromLocalNameAndPrefix().
string GetScope | ( | void | ) |
FI: I do not know if it wouldn't be better to initialize the ContextStack with a default context before calling the C parser
Definition at line 371 of file cyacc.tab.c.
References c_parser_context_scope, ContextStack, stack_empty_p(), and stack_head().
Referenced by CreateEntityFromLocalNameAndPrefix(), CreateMemberScope(), and FindEntityFromLocalNameAndPrefix().
void init_C_comment | ( | void | ) |
Definition at line 1513 of file clexer.c.
References bracket_depth, C_current_comment, pips_internal_error, STACK_NULL_P, stack_undefined_p, string_undefined_p, and token_has_been_seen_p.
Referenced by actual_c_parser().
void init_c_parser_scope_stack | ( | void | ) |
Definition at line 514 of file cyacc.tab.c.
References c_parser_scope_number, c_parser_scope_stack, pips_assert, stack_make(), stack_undefined_p, and string_domain.
Referenced by actual_c_parser().
void InitScope | ( | void | ) |
Definition at line 306 of file cyacc.tab.c.
References C_scope_identifier.
Referenced by actual_c_parser().
The scope is moved up the scope tree and a NULL is return when there are no more scope to explore.
get rid of last block separator
old_scope | ld_scope |
Definition at line 235 of file cyacc.tab.c.
References BLOCK_SEP_CHAR, pips_assert, pips_debug, string_block_scope_p(), and string_undefined.
Referenced by FindEntityFromLocalNameAndPrefixAndScope(), and FindOrCreateEntityFromLocalNameAndPrefixAndScope().
void pop_c_parser_scope_stack | ( | void | ) |
Definition at line 558 of file cyacc.tab.c.
References c_parser_scope_stack, and stack_pop().
string pop_current_C_comment | ( | void | ) |
Pop the current comment.
This is typically used at the end of a statement to be built.
Note this do not set the current comment. Strange API...
Definition at line 1352 of file clexer.c.
References get_current_C_line_number(), pips_debug, and string_undefined_p.
Referenced by MakeForloop().
int pop_current_C_line_number | ( | void | ) |
Definition at line 1202 of file clexer.c.
References c_lineno.
Referenced by MakeForloop().
void PopContext | ( | void | ) |
Definition at line 441 of file cyacc.tab.c.
References c_parser_context_scope, ContextStack, pips_debug, stack_empty_p(), stack_head(), stack_pop(), and stack_size().
void push_current_C_comment | ( | void | ) |
Push the current C comment so that we can get it back when building the statement later.
This reset the current comment through get_current_C_comment()
Definition at line 1331 of file clexer.c.
References get_current_C_comment(), get_current_C_line_number(), pips_debug, and string_undefined_p.
void push_current_C_line_number | ( | void | ) |
The line number stack, designed for structured control structure, is not used yet.
Definition at line 1194 of file clexer.c.
References c_lineno, and get_current_C_line_number().
void push_new_c_parser_scope | ( | void | ) |
Definition at line 549 of file cyacc.tab.c.
References asprintf, c_parser_scope_number, c_parser_scope_stack, stack_push(), and string_undefined.
void PushContext | ( | c_parser_context | c | ) |
Definition at line 434 of file cyacc.tab.c.
References c_parser_context_scope, ContextStack, pips_debug, stack_push(), and stack_size().
void remove_LFs_from_C_comment | ( | int | extra_LF | ) |
Remove "extra_LF" trailing LF from C_current_comment if they can be found at the end of the comment string.
extra_LF | xtra_LF |
Definition at line 1398 of file clexer.c.
References C_current_comment, pips_debug, pips_user_warning, string_undefined, and token_has_been_seen_p.
Referenced by analyze_preprocessor_line().
void reset_C_comment | ( | bool | is_compilation_unit_p | ) |
reset and reset_error should be handled differently
Comments in the compilation unit are lost because they are related only to declarations and because comments on declarations are lost. Also, comments located at the end of a block are lost, as we do not generate an extra NOP to carry them.
pips_internal_error("Comments stack is not empty\n");
is_compilation_unit_p | s_compilation_unit_p |
Definition at line 1450 of file clexer.c.
References bracket_depth, C_current_comment, clear_C_comment(), count, fprintf(), free(), pips_user_warning, string_undefined, string_undefined_p, and token_has_been_seen_p.
Referenced by actual_c_parser(), and c_parser_error().
void reset_c_parser_scope_stack | ( | void | ) |
Definition at line 522 of file cyacc.tab.c.
References c_parser_scope_number, c_parser_scope_stack, pips_user_warning, SCOPE_UNDEFINED, stack_empty_p(), stack_free(), and stack_undefined.
Referenced by actual_c_parser().
void reset_current_C_line_number | ( | void | ) |
Definition at line 1210 of file clexer.c.
References C_line_number, c_lineno, FIRST_C_LINE_NUMBER, pips_internal_error, previous_C_line_number, previous_c_lineno, and UNDEFINED_C_LINE_NUMBER.
Referenced by actual_c_parser().
void reset_declaration_counter | ( | void | ) |
Definition at line 492 of file cyacc.tab.c.
References declaration_counter.
Referenced by actual_c_parser(), and c_parser_error().
void reset_expression_comment | ( | void | ) |
we don't want an expression comment with new lines, it is disgracefull
Too bad. This should not happen, but it happens with comma expressions in header files
Definition at line 169 of file cyacc.tab.c.
References expression_comment, expression_line_number, free(), STATEMENT_NUMBER_UNDEFINED, string_undefined, and string_undefined_p.
Referenced by actual_c_parser(), and c_parser_error().
void reset_token_has_been_seen_p | ( | void | ) |
Allocate a new string containing only block scope information.
full_scope | ull_scope |
Definition at line 268 of file cyacc.tab.c.
References BLOCK_SEP_CHAR, gen_strndup0(), MODULE_SEP, pips_assert, pips_debug, strdup(), string_block_scope_p(), and string_undefined.
Referenced by constant_memory_access_path_to_location_name(), CreateEntityFromLocalNameAndPrefix(), CreateMemberScope(), FindEntityFromLocalNameAndPrefix(), and FindOrCreateCurrentEntity().
int ScopeStackSize | ( | void | ) |
Definition at line 366 of file cyacc.tab.c.
References ContextStack, and stack_size().
Referenced by FindEntityFromLocalNameAndPrefix().
void set_current_C_line_number | ( | void | ) |
Initialize the user line number...
... and the absolute line number in the current file
The first line is used to indicate the line number in the user source file
Some check on it first? It should have been disallocated by reset_current_C_line_number()
Definition at line 1166 of file clexer.c.
References C_line_increment, C_line_number, c_lineno, FIRST_C_LINE_NUMBER, pips_internal_error, previous_C_line_number, previous_c_lineno, and UNDEFINED_C_LINE_NUMBER.
Referenced by actual_c_parser().
void update_C_comment | ( | string | a_comment | ) |
Add a comment to the current one.
Do not add LFs that appear within a statement
Do not concatenate two comments without a LF
a_comment | _comment |
Definition at line 1365 of file clexer.c.
References C_current_comment, concatenate(), free(), pips_debug, strdup(), string_undefined, string_undefined_p, and token_has_been_seen_p.
|
extern |
Definition at line 291 of file c_syntax.h.
Referenced by __memchr(), actual_c_parser(), contrainte_copy(), contrainte_dup(), contraintes_copy(), contraintes_dup(), controlize_list_1(), rawmemchr(), statement_arrows(), strchrnul(), uns_rwt(), and unstructured_to_direct_declarations().
|
extern |
from "clex.l"
from "clex.l"
The goal is to reconstruct the line number in the user file and not the line number in the preprocessed file.
This is performed in analyze_preprocessor_line() (util.c)
Definition at line 296 of file c_syntax.h.
Referenced by analyze_preprocessor_line().
|
extern |
the file read in by the c_lexer
Definition at line 293 of file c_syntax.h.
Referenced by c_parser_user_warning_alist(), error_reset_current_C_line_number(), get_current_C_line_number(), pop_current_C_line_number(), push_current_C_line_number(), reset_current_C_line_number(), and set_current_C_line_number().
|
extern |
These global variables are declared in ri-util/util.c.
These global variables are declared in ri-util/util.c.
functions for areas Four areas used to allocate variables which are not stored in a Fortran common. These areas are just like Fortran commons, but the dynamic area is the only non-static area according to Fortran standard. The heap and the stack area are used to deal with Fortran ANSI extensions and C, pointers and allocatable arrays, and adjustable arrays (VLA in C). The dynamic area is stack allocated by most compilers but could be statically allocated since the array sizes are known.
Areas are declared for each module. These four global variables are managed by the Fortran and C parsers and used to allocate variables in the current module. Note that the C parser uses more areas at the same time to cope with global variables.
Definition at line 57 of file area.c.
Referenced by ComputeAddresses(), EndOfProcedure(), gfc2pips_code2instruction__TOP(), gfc2pips_computeAdressesDynamic(), gfc2pips_computeAdressesOfArea(), gfc2pips_expr2entity(), gfc2pips_expr2expression(), gfc2pips_vars_(), init_c_areas(), init_c_implicit_variables(), InitAreas(), make_empty_module(), MakeStorageRam(), MakeVariableStatic(), ParserError(), save_all_entities(), and SaveEntity().
|
extern |
Definition at line 59 of file area.c.
Referenced by ComputeAddresses(), DeclarePointer(), dump_common_layout(), gfc2pips_computeAdressesHeap(), gfc2pips_computeAdressesOfArea(), gfc2pips_vars_(), init_c_areas(), InitAreas(), make_empty_module(), and ParserError().
|
extern |
Definition at line 60 of file area.c.
Referenced by CModuleMemoryAllocation(), ComputeAddresses(), dump_common_layout(), gfc2pips_computeAdressesOfArea(), gfc2pips_parameters(), gfc2pips_vars_(), init_c_areas(), InitAreas(), make_empty_module(), and MakeStorageRam().
|
extern |
Definition at line 58 of file area.c.
Referenced by AnalyzeData(), ComputeAddresses(), EndOfProcedure(), fix_storage(), gfc2pips_code2instruction__TOP(), gfc2pips_computeAdressesOfArea(), gfc2pips_computeAdressesStatic(), gfc2pips_namespace(), init_c_areas(), InitAreas(), make_common_entity(), make_empty_module(), make_new_common(), MakeStorageRam(), MakeVariableStatic(), ParserError(), ProcessEntry(), save_all_entities(), and SaveEntity().