From 15a0e1e2c5b56dd460e83ed260196447dcc13831 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 15 May 2012 18:01:27 +0200 Subject: [PATCH] -s option updated --- bin/irpf90 | 43 +--------------------------- packages/Makefile | 2 +- packages/irpf90.list | 62 ---------------------------------------- src/Makefile | 4 +-- src/command_line.py | 2 +- src/parsed_text.py | 6 ++-- src/preprocessed_text.py | 1 - 7 files changed, 8 insertions(+), 112 deletions(-) mode change 100755 => 120000 bin/irpf90 delete mode 100644 packages/irpf90.list diff --git a/bin/irpf90 b/bin/irpf90 deleted file mode 100755 index c135dec..0000000 --- a/bin/irpf90 +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/python -O -# IRPF90 is a Fortran90 preprocessor written in Python for programming using -# the Implicit Reference to Parameters (IRP) method. -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Anthony Scemama -# LCPQ - IRSAMC - CNRS -# Universite Paul Sabatier -# 118, route de Narbonne -# 31062 Toulouse Cedex 4 -# scemama@irsamc.ups-tlse.fr - - -import os -import sys - -wd = os.path.abspath(os.path.dirname(__file__)) -sys.path.insert(0,(wd+"/../src/")) -sys.path.insert(0,(wd+"/../share/irpf90/src/")) - -debug = int(os.getenv("IRP_DEBUG",0)) -if debug == 0: - import irpf90 - irpf90.main() -else: - import profile - print "Profiling irpf90" - profile.run('import irpf90 ; irpf90.main()') diff --git a/bin/irpf90 b/bin/irpf90 new file mode 120000 index 0000000..09358c1 --- /dev/null +++ b/bin/irpf90 @@ -0,0 +1 @@ +/home/scemama/irpf90/src/irpf90.exe \ No newline at end of file diff --git a/packages/Makefile b/packages/Makefile index 70c5a8c..b523cb8 100644 --- a/packages/Makefile +++ b/packages/Makefile @@ -1,7 +1,7 @@ include version default: rm *.rpm *.tar.gz *.exe.gz 2> /dev/null ;\ - VERSION=$(VERSION) epm -a noarch -m noarch irpf90 irpf90.list ;\ + VERSION=$(VERSION) epm -f portable -a noarch -m noarch irpf90 irpf90.list ;\ cd noarch ;\ cp ~/.rpmmacros .;\ echo "%_topdir $$PWD" > ~/.rpmmacros ;\ diff --git a/packages/irpf90.list b/packages/irpf90.list deleted file mode 100644 index 6d39c73..0000000 --- a/packages/irpf90.list +++ /dev/null @@ -1,62 +0,0 @@ -# epm -f format irpf90 irpf90.list -# format: -# aix -# bsd -# depot or swinstall (HP-UX) -# dpkg -# inst or tardist (IRIX -# native (native for the current platform) -# osx -# pkg (Solaris) -# portable (default) -# rpm -# setld (Tru64) -# slackware - -# Product information -# ------------------- - -%product irpf90 -%copyright 2009 A. Scemama, CNRS -%vendor A. Scemama, CNRS -%license ../LICENSE -%readme ../README -%description IRP-Fortran90 preprocessor -%version $VERSION - -%format rpm -%requires python -%requires make - -%format all - -# Autoconfiguration variables -# --------------------------- - -$prefix=/usr -$exec_prefix=/usr -$bindir=${exec_prefix}/bin -$datadir=${exec_prefix}/share/irpf90/src -$vimdir=${exec_prefix}/share/irpf90/vim -$docdir=${prefix}/share/irpf90/doc -$mandir=${prefix}/man -$srcdir=.. - -# Executables -# ----------- - - -%system all -%description IRP-Fortran90 preprocessor -f 0444 root sys ${mandir}/man1/irpf90.1.gz ${srcdir}/man/man1/irpf90.1.gz -f 0444 root sys ${mandir}/man1/irpman.1.gz ${srcdir}/man/man1/irpman.1.gz -f 0444 root sys ${vimdir}/irpf90.vim ${srcdir}/vim/irpf90.vim -f 0555 root sys ${bindir}/irpf90 ${srcdir}/bin/irpf90 -f 0555 root sys ${bindir}/irpman ${srcdir}/bin/irpman -f 0555 root sys ${datadir}/ ${srcdir}/src/*.py -f 0444 root sys ${docdir}/README ${srcdir}/README -f 0444 root sys ${docdir}/LICENSE ${srcdir}/LICENSE - -EOF - - diff --git a/src/Makefile b/src/Makefile index 465e7bc..a6bf542 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,9 +2,9 @@ PYTHON=python PYVERSION=$(shell $(PYTHON) -c "import sys; print(sys.version[:3])") irpf90.exe: irpf90.so - gcc build/*/irpf90.o -L/usr/lib -lpython$(PYVERSION) -o irpf90.exe + gcc build/*/irpf90.o -L/usr/lib64 -lpython$(PYVERSION) -o irpf90.exe -irpf90.so : $(wildcard %.py) irpf90.c +irpf90.so : $(wildcard *.py) irpf90.c ./cython_setup.py build_ext --inplace irpf90.c: irpf90.py diff --git a/src/command_line.py b/src/command_line.py index bae1b02..c0a2d86 100644 --- a/src/command_line.py +++ b/src/command_line.py @@ -81,7 +81,7 @@ class CommandLine(object): for o,a in self.opts: if o in [ "-s", '--'+options['s'][0] ]: k, v = a.split(':') - v_re = re.compile(r"(^.*[,| ]+)(%s)(\s*$)"%k.strip()) + v_re = re.compile(r"(\W)(%s)(\W.*$|$)"%k.strip()) self._substituted[k] = [v, v_re] return self._substituted substituted = property(fget=substituted) diff --git a/src/parsed_text.py b/src/parsed_text.py index b5dae1d..cf17e19 100644 --- a/src/parsed_text.py +++ b/src/parsed_text.py @@ -519,11 +519,11 @@ def perform_loop_substitutions(): result = [] append = result.append for vars,line in text: - if type(line) == Do: + if type(line) in [ Do, If, Elseif] : for k,v in command_line.substituted.items(): reg = v[1] - if reg.search(line.text) is not None: - line.text = re.sub(reg,r'\1%s\3', line.text)%v[0] + while reg.search(line.text) is not None: + line.text = re.sub(reg,r'\1%s\3', line.text,count=1)%v[0] append( (vars,line) ) main_result.append( (filename, result) ) return main_result diff --git a/src/preprocessed_text.py b/src/preprocessed_text.py index 56c7911..d93dac1 100644 --- a/src/preprocessed_text.py +++ b/src/preprocessed_text.py @@ -588,7 +588,6 @@ def irp_simple_statements(text): def process_function(line): assert type(line) == Function - buffer = line.text.split('(') subname = find_subname(line) length = len(subname) i = line.i