def SectionHeaderParser(self, SectionString, FileName, LineNo): _Scope = [] _SectionName = '' ArchList = set() _ValueList = [] _PcdNameList = [ DT.TAB_INF_FIXED_PCD.upper(), DT.TAB_INF_FEATURE_PCD.upper(), DT.TAB_INF_PATCH_PCD.upper(), DT.TAB_INF_PCD.upper(), DT.TAB_INF_PCD_EX.upper() ] SectionString = SectionString.strip() for Item in GetSplitValueList(SectionString[1:-1], DT.TAB_COMMA_SPLIT): if Item == '': Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % (""), File=FileName, Line=LineNo, ExtraData=SectionString) ItemList = GetSplitValueList(Item, DT.TAB_SPLIT) # # different section should not mix in one section # Allow different PCD type sections mixed together # if _SectionName.upper() not in _PcdNameList: if _SectionName != '' and _SectionName.upper( ) != ItemList[0].upper(): Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SECTION_NAME_DUPLICATE, File=FileName, Line=LineNo, ExtraData=SectionString) elif _PcdNameList[1] in [_SectionName.upper(), ItemList[0].upper()] and \ (_SectionName.upper()!= ItemList[0].upper()): Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % (""), File=FileName, Line=LineNo, ExtraData=SectionString) _SectionName = ItemList[0] if _SectionName.upper() in gINF_SECTION_DEF: self._SectionType = gINF_SECTION_DEF[_SectionName.upper()] else: self._SectionType = DT.MODEL_UNKNOWN Logger.Error("Parser", FORMAT_INVALID, ST.ERR_INF_PARSER_UNKNOWN_SECTION, File=FileName, Line=LineNo, ExtraData=SectionString) # # Get Arch # Str1, ArchList = GetArch(ItemList, ArchList, FileName, LineNo, SectionString) # # For [Defines] section, do special check. # if ItemList[0].upper() == DT.TAB_COMMON_DEFINES.upper(): if len(ItemList) != 1: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (SectionString), File=FileName, Line=LineNo, ExtraData=SectionString) # # For [UserExtension] section, do special check. # if ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper(): RetValue = ProcessUseExtHeader(ItemList) if not RetValue[0]: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (SectionString), File=FileName, Line=LineNo, ExtraData=SectionString) else: ItemList = RetValue[1] if len(ItemList) == 3: ItemList.append('COMMON') Str1 = ItemList[1] # # For Library classes, need to check module type. # if ItemList[0].upper() == DT.TAB_LIBRARY_CLASSES.upper() and len( ItemList) == 3: if ItemList[2] != '': ModuleTypeList = GetSplitValueList(ItemList[2], DT.TAB_VALUE_SPLIT) for Item in ModuleTypeList: if Item.strip() not in DT.MODULE_LIST: Logger.Error( 'Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID % (Item), File=FileName, Line=LineNo, ExtraData=SectionString) # # GetSpecialStr2 # Str2 = GetSpecialStr2(ItemList, FileName, LineNo, SectionString) _Scope.append([Str1, Str2]) _NewValueList = [] _AppendFlag = True if _SectionName.upper() in _PcdNameList: for ValueItem in _ValueList: if _SectionName.upper() == ValueItem[0].upper( ) and Str1.upper() not in ValueItem[1].split(): ValueItem[1] = ValueItem[1] + " " + Str1 _AppendFlag = False elif _SectionName.upper() == ValueItem[0].upper( ) and Str1.upper() in ValueItem[1].split(): _AppendFlag = False _NewValueList.append(ValueItem) _ValueList = _NewValueList if _AppendFlag: if not ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper(): _ValueList.append([_SectionName, Str1, Str2, LineNo]) else: if len(ItemList) == 4: _ValueList.append( [_SectionName, Str1, Str2, ItemList[3], LineNo]) self.SectionHeaderContent = deepcopy(_ValueList)
def SectionHeaderParser(self, SectionString, FileName, LineNo): _Scope = [] _SectionName = '' ArchList = set() _ValueList = [] _PcdNameList = [DT.TAB_INF_FIXED_PCD.upper(), DT.TAB_INF_FEATURE_PCD.upper(), DT.TAB_INF_PATCH_PCD.upper(), DT.TAB_INF_PCD.upper(), DT.TAB_INF_PCD_EX.upper() ] SectionString = SectionString.strip() for Item in GetSplitValueList(SectionString[1:-1], DT.TAB_COMMA_SPLIT): if Item == '': Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % (""), File=FileName, Line=LineNo, ExtraData=SectionString) ItemList = GetSplitValueList(Item, DT.TAB_SPLIT) # # different section should not mix in one section # Allow different PCD type sections mixed together # if _SectionName.upper() not in _PcdNameList: if _SectionName != '' and _SectionName.upper() != ItemList[0].upper(): Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SECTION_NAME_DUPLICATE, File=FileName, Line=LineNo, ExtraData=SectionString) elif _PcdNameList[1] in [_SectionName.upper(), ItemList[0].upper()] and \ (_SectionName.upper()!= ItemList[0].upper()): Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % (""), File=FileName, Line=LineNo, ExtraData=SectionString) _SectionName = ItemList[0] if _SectionName.upper() in gINF_SECTION_DEF: self._SectionType = gINF_SECTION_DEF[_SectionName.upper()] else: self._SectionType = DT.MODEL_UNKNOWN Logger.Error("Parser", FORMAT_INVALID, ST.ERR_INF_PARSER_UNKNOWN_SECTION, File=FileName, Line=LineNo, ExtraData=SectionString) # # Get Arch # Str1, ArchList = GetArch(ItemList, ArchList, FileName, LineNo, SectionString) # # For [Defines] section, do special check. # if ItemList[0].upper() == DT.TAB_COMMON_DEFINES.upper(): if len(ItemList) != 1: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (SectionString), File=FileName, Line=LineNo, ExtraData=SectionString) # # For [UserExtension] section, do special check. # if ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper(): RetValue = ProcessUseExtHeader(ItemList) if not RetValue[0]: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (SectionString), File=FileName, Line=LineNo, ExtraData=SectionString) else: ItemList = RetValue[1] if len(ItemList) == 3: ItemList.append('COMMON') Str1 = ItemList[1] # # For Library classes, need to check module type. # if ItemList[0].upper() == DT.TAB_LIBRARY_CLASSES.upper() and len(ItemList) == 3: if ItemList[2] != '': ModuleTypeList = GetSplitValueList(ItemList[2], DT.TAB_VALUE_SPLIT) for Item in ModuleTypeList: if Item.strip() not in DT.MODULE_LIST: Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID % (Item), File=FileName, Line=LineNo, ExtraData=SectionString) # # GetSpecialStr2 # Str2 = GetSpecialStr2(ItemList, FileName, LineNo, SectionString) _Scope.append([Str1, Str2]) _NewValueList = [] _AppendFlag = True if _SectionName.upper() in _PcdNameList: for ValueItem in _ValueList: if _SectionName.upper() == ValueItem[0].upper() and Str1.upper() not in ValueItem[1].split(): ValueItem[1] = ValueItem[1] + " " + Str1 _AppendFlag = False elif _SectionName.upper() == ValueItem[0].upper() and Str1.upper() in ValueItem[1].split(): _AppendFlag = False _NewValueList.append(ValueItem) _ValueList = _NewValueList if _AppendFlag: if not ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper(): _ValueList.append([_SectionName, Str1, Str2, LineNo]) else: if len(ItemList) == 4: _ValueList.append([_SectionName, Str1, Str2, ItemList[3], LineNo]) self.SectionHeaderContent = deepcopy(_ValueList)