mirror of
https://gitlab.com/scemama/irpf90.git
synced 2024-12-22 04:13:33 +01:00
Corrected bugs
Version:1.1.3
This commit is contained in:
parent
e1fb434bc8
commit
414d47a6e1
@ -265,7 +265,7 @@ def create_irpf90_files():
|
|||||||
import os
|
import os
|
||||||
if command_line.do_run:
|
if command_line.do_run:
|
||||||
def is_irpf90_file(filename):
|
def is_irpf90_file(filename):
|
||||||
return filename.endswith(".irp.f") and filename.startswith("p")
|
return filename.endswith(".irp.f") #DEUBUG and filename.startswith("p")
|
||||||
result = filter ( is_irpf90_file, os.listdir(os.getcwd()) )
|
result = filter ( is_irpf90_file, os.listdir(os.getcwd()) )
|
||||||
return result
|
return result
|
||||||
irpf90_files = create_irpf90_files()
|
irpf90_files = create_irpf90_files()
|
||||||
|
@ -20,25 +20,20 @@ def find_variables_in_line(line):
|
|||||||
|
|
||||||
def find_subroutine_in_line(line):
|
def find_subroutine_in_line(line):
|
||||||
assert isinstance(line,Call)
|
assert isinstance(line,Call)
|
||||||
buffer = regexps.re_string.sub('',line.text)
|
buffer = line.text.split('(')[0]
|
||||||
result = None
|
buffer = buffer.split()[1]
|
||||||
for v in subroutines.keys():
|
return buffer
|
||||||
sub = subroutines[v]
|
|
||||||
if sub.regexp.search(buffer) is not None:
|
|
||||||
result = sub.name
|
|
||||||
break
|
|
||||||
assert result is not None
|
|
||||||
return result
|
|
||||||
|
|
||||||
def check_touch(vars,main_vars):
|
def check_touch(line,vars,main_vars):
|
||||||
def fun(main_var):
|
def fun(main_var):
|
||||||
if main_var not in variables:
|
if main_var not in variables:
|
||||||
error.fail(line,"Variable %s unknown"%(main_var,))
|
error.fail(line,"Variable %s unknown"%(main_var,))
|
||||||
x = variables[main_var]
|
x = variables[main_var]
|
||||||
return [main_var]+x.others
|
return [main_var]+x.others
|
||||||
all_others = flatten( map(fun,main_vars) )
|
all_others = make_single(flatten( map(fun,main_vars) ))
|
||||||
all_others.sort()
|
all_others.sort()
|
||||||
if len(all_others) == len(vars):
|
if len(all_others) == len(vars):
|
||||||
|
vars.sort()
|
||||||
for x,y in zip(vars,all_others):
|
for x,y in zip(vars,all_others):
|
||||||
if x != y:
|
if x != y:
|
||||||
message = "The following entities should be touched:\n"
|
message = "The following entities should be touched:\n"
|
||||||
@ -46,9 +41,9 @@ def check_touch(vars,main_vars):
|
|||||||
error.fail(line,message)
|
error.fail(line,message)
|
||||||
|
|
||||||
def get_parsed_text():
|
def get_parsed_text():
|
||||||
result = []
|
main_result = []
|
||||||
for filename, text in preprocessed_text:
|
for filename, text in preprocessed_text:
|
||||||
temp_result = []
|
result = []
|
||||||
varlist = []
|
varlist = []
|
||||||
for line in filter(
|
for line in filter(
|
||||||
lambda x: type(x) not in [ Doc, Begin_doc, End_doc ],
|
lambda x: type(x) not in [ Doc, Begin_doc, End_doc ],
|
||||||
@ -70,21 +65,24 @@ def get_parsed_text():
|
|||||||
Function,
|
Function,
|
||||||
End,
|
End,
|
||||||
]:
|
]:
|
||||||
temp_result.append( ([],line) )
|
result.append( ([],line) )
|
||||||
elif type(line) in [End, End_provider]:
|
elif type(line) in [End, End_provider]:
|
||||||
temp_result.append( ([],line) )
|
result.append( ([],line) )
|
||||||
varlist = []
|
varlist = []
|
||||||
elif isinstance(line,Provide):
|
elif isinstance(line,Provide):
|
||||||
l = line.text.split()[1:]
|
l = line.text.split()[1:]
|
||||||
varlist += l
|
varlist += l
|
||||||
temp_result.append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
result.append( (l,Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
elif isinstance(line,Call):
|
elif isinstance(line,Call):
|
||||||
sub = find_subroutine_in_line(line)
|
sub = find_subroutine_in_line(line)
|
||||||
if subroutines[sub].touches == []:
|
if sub not in subroutines:
|
||||||
t = Simple_line
|
t = Simple_line
|
||||||
else:
|
else:
|
||||||
t = Provide_all
|
if subroutines[sub].touches == []:
|
||||||
temp_result.append( ([],t(line.i,line.text,line.filename)) )
|
t = Simple_line
|
||||||
|
else:
|
||||||
|
t = Provide_all
|
||||||
|
result.append( ([],t(line.i,line.text,line.filename)) )
|
||||||
elif isinstance(line,Free):
|
elif isinstance(line,Free):
|
||||||
vars = line.text.split()
|
vars = line.text.split()
|
||||||
if len(vars) < 2:
|
if len(vars) < 2:
|
||||||
@ -92,13 +90,13 @@ def get_parsed_text():
|
|||||||
vars = vars[1:]
|
vars = vars[1:]
|
||||||
result.append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
result.append( ([],Simple_line(line.i,"!%s"%(line.text),line.filename)) )
|
||||||
for var in vars:
|
for var in vars:
|
||||||
temp_result.append( ([],Simple_line(line.i," call free_%s"%var,
|
result.append( ([],Simple_line(line.i," call free_%s"%var,
|
||||||
line.filename)) )
|
line.filename)) )
|
||||||
elif isinstance(line,Touch):
|
elif isinstance(line,Touch):
|
||||||
vars = line.text.split()
|
vars = line.text.split()
|
||||||
if len(vars) < 2:
|
if len(vars) < 2:
|
||||||
error.fail(line,"Syntax error")
|
error.fail(line,"Syntax error")
|
||||||
vars = vars[1:]
|
vars = map(lower,vars[1:])
|
||||||
def fun(x):
|
def fun(x):
|
||||||
if x not in variables:
|
if x not in variables:
|
||||||
error.fail(line,"Variable %s unknown"%(x,))
|
error.fail(line,"Variable %s unknown"%(x,))
|
||||||
@ -107,31 +105,31 @@ def get_parsed_text():
|
|||||||
main = x
|
main = x
|
||||||
return main
|
return main
|
||||||
main_vars = make_single( map(fun, vars) )
|
main_vars = make_single( map(fun, vars) )
|
||||||
check_touch(vars,main_vars)
|
check_touch(line,vars,main_vars)
|
||||||
txt = " ".join(vars)
|
txt = " ".join(vars)
|
||||||
result = [ ([],Simple_line(line.i,"!",line.filename)),
|
result += [ ([],Simple_line(line.i,"!",line.filename)),
|
||||||
([],Simple_line(line.i,"! >>> TOUCH %s"%(txt,),line.filename)) ]
|
([],Simple_line(line.i,"! >>> TOUCH %s"%(txt,),line.filename)) ]
|
||||||
def fun(x):
|
def fun(x):
|
||||||
if x not in variables:
|
if x not in variables:
|
||||||
error.fail(line,"Variable %s unknown"%(x,))
|
error.fail(line,"Variable %s unknown"%(x,))
|
||||||
return [ ([],Simple_line(line.i," call touch_%s"%(x,),line.filename)),
|
return [ ([],Simple_line(line.i," call touch_%s"%(x,),line.filename)),
|
||||||
([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename)) ]
|
([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename)) ]
|
||||||
result += map( fun, main_vars )
|
result += flatten(map( fun, main_vars ))
|
||||||
def fun(x):
|
def fun(x):
|
||||||
if x not in variables:
|
if x not in variables:
|
||||||
error.fail(line,"Variable %s unknown"%(x,))
|
error.fail(line,"Variable %s unknown"%(x,))
|
||||||
return [ ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename)) ]
|
return ([],Simple_line(line.i," %s_is_built = .True."%(x,),line.filename))
|
||||||
result += map( fun, main_vars )
|
result += map( fun, main_vars[:-1] )
|
||||||
result += [ ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) ]
|
result += [ ([],Provide_all(line.i,"! <<< END TOUCH",line.filename)) ]
|
||||||
else:
|
else:
|
||||||
l = find_variables_in_line(line)
|
l = find_variables_in_line(line)
|
||||||
varlist += l
|
varlist += l
|
||||||
temp_result.append( (l,line) )
|
result.append( (l,line) )
|
||||||
result.append( (filename, temp_result) )
|
main_result.append( (filename, result) )
|
||||||
return result
|
return main_result
|
||||||
|
|
||||||
parsed_text = get_parsed_text()
|
parsed_text = get_parsed_text()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for line in parsed_text[0][1]:
|
for line in parsed_text[12][1]:
|
||||||
print line
|
print line[1],'!',line[0]
|
||||||
|
@ -663,7 +663,7 @@ def remove_ifdefs(text):
|
|||||||
######################################################################
|
######################################################################
|
||||||
def move_to_top(text,t):
|
def move_to_top(text,t):
|
||||||
assert isinstance(text,list)
|
assert isinstance(text,list)
|
||||||
assert t in [ Declaration, Implicit, Use ]
|
assert t in [ Declaration, Implicit, Use, Cont_provider ]
|
||||||
|
|
||||||
begin = -1
|
begin = -1
|
||||||
for i in range(len(text)):
|
for i in range(len(text)):
|
||||||
@ -695,6 +695,7 @@ def create_preprocessed_text(filename):
|
|||||||
result = move_to_top(result,Declaration)
|
result = move_to_top(result,Declaration)
|
||||||
result = move_to_top(result,Implicit)
|
result = move_to_top(result,Implicit)
|
||||||
result = move_to_top(result,Use)
|
result = move_to_top(result,Use)
|
||||||
|
result = move_to_top(result,Cont_provider)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
@ -47,7 +47,8 @@ class Sub(object):
|
|||||||
for line in filter(lambda x: isinstance(x,Touch),self.text):
|
for line in filter(lambda x: isinstance(x,Touch),self.text):
|
||||||
self._touches += line.text.split()[1:]
|
self._touches += line.text.split()[1:]
|
||||||
for sub in self.calls:
|
for sub in self.calls:
|
||||||
self._touches += subroutines[sub].touches
|
if sub in subroutines:
|
||||||
|
self._touches += subroutines[sub].touches
|
||||||
self._touches = make_single(self._touches)
|
self._touches = make_single(self._touches)
|
||||||
return self._touches
|
return self._touches
|
||||||
touches = property(touches)
|
touches = property(touches)
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
def strip(x):
|
def strip(x):
|
||||||
return x.strip()
|
return x.strip()
|
||||||
|
|
||||||
|
def lower(x):
|
||||||
|
return x.lower()
|
||||||
|
|
||||||
def same_file(filename,txt):
|
def same_file(filename,txt):
|
||||||
assert isinstance(filename,str)
|
assert isinstance(filename,str)
|
||||||
assert isinstance(txt,list)
|
assert isinstance(txt,list)
|
||||||
|
Loading…
Reference in New Issue
Block a user