@@ -986,7 +986,7 @@ private static Dictionary<string, HardwareRegisterSet> ProcessRegisterSetTypes(s
986986 dict_type_sizes [ "uint16_t" ] = 16 ;
987987 dict_type_sizes [ "uint8_t" ] = 8 ;
988988
989- Regex struct_regex = new Regex ( @"typedef struct[ \t]*\r\n\{[ \t]*\r\n([^}]*)\r\n\}[ \t\r\n]*([A-Za-z0-9_]*)_(Global)?TypeDef;" ) ;
989+ Regex struct_regex = new Regex ( @"typedef struct[ \t]*\r? \n\{[ \t]*\r? \n([^}]*)\r? \n\}[ \t\r? \n]*([A-Za-z0-9_]*)_(Global)?TypeDef;" ) ;
990990
991991 var structs = struct_regex . Matches ( file ) ;
992992 foreach ( Match strct in structs )
@@ -995,7 +995,7 @@ private static Dictionary<string, HardwareRegisterSet> ProcessRegisterSetTypes(s
995995 int set_size = 0 ;
996996
997997 RegexOptions option = RegexOptions . IgnoreCase ;
998- Regex register_regex = new Regex ( @"[ \t]*(__IO|__I)*[ ]*(?:const )*[ ]*([^ #\r\n]*)[ ]*(?:const )*([^\[;#\r\n]*)[\[]?([0-9xXa-fA-F]+)*[\]]?;[ ]*(/\*)*(!<)*[ ]?([^,*\r\n]*)[,]?[ ]*(Ad[d]?ress)*( offset:)*[ ]*([0-9xXa-fA-F]*)[ ]?[-]?[ ]?([^ *\r\n]*)[ ]*(\*/)*[ ]*(\r\n)*" , option ) ;
998+ Regex register_regex = new Regex ( @"[ \t]*(__IO|__I)*[ ]*(?:const )*[ ]*([^ #\r? \n]*)[ ]*(?:const )*([^\[;#\r? \n]*)[\[]?([0-9xXa-fA-F]+)*[\]]?;[ ]*(/\*)*(!<)*[ ]?([^,*\r? \n]*)[,]?[ ]*(Ad[d]?ress)*( offset:)*[ ]*([0-9xXa-fA-F]*)[ ]?[-]?[ ]?([^ *\r? \n]*)[ ]*(\*/)*[ ]*(\r? \n)*" , option ) ;
999999
10001000 var regs = register_regex . Matches ( strct . Groups [ 1 ] . Value ) ;
10011001
@@ -1099,8 +1099,10 @@ private static Dictionary<string, KeyValuePair<string, string>> ProcessRegisterS
10991099 {
11001100 Dictionary < string , KeyValuePair < string , string > > names = new Dictionary < string , KeyValuePair < string , string > > ( ) ;
11011101
1102- Regex periph_decl_begin_regex = new Regex ( @"/\*\* \@addtogroup Peripheral_declaration\r\n(.*)\r\n(.*)" ) ;
1102+ Regex periph_decl_begin_regex = new Regex ( @"/\*\* \@addtogroup Peripheral_declaration\r? \n(.*)\r? \n(.*)" ) ;
11031103 var m_begin = periph_decl_begin_regex . Match ( file ) ;
1104+ if ( ! m_begin . Success )
1105+ throw new Exception ( "Failed to locate peripheral declaration group" ) ;
11041106
11051107 string [ ] lines = file . Substring ( m_begin . Index + m_begin . Groups [ 0 ] . Length ) . Split ( new char [ ] { '\n ' } , StringSplitOptions . RemoveEmptyEntries ) ;
11061108 Regex periph_def_regex = new Regex ( @"#define[ ]+([a-zA-Z0-9_]*)[ ]+\(\(([a-zA-Z0-9_]*)_(|Global)TypeDef[ ]+\*\)[ ]*(.+)\)" ) ;
@@ -1168,7 +1170,7 @@ private static Dictionary<string, ulong> ProcessRegisterSetAddresses(string fn,
11681170 Dictionary < string , ulong > addresses = new Dictionary < string , ulong > ( ) ;
11691171
11701172 Regex memory_map_begin_regex = new Regex ( @"/\*\* \@addtogroup Peripheral_memory_map[\r]?\n(.*)[\r]?\n(.*)" ) ;
1171- Regex memory_map_begin_regex2 = new Regex ( @"/\*\* \r\n \* \@brief Peripheral_memory_map" ) ;
1173+ Regex memory_map_begin_regex2 = new Regex ( @"/\*\* \r? \n \* \@brief Peripheral_memory_map" ) ;
11721174 Regex rgComment = new Regex ( @"^[ \t]*/\*[^/]+\*/[ \t]*$" ) ;
11731175 var m_begin = memory_map_begin_regex . Match ( file ) ;
11741176 if ( ! m_begin . Success )
@@ -1671,6 +1673,14 @@ public static string FormatToHex(ulong addr, int length = 32)
16711673 return string . Format ( format , ( uint ) addr ) ;
16721674 }
16731675
1676+ public class BitmaskNotSequentialException : Exception
1677+ {
1678+ public BitmaskNotSequentialException ( )
1679+ : base ( )
1680+ {
1681+ }
1682+ }
1683+
16741684 private static void ExtractFirstBitAndSize ( ulong val , out int size , out int firstBit )
16751685 {
16761686 size = 0 ;
@@ -1683,7 +1693,7 @@ private static void ExtractFirstBitAndSize(ulong val, out int size, out int firs
16831693 if ( state == 0 )
16841694 state = 1 ;
16851695 else if ( state == 2 )
1686- throw new Exception ( "Hit a second 1 region inside subregister bit mask!" ) ;
1696+ throw new BitmaskNotSequentialException ( ) ;
16871697
16881698 size ++ ;
16891699 if ( firstBit < 0 )
0 commit comments