From 5abd43782fb3fb4fe2fa76f4a7eb364fc46d7220 Mon Sep 17 00:00:00 2001 From: vijaygopalchilkuri Date: Tue, 9 Jul 2013 19:53:05 +0200 Subject: [PATCH 1/2] Bug in touch of multiple variables --- src/parsed_text.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/parsed_text.py b/src/parsed_text.py index 2c07ad1..6c09612 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -1,7 +1,7 @@ #!/usr/bin/python # IRPF90 is a Fortran90 preprocessor written in Python for programming using # the Implicit Reference to Parameters (IRP) method. -# Copyright (C) 2009 Anthony SCEMAMA +# Copyright (C) 2009 Anthony SCEMAMA # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,8 +20,8 @@ # Anthony Scemama # LCPQ - IRSAMC - CNRS # Universite Paul Sabatier -# 118, route de Narbonne -# 31062 Toulouse Cedex 4 +# 118, route de Narbonne +# 31062 Toulouse Cedex 4 # scemama@irsamc.ups-tlse.fr @@ -82,7 +82,6 @@ def check_touch(line,vars,main_vars): all_others = make_single(flatten( map(fun,main_vars) )) all_others.sort() vars.sort() - print vars for x,y in zip(vars,all_others): if x != y: message = "The following entities should be touched:\n" @@ -118,7 +117,7 @@ def update_variables(): variables[line.filename]._is_written = True ################################################################################ - + def get_parsed_text(): def func(filename, text): varlist = [] @@ -144,7 +143,7 @@ def get_parsed_text(): Subroutine, Function, End, - ]: + ]: append( ([],line) ) elif type(line) in [ Begin_provider, Cont_provider ]: if type(line) == Begin_provider: @@ -243,7 +242,7 @@ def get_parsed_text(): # main_result.append( (filename, func(filename,text)) ) #return main_result return parallel_loop(func,preprocessed_text) - + update_variables() parsed_text = get_parsed_text() @@ -321,7 +320,7 @@ def add_subroutine_needs(): append( (vars,line) ) main_result.append( (filename, result) ) return main_result - + parsed_text = add_subroutine_needs() ###################################################################### @@ -386,7 +385,7 @@ def move_variables(): error.fail(line,"Unable to parse file") result.reverse() - + # 2nd pass text = result result = [] @@ -458,12 +457,12 @@ def build_needs(): Simple_line, Assert, Do , If, Elseif , Select, - ]: + ]: funcs = find_funcs_in_line(line) for f in funcs: - var.needs += subroutines[f].needs + var.needs += subroutines[f].needs for v in variables: - main = variables[v].same_as + main = variables[v].same_as if main != v: variables[v].needs = variables[main].needs variables[v].to_provide = variables[main].to_provide @@ -472,7 +471,7 @@ def build_needs(): for v in variables: variables[v].needed_by = [] for v in variables: - main = variables[v].same_as + main = variables[v].same_as if main != v: variables[v].needed_by = variables[main].needed_by for v in variables: @@ -534,7 +533,7 @@ def perform_loop_substitutions(): append( (vars,line) ) main_result.append( (filename, result) ) return main_result - + parsed_text = perform_loop_substitutions() ###################################################################### From 5e15a7ad05bf6068dfbb4f08c593512b62bda105 Mon Sep 17 00:00:00 2001 From: vijaygopalchilkuri Date: Wed, 2 Apr 2014 23:01:33 +0200 Subject: [PATCH 2/2] add support for interface block --- src/preprocessed_text.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 9eb2db3..9ee8e33 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -37,12 +37,12 @@ re_enddo = re.compile("end\s+do") re_endtype= re.compile("end\s+type") re_endmodule = re.compile("end\s+module") re_endselect = re.compile("end\s+select") +re_endinterface = re.compile("end\s+interface") # Local variables Free_form = 0 Fixed_form = 1 - ###################################################################### # Dictionary of simple statements simple_dict = { @@ -95,6 +95,9 @@ def get_type (i, filename, line, is_doc): assert type(line) == str assert type(is_doc) == bool + # add support for interface block + has_interface = False + line = line.rstrip() line = line.replace("$IRP_ALIGN",command_line.align) lower_line0 = line.lstrip().lower() @@ -107,6 +110,7 @@ def get_type (i, filename, line, is_doc): lower_line = re_endmodule.sub("endmodule",lower_line) lower_line = re_endif.sub("endif",lower_line) lower_line = re_endselect.sub("endselect",lower_line) + lower_line = re_endinterface.sub("endinterface",lower_line) for c in """()'"[]""": lower_line = lower_line.replace(c," "+c+" ") @@ -122,6 +126,14 @@ def get_type (i, filename, line, is_doc): firstword = buffer[0] # Identify line + if firstword == "endinterface": + has_interface = False + return [ Simple_line (i,line,filename) ], False + + if firstword == "interface" or has_interface: + has_interface = True + return [ Simple_line (i,line,filename) ], False + if firstword == "end_doc": return [ End_doc (i,line,filename) ], False