improved parser, fixed convertation

This commit is contained in:
ALEXks
2024-02-25 11:16:56 +03:00
parent deaeb4a670
commit 4386eb7041
13 changed files with 259 additions and 152 deletions

View File

@@ -80,6 +80,7 @@ extern void BufferAllocate();
int out_free_form;
int out_upper_case;
int out_line_unlimit;
int out_line_length; // out_line_length = 132 for -ffo mode; out_line_length = 72 for -uniForm mode
PTR_SYMB last_file_symbol;
static int CountNullBifNext = 0; /* for internal debugging */
@@ -1305,14 +1306,14 @@ char* filter(char *s)
{
char c;
int i = 1, quote = 0;
// 14.10.2016 Kolganov. Switch constant buffer to dynamic
int temp_size = 4096;
char *temp = (char*)malloc(sizeof(char) * temp_size);
#ifdef __SPF
addToCollection(__LINE__, __FILE__,temp, 0);
#endif
// out_line_length = 132 if -ffo option is used or out_line_length = 72 if -uniForm option is used
int temp_i = 0;
int buf_i = 0;
int commentline = 0;
@@ -1442,7 +1443,7 @@ char* filter(char *s)
}
else
{
if (((!out_free_form && temp_i == 71) || (out_free_form && !out_line_unlimit && temp_i == 131)) && !commentline && (s[i + 1] != '\n'))
if (((!out_free_form && temp_i == 71) || (out_free_form && !out_line_unlimit && temp_i == out_line_length - 1)) && !commentline && (s[i + 1] != '\n'))
{
if (buf_i + 1 > temp_size)
{
@@ -1479,7 +1480,7 @@ char* filter(char *s)
buf_i = -1;
}
if (((!out_free_form && temp_i == 71) || (out_free_form && !out_line_unlimit && temp_i == 131)) && commentline && (s[i + 1] != '\n') && ((OMP == 1) || (OMP == 2) || (DVM == 1) || (SPF == 1))) /*07.08.17*/
if (((!out_free_form && temp_i == 71) || (out_free_form && !out_line_unlimit && temp_i == out_line_length - 1)) && commentline && (s[i + 1] != '\n') && ((OMP == 1) || (OMP == 2) || (DVM == 1) || (SPF == 1))) /*07.08.17*/
{
if (buf_i + 1 > temp_size)
{

View File

@@ -80,6 +80,7 @@ extern int iacross;
extern "C" int out_free_form;
extern "C" int out_upper_case;
extern "C" int out_line_unlimit;
extern "C" int out_line_length;
extern "C" PTR_SYMB last_file_symbol;
Options options;
@@ -280,6 +281,11 @@ int main(int argc, char *argv[])
out_upper_case = 1;
else if (!strcmp(argv[0], "-noLimitLine"))
out_line_unlimit = 1;
else if (!strcmp(argv[0], "-uniForm"))
{
out_free_form = 1;
out_line_length = 72;
}
else if (!strcmp(argv[0], "-noRemote"))
options.setOn(NO_REMOTE);
else if (!strcmp(argv[0], "-lgstd"))
@@ -365,6 +371,11 @@ int main(int argc, char *argv[])
(void)fprintf(stderr, "Warning: -Ohost option is set to -Opl2 mode\n");
options.setOn(O_HOST);
}
if(out_free_form == 1 && out_line_length == 72 && out_line_unlimit == 1)
{
(void)fprintf(stderr, "Warning: -noLimitLine and -uniForm options are incompatible; -noLimitLine option is ignored\n");
out_line_unlimit = 0;
}
if (v_print)
(void)fprintf(stderr, "<<<<< Translating >>>>>\n");
@@ -392,7 +403,7 @@ int main(int argc, char *argv[])
// for call of function 'tpoint'
//added one symbol to input-file name
//printf("%s",fin_name); //!!! debug
if(a_mode && project.numberOfFiles()>1)
if(a_mode || project.numberOfFiles()>1)
fout_name = doOutFileName(file->filename()); //project.fileName(id);
else if (fout_name && source_name && !strcmp(source_name, fout_name))
{
@@ -582,6 +593,7 @@ void initialize()
out_free_form = 0;
out_upper_case = 0;
out_line_unlimit = 0;
out_line_length = 132;
default_integer_size = 4;
default_real_size = 4;
unparse_functions = 0; //set to 1 by option -byFunUnparse

View File

@@ -507,6 +507,8 @@ int main(int argc, char *argv[])
;
else if (!strcmp(argv[0], "-noLimitLine"))
;
else if (!strcmp(argv[0], "-uniForm"))
;
else if (!strcmp(argv[0], "-noRemote"))
;
else if (!strcmp(argv[0], "-lgstd"))

View File

@@ -1945,6 +1945,8 @@ copy_module_scope(sym_mod,list)
for(source=sym_mod->entry.Template.next; source; source=source->entry.Template.next) {
if((source->attr & PRIVATE_BIT) && (!(source->attr & PUBLIC_BIT)) )
continue;
if(source->variant == FUNCTION_NAME && source->decl != YES) /* intrinsic function called from specification expression */ /* podd 24.02.24 */
continue;
if(list && in_rename_list(source,list))
continue;
if((copy=just_look_up_sym_in_scope(cur_scope(),source->ident)) && copy->id_attr && copy->id_attr->entry.Template.tag==sym_mod->entry.Template.func_hedr->id)