travellhyne / f2py

Automatically exported from code.google.com/p/f2py
Other
0 stars 0 forks source link

[patch] Fix some regular expressions #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This patch fixes assignments to variables named "type" or "entry" for which 
were misinterpreted as TypeDecl constructs and Entry statements, by adding a 
negative lookahead for "=" to the regexps, and corrects a typo in 
ForallConstruct ("forar" -> "forall)

diff -r 9958619dab6a -r c5b88e996b11 fparser/block_statements.py
--- a/fparser/block_statements.py       Fri Jan 27 14:15:00 2012 +0000
+++ b/fparser/block_statements.py       Fri Jan 27 14:26:10 2012 +0000
@@ -842,7 +842,7 @@
     <forall-assignment-stmt> = <assignment-stmt> | <pointer-assignment-stmt>
     """
     end_stmt_cls = EndForall
-    match = re.compile(r'forarr\s*\(.*\)\Z',re.I).match
+    match = re.compile(r'forall\s*\(.*\)\Z',re.I).match
     name = ''
     def process_item(self):
         self.specs = self.item.get_line()[6:].lstrip()[1:-1].strip()
@@ -1035,7 +1035,7 @@
     <type-attr-spec> = <access-spec> | EXTENDS ( <parent-type-name> )
                        | ABSTRACT | BIND(C)
     """
-    match = re.compile(r'type\b\s*').match
+    match = re.compile(r'type\b(?!\s*=)').match
     end_stmt_cls = EndType

     a = AttributeHolder(extends = None,
diff -r 9958619dab6a -r c5b88e996b11 fparser/statements.py
--- a/fparser/statements.py     Fri Jan 27 14:15:00 2012 +0000
+++ b/fparser/statements.py     Fri Jan 27 14:26:10 2012 +0000
@@ -1364,7 +1364,7 @@
     <language-binding-spec> = BIND ( C [ , NAME = <scalar-char-initialization-expr> ] )
     <dummy-arg> = <dummy-arg-name> | *
     """
-    match = re.compile(r'entry\b', re.I).match
+    match = re.compile(r'entry\b(?!\s*[%=])', re.I).match
     def process_item(self):
         line = self.item.get_line()[5:].lstrip()
         m = re.match(r'\w+', line)

Original issue reported on code.google.com by james.ke...@gmail.com on 27 Jan 2012 at 2:39