10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-11-09 07:33:43 +01:00

Merge branch 'master' of ssh://git.code.sf.net/p/irpf90/code

This commit is contained in:
Anthony Scemama 2014-04-25 17:21:28 +02:00
commit 2aa209dd6b
2 changed files with 26 additions and 14 deletions

View File

@ -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
@ -117,7 +117,7 @@ def update_variables():
variables[line.filename]._is_written = True
################################################################################
def get_parsed_text():
def func(filename, text):
varlist = []
@ -143,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:
@ -242,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()
@ -320,7 +320,7 @@ def add_subroutine_needs():
append( (vars,line) )
main_result.append( (filename, result) )
return main_result
parsed_text = add_subroutine_needs()
######################################################################
@ -385,7 +385,7 @@ def move_variables():
error.fail(line,"Unable to parse file")
result.reverse()
# 2nd pass
text = result
result = []
@ -457,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
@ -471,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:
@ -533,7 +533,7 @@ def perform_loop_substitutions():
append( (vars,line) )
main_result.append( (filename, result) )
return main_result
parsed_text = perform_loop_substitutions()
######################################################################

View File

@ -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