From d5d56f1bc5e7bcebd08ad55e940fb907ea0af365 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Thu, 4 Mar 2010 05:29:52 +0000 Subject: Sync EDKII BaseTools to BaseTools project r1911. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10177 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/Python/Common/FdfParserLite.py | 37 +++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'BaseTools/Source/Python/Common') diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py index e9b69ff1b9..eb7b0d7514 100644 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ b/BaseTools/Source/Python/Common/FdfParserLite.py @@ -1,7 +1,7 @@ ## @file # parse FDF file # -# Copyright (c) 2007, Intel Corporation +# Copyright (c) 2007 - 2010, Intel Corporation # # All rights reserved. This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -383,7 +383,22 @@ class FdfParser(object): while Offset <= EndPos[1]: self.Profile.FileLinesList[EndPos[0]][Offset] = Value Offset += 1 - + + + def __GetMacroName(self): + if not self.__GetNextToken(): + raise Warning("expected Macro name", self.FileName, self.CurrentLineNumber) + MacroName = self.__Token + NotFlag = False + if MacroName.startswith('!'): + NotFlag = True + MacroName = MacroName[1:].strip() + + if not MacroName.startswith('$(') or not MacroName.endswith(')'): + raise Warning("Macro name expected(Please use '$(%(Token)s)' if '%(Token)s' is a macro.)" % {"Token" : MacroName}, + self.FileName, self.CurrentLineNumber) + MacroName = MacroName[2:-1] + return MacroName, NotFlag ## PreprocessFile() method # @@ -554,14 +569,7 @@ class FdfParser(object): IfList.append([IfStartPos, None, None]) CondLabel = self.__Token - if not self.__GetNextToken(): - raise Warning("expected Macro name At Line ", self.FileName, self.CurrentLineNumber) - MacroName = self.__Token - NotFlag = False - if MacroName.startswith('!'): - NotFlag = True - MacroName = MacroName[1:] - + MacroName, NotFlag = self.__GetMacroName() NotDefineFlag = False if CondLabel == '!ifndef': NotDefineFlag = True @@ -615,14 +623,7 @@ class FdfParser(object): self.__WipeOffArea.append((IfList[-1][0], ElseStartPos)) IfList[-1] = [ElseStartPos, True, IfList[-1][2]] if self.__Token == '!elseif': - if not self.__GetNextToken(): - raise Warning("expected Macro name At Line ", self.FileName, self.CurrentLineNumber) - MacroName = self.__Token - NotFlag = False - if MacroName.startswith('!'): - NotFlag = True - MacroName = MacroName[1:] - + MacroName, NotFlag = self.__GetMacroName() if not self.__GetNextOp(): raise Warning("expected !endif At Line ", self.FileName, self.CurrentLineNumber) -- cgit v1.2.3