Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Fix some regular expressions #34

Open
GoogleCodeExporter opened this issue Aug 5, 2015 · 0 comments
Open

[patch] Fix some regular expressions #34

GoogleCodeExporter opened this issue Aug 5, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 27 Jan 2012 at 2:39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant