@@ -88,9 +88,14 @@ def __repr__(self):
8888 return '<Structure {name} +compiled>'
8989"""
9090
91- COMMENT_REGEX_START = r'(\n?[ ]*\/\/[^\n]*\n)*[ ]*(?P<commentBlock>/\*[^*]*\*+(?:[^/*][^*]*\*+)*/)?[ \t\r\n]*'
92- COMMENT_REGEX_END = r'[ ]*(?P<commentBlockAfter>\/\*(\*(?!\/)|[^*])*\*\/)?(\n?[ ]*\/\/[^\n]*\n*)*'
91+ COMMENT_MULTILINE = r'/\*[^*]*\*+(?:[^/*][^*]*\*+)*/'
92+ COMMENT_INLINE = r'//[^\n]*'
93+ COMMENT_MULTILINE_REPEATED = r'(^[ ]*(' + COMMENT_INLINE + r'|' + COMMENT_MULTILINE + r'([ ]*(' + COMMENT_INLINE + r'|' + COMMENT_MULTILINE + r'))*)[ \t\r]*\n?)*^[ ]*(' + COMMENT_INLINE + r'|(?P<commentBlock>' + COMMENT_MULTILINE + r'))+'
94+ COMMENT_REGEX_START = r'(' + COMMENT_MULTILINE_REPEATED + r')?[ \t\r\n]*'
95+ COMMENT_REGEX_END = r'(?P<commentBlockAfter>(([ ]*' + COMMENT_MULTILINE + r')+)?[ ]*(' + COMMENT_INLINE + r')?)?[ \t\r]*'
9396
97+ #print(f"COMMENT_REGEX_START:{COMMENT_REGEX_START}")
98+ #print(f"COMMENT_REGEX_END:{COMMENT_REGEX_END}")
9499
95100class Error (Exception ):
96101 pass
@@ -337,7 +342,7 @@ def _constants(self, data):
337342 def _enums (self , data ):
338343 r = re .finditer (
339344 COMMENT_REGEX_START + r'enum\s+(?P<name>[^\s:{]+)\s*(:\s*(?P<type>[^\s]+)\s*)?\{(?P<values>[^}]+)\}\s*;' + COMMENT_REGEX_END ,
340- data ,
345+ data , re . MULTILINE
341346 )
342347 for t in r :
343348 d = t .groupdict ()
@@ -360,7 +365,7 @@ def _parse_fields_enums(self, s):
360365 valuesDetails = {}
361366 fields = re .finditer (
362367 COMMENT_REGEX_START + r'(?P<value>[a-zA-z][^\n,/]*),?' + COMMENT_REGEX_END ,
363- s ,
368+ s , re . MULTILINE
364369 )
365370
366371 for f in fields :
@@ -387,7 +392,7 @@ def _structs(self, data):
387392 compiler = Compiler (self .cstruct )
388393 r = re .finditer (
389394 COMMENT_REGEX_START + r'(#(?P<flags>(?:compile))\s+)?((?P<typedef>typedef)\s+)?(?P<type>[^\s]+)\s+(__attribute__\(\([^)]+\)\)\s*)?(?P<name>[^\s]+)?(?P<fields>\s*\{(\s*//[^\n]*|/\*[^*]*\*/|[^}])+\}(?P<defs>\s+[^;\n]+)?)?\s*;' + COMMENT_REGEX_END ,
390- data ,
395+ data , re . MULTILINE
391396 )
392397 for t in r :
393398 d = t .groupdict ()
@@ -421,7 +426,7 @@ def _structs(self, data):
421426 def _parse_fields_struct (self , s ):
422427 fields = re .finditer (
423428 COMMENT_REGEX_START + r'(?P<type>[^\s]+)\s+(?P<name>[^\s\[:]+)(\s*:\s*(?P<bits>\d+))?(\[(?P<count>[^;\n]*)\])?;' + COMMENT_REGEX_END ,
424- s ,
429+ s , re . MULTILINE
425430 )
426431 r = []
427432 for f in fields :
0 commit comments