PIPS
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "parser_private.h"
#include "syntax.h"
#include "resources.h"
#include "database.h"
#include "misc.h"
#include "pipsdbm.h"
Go to the source code of this file.
Functions | |
void | reset_current_label_string () |
string | get_current_label_string () |
void | set_current_label_string (string ln) |
bool | empty_current_label_string_p () |
static void | reset_parser_recursive_call () |
Safety for recursive calls of parser required to process entries. More... | |
static void | set_parser_recursive_call () |
bool | ParserError (const char *f, const char *m) |
void | BeginingOfParsing () |
this function is called for each new file (FI: once?) FI: I do not understand how this works. More... | |
static bool | the_actual_parser (string module, string dbr_file) |
parse "module.dbr_file" More... | |
bool | hpfc_parser (const string module) |
parser for HPFC. More... | |
bool | parser (const string module) |
void | init_parser_properties (void) |
Variables | |
char * | CurrentFN = NULL |
Pre-parser for Fortran syntax idiosyncrasy. More... | |
cons * | FormalParameters = NIL |
the current function More... | |
const char * | CurrentPackage = NULL |
the name of the current package, i.e. More... | |
int | line_b_I |
Indicates where the current instruction (in fact statement) starts and ends in the input file and gives its label. More... | |
int | line_e_I |
int | line_b_C |
int | line_e_C |
char | lab_I [6] |
char | FormatValue [FORMATLENGTH] |
a string that will contain the value of the format in case of format statement More... | |
static bool | parser_recursive_call = false |
bool | InParserError = false |
Parser error handling. More... | |
void BeginingOfParsing | ( | void | ) |
this function is called for each new file (FI: once?) FI: I do not understand how this works.
It has an effect only once during a pips process lifetime. The error handling routine resets CurrentPackage to NULL, as it is when the pips process is started.
Should I:
A modify the error handling routine to reset CurrentPackage to TOP_LEVEL_MODULE_NAME?
B reset CurrentPackage to TOP_LEVEL_MODULE_NAME each time the parser is entered?
I choose A.
the current package is initialized
Definition at line 208 of file parser.c.
References CurrentPackage, and TOP_LEVEL_MODULE_NAME.
Referenced by the_actual_parser().
bool empty_current_label_string_p | ( | void | ) |
Definition at line 87 of file parser.c.
References lab_I, and same_string_p.
Referenced by MakeElseInst().
string get_current_label_string | ( | void | ) |
Definition at line 76 of file parser.c.
References lab_I.
Referenced by MakeElseInst().
parser for HPFC.
just a different input file not to touch the original source file. this parser should be selected/activated automatically.
module | odule |
Definition at line 286 of file parser.c.
References module, and the_actual_parser().
void init_parser_properties | ( | void | ) |
Definition at line 296 of file parser.c.
References init_parser_reader_properties().
Referenced by the_actual_parser().
module | odule |
Definition at line 291 of file parser.c.
References module, and the_actual_parser().
bool ParserError | ( | const char * | f, |
const char * | m | ||
) |
Maybe a routine called by ParserError() may call ParserError() e.g. AbortOfProcedure() thru remove_ghost_variables()
Get rid of partly declared variables...
Callers may already have pointers towards this function. The prettyprinter core dumps if entity_initial is destroyed. Maybe, I should clean the declarations field in code, as well as decls_text.
The error may occur before the current module entity is defined
GetChar() will reinitialize its own buffer when called
Because of the strange behavior of BeginingOfParsing
CurrentPackage = NULL;
Too bad for memory leak...
FI: let catch_error() take care of this in pipsmake since debug_on() was not activated in ParserError
Should never be executed
Definition at line 116 of file parser.c.
References AbortEntries(), AbortOfProcedure(), CleanLocalEntities(), code_declarations, code_decls_text, CurrentFN, CurrentPackage, DynamicArea, entity_initial, entity_undefined, error_reset_current_module_entity(), f(), free(), get_current_module_entity(), HeapArea, InParserError, line_b_I, line_e_I, NIL, parser_reset_all_reader_buffers(), parser_reset_StmtHeap_buffer(), reset_common_size_map_on_error(), reset_parser_recursive_call(), ResetBlockStack(), ResetChains(), ResetReturnCodeVariable(), safe_fclose(), soft_reset_alternate_returns(), StaticArea, string_undefined, SubstituteAlternateReturns(), syn_in, syn_reset_lex(), TOP_LEVEL_MODULE_NAME, user_error, uses_alternate_return(), and value_code.
Referenced by AddVariableToCommon(), AnalyzeData(), CapitalizeStmt(), check_in_declarations(), CheckAndInitializeStmt(), CheckParenthesis(), ComputeAddresses(), DeclareExternalFunction(), DeclarePointer(), DeclareVariable(), EndOfProcedure(), EvalCall(), EvalSyntax(), expression_reference_number(), find_target_position(), fix_if_condition(), fix_storage(), FortranExpressionList(), IsCapKeyword(), LinkInstToCurrentBlock(), make_Fortran_constant_entity(), MakeAssignInst(), MakeAtom(), MakeCurrentFunction(), MakeDataValueSet(), MakeElseInst(), MakeEnddoInst(), MakeEndifInst(), MakeEntryCommon(), MakeEquivAtom(), MakeFormalParameter(), MakeFortranBinaryCall(), MakeFortranType(), MakeFortranUnaryCall(), MakeParameter(), MakeSimpleIoInst1(), MakeSimpleIoInst2(), MakeStatement(), MakeVariableStatic(), NeedKeyword(), NewStmt(), parser_add_a_macro(), PopBlock(), process_static_initialization(), process_value_list(), PushBlock(), ReadLine(), ReadStmt(), remove_ghost_variable_entities(), reset_common_size_map(), SafeSizeOfArray(), SaveChains(), SaveEntity(), store_initial_value(), SubstituteAlternateReturns(), TypeFunctionalEntity(), update_called_modules(), update_functional_type_result(), uses_alternate_return(), and ValueOfIthLowerBound().
void reset_current_label_string | ( | void | ) |
Definition at line 71 of file parser.c.
References lab_I.
Referenced by LinkInstToCurrentBlock(), and MakeElseInst().
|
static |
Safety for recursive calls of parser required to process entries.
Definition at line 101 of file parser.c.
References parser_recursive_call.
Referenced by ParserError(), and the_actual_parser().
void set_current_label_string | ( | string | ln | ) |
ln | n |
Definition at line 81 of file parser.c.
References lab_I, and pips_assert.
Referenced by MakeElseInst().
|
static |
Definition at line 106 of file parser.c.
References parser_recursive_call.
Referenced by the_actual_parser().
parse "module.dbr_file"
set up parser properties
parser is initialized
scanner is initialized
yacc parser is called
Handle the special case for entries without looping forever
The requested parsed code may have been an entry code. Then it is not yet computed because the parsed code for the module was produced and only a file resource was produced for the entry code.
This debug_off() occurs too late since pipsdbm has been called before. Initially, the parser was designed to parse more than one subroutine/function/program at a time.
Definition at line 223 of file parser.c.
References BeginingOfParsing(), concatenate(), CurrentFN, db_get_current_workspace_directory(), db_get_file_resource, db_resource_p(), debug_off, debug_on, EmptyEntryListsP(), free(), init_parser_properties(), module, parser_init_macros_support(), parser_recursive_call, pips_assert, pips_internal_error, reset_parser_recursive_call(), ResetEntries(), safe_fclose(), safe_fopen(), ScanNewFile(), set_parser_recursive_call(), strdup(), syn_in, and syn_parse().
Referenced by hpfc_parser(), and parser().
char* CurrentFN = NULL |
Pre-parser for Fortran syntax idiosyncrasy.
parser.c
name of the current file
Definition at line 49 of file parser.c.
Referenced by check_first_statement(), dump_current_statement(), ParserError(), and the_actual_parser().
const char* CurrentPackage = NULL |
the name of the current package, i.e.
TOP-LEVEL or a module name?
Definition at line 58 of file parser.c.
Referenced by BeginingOfParsing(), EndOfProcedure(), get_use_entities_list(), gfc2pips_add_to_callees(), InitAreas(), MakeCurrentFunction(), MakeLabel(), NameToFunctionalEntity(), ParserError(), and update_common_sizes().
the current function
entity CurrentFunction; list of formal parameters of the current function
Definition at line 55 of file parser.c.
Referenced by EndOfProcedure(), and ScanFormalParameters().
char FormatValue[FORMATLENGTH] |
char lab_I[6] |
Definition at line 69 of file parser.c.
Referenced by empty_current_label_string_p(), EndOfProcedure(), GenerateReturn(), get_current_label_string(), LinkInstToCurrentBlock(), MakeEnddoInst(), ReadStmt(), reset_current_label_string(), and set_current_label_string().
int line_b_C |
Definition at line 68 of file parser.c.
Referenced by check_first_statement(), and set_first_format_statement().
int line_b_I |
Indicates where the current instruction (in fact statement) starts and ends in the input file and gives its label.
Temporary versions of these variables are used because of the pipeline existing between the reader and the actual parser. The names of the temporary variables are prefixed with "tmp_". The default and reset values of these variables and their temporary versions (declared in reader.c) must be consistent.
Definition at line 68 of file parser.c.
Referenced by add_alternate_return(), AddVariableToCommon(), check_first_statement(), DeclarePointer(), DeclareVariable(), dump_current_statement(), fix_if_condition(), implied_do_reference_number(), MakeReturn(), MakeWhileDoInst(), ParserError(), ReadStmt(), set_first_format_statement(), update_functional_type_with_actual_arguments(), and uses_alternate_return().
int line_e_I |
Definition at line 68 of file parser.c.
Referenced by add_alternate_return(), AddVariableToCommon(), DeclarePointer(), DeclareVariable(), fix_if_condition(), implied_do_reference_number(), MakeReturn(), MakeWhileDoInst(), ParserError(), update_functional_type_with_actual_arguments(), and uses_alternate_return().
Definition at line 98 of file parser.c.
Referenced by reset_parser_recursive_call(), set_parser_recursive_call(), and the_actual_parser().