Make the regexp smarter
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 20 Jan 2009 16:23:07 +0000 (16:23 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 20 Jan 2009 16:23:07 +0000 (16:23 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2188 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py

index dfcaf68f73777f268f0887199f1d87d64c5354b7..593bb4627ca39a42306ffa8ef5a93a8419cbcd49 100644 (file)
@@ -96,11 +96,11 @@ def getInfos(definition):
 
 def getDefinitionBlocks(text):
     block = []
-    block_tmp = re.findall(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/\s*#define\s+([^/]*?/[^/]*?)\s*?(?!/{3}<.*?)$", text, re.MULTILINE)
+    block_tmp = re.findall(r"/\*{2}\s*([^*]*\*(?:[^/*][^*]*\*+)*)/\s*#define\s+((?:[^/]*?/?)+)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE)
     for comment, define in block_tmp:
-        block.append((" ".join(re.findall(r"^\s*\*?\s*(.*?)\s*?$", comment, re.MULTILINE)), define))
-    block += re.findall(r"/{3}<?\s*(.*)\s*#define\s+([^/]*?/[^/]*?)\s*?$", text, re.MULTILINE)
-    block += [(comment, define) for define, comment in re.findall(r"#define\s*(.*?)\s*/{3}<\s*(.*?)\s*?$", text, re.MULTILINE)]
+        block.append((" ".join(re.findall(r"^\s*\*?\s*(.*?)\s*?(?:/{2}.*?)?$", comment, re.MULTILINE)).strip(), define))
+    block += re.findall(r"/{3}\s*([^<].*?)\s*#define\s+((?:[^/]*?/?)+)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE)
+    block += [(comment, define) for define, comment in re.findall(r"#define\s*(.*?)\s*/{3}<\s*(.+?)\s*?(?:/{2,3}[^<].*?)?$", text, re.MULTILINE)]
     return block
 
 def loadModuleInfos(path):