@@ -986,7 +986,7 @@ private static Dictionary<string, HardwareRegisterSet> ProcessRegisterSetTypes(s
986
986
dict_type_sizes [ "uint16_t" ] = 16 ;
987
987
dict_type_sizes [ "uint8_t" ] = 8 ;
988
988
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;" ) ;
990
990
991
991
var structs = struct_regex . Matches ( file ) ;
992
992
foreach ( Match strct in structs )
@@ -995,7 +995,7 @@ private static Dictionary<string, HardwareRegisterSet> ProcessRegisterSetTypes(s
995
995
int set_size = 0 ;
996
996
997
997
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 ) ;
999
999
1000
1000
var regs = register_regex . Matches ( strct . Groups [ 1 ] . Value ) ;
1001
1001
@@ -1099,8 +1099,10 @@ private static Dictionary<string, KeyValuePair<string, string>> ProcessRegisterS
1099
1099
{
1100
1100
Dictionary < string , KeyValuePair < string , string > > names = new Dictionary < string , KeyValuePair < string , string > > ( ) ;
1101
1101
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(.*)" ) ;
1103
1103
var m_begin = periph_decl_begin_regex . Match ( file ) ;
1104
+ if ( ! m_begin . Success )
1105
+ throw new Exception ( "Failed to locate peripheral declaration group" ) ;
1104
1106
1105
1107
string [ ] lines = file . Substring ( m_begin . Index + m_begin . Groups [ 0 ] . Length ) . Split ( new char [ ] { '\n ' } , StringSplitOptions . RemoveEmptyEntries ) ;
1106
1108
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,
1168
1170
Dictionary < string , ulong > addresses = new Dictionary < string , ulong > ( ) ;
1169
1171
1170
1172
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" ) ;
1172
1174
Regex rgComment = new Regex ( @"^[ \t]*/\*[^/]+\*/[ \t]*$" ) ;
1173
1175
var m_begin = memory_map_begin_regex . Match ( file ) ;
1174
1176
if ( ! m_begin . Success )
@@ -1671,6 +1673,14 @@ public static string FormatToHex(ulong addr, int length = 32)
1671
1673
return string . Format ( format , ( uint ) addr ) ;
1672
1674
}
1673
1675
1676
+ public class BitmaskNotSequentialException : Exception
1677
+ {
1678
+ public BitmaskNotSequentialException ( )
1679
+ : base ( )
1680
+ {
1681
+ }
1682
+ }
1683
+
1674
1684
private static void ExtractFirstBitAndSize ( ulong val , out int size , out int firstBit )
1675
1685
{
1676
1686
size = 0 ;
@@ -1683,7 +1693,7 @@ private static void ExtractFirstBitAndSize(ulong val, out int size, out int firs
1683
1693
if ( state == 0 )
1684
1694
state = 1 ;
1685
1695
else if ( state == 2 )
1686
- throw new Exception ( "Hit a second 1 region inside subregister bit mask!" ) ;
1696
+ throw new BitmaskNotSequentialException ( ) ;
1687
1697
1688
1698
size ++ ;
1689
1699
if ( firstBit < 0 )
0 commit comments