##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import re\r
\r
import Fd\r
from Common.BuildToolError import *\r
from Common import EdkLogger\r
from Common.Misc import PathClass\r
-from Common.String import NormPath\r
+from Common.StringUtils import NormPath\r
import Common.GlobalData as GlobalData\r
from Common.Expression import *\r
from Common import GlobalData\r
from Common.DataType import *\r
-from Common.String import ReplaceMacro\r
+from Common.StringUtils import ReplaceMacro\r
import uuid\r
from Common.Misc import tdict\r
from Common.MultipleWorkspace import MultipleWorkspace as mws\r
return MacroDict\r
\r
def __EvaluateConditional(self, Expression, Line, Op = None, Value = None):\r
- FileLineTuple = GetRealFileLine(self.FileName, Line)\r
MacroPcdDict = self.__CollectMacroPcd()\r
if Op == 'eval':\r
try:\r
return ValueExpression(Expression, MacroPcdDict)(True)\r
else:\r
return ValueExpression(Expression, MacroPcdDict)()\r
- except WrnExpression, Excpt:\r
+ except WrnExpression as Excpt:\r
# \r
# Catch expression evaluation warning here. We need to report\r
# the precise number of line and return the evaluation result\r
File=self.FileName, ExtraData=self.__CurrentLine(), \r
Line=Line)\r
return Excpt.result\r
- except Exception, Excpt:\r
+ except Exception as Excpt:\r
if hasattr(Excpt, 'Pcd'):\r
if Excpt.Pcd in GlobalData.gPlatformOtherPcds:\r
Info = GlobalData.gPlatformOtherPcds[Excpt.Pcd]\r
" it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"\r
" of the DSC file (%s), and it is currently defined in this section:"\r
" %s, line #: %d." % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE'], Info[0], Info[1]),\r
- *FileLineTuple)\r
+ self.FileName, Line)\r
else:\r
raise Warning("PCD (%s) is not defined in DSC file (%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']),\r
- *FileLineTuple)\r
+ self.FileName, Line)\r
else:\r
- raise Warning(str(Excpt), *FileLineTuple)\r
+ raise Warning(str(Excpt), self.FileName, Line)\r
else:\r
if Expression.startswith('$(') and Expression[-1] == ')':\r
Expression = Expression[2:-1] \r
\r
try:\r
self.Preprocess()\r
+ self.__GetError()\r
#\r
# Keep processing sections of the FDF until no new sections or a syntax error is found\r
#\r
while self.__GetFd() or self.__GetFv() or self.__GetFmp() or self.__GetCapsule() or self.__GetVtf() or self.__GetRule() or self.__GetOptionRom():\r
pass\r
\r
- except Warning, X:\r
+ except Warning as X:\r
self.__UndoToken()\r
#'\n\tGot Token: \"%s\" from File %s\n' % (self.__Token, FileLineTuple[0]) + \\r
# At this point, the closest parent would be the included file itself\r
\r
return False\r
\r
+ ##__GetError() method\r
+ def __GetError(self):\r
+ #save the Current information\r
+ CurrentLine = self.CurrentLineNumber\r
+ CurrentOffset = self.CurrentOffsetWithinLine\r
+ while self.__GetNextToken():\r
+ if self.__Token == TAB_ERROR:\r
+ EdkLogger.error('FdfParser', ERROR_STATEMENT, self.__CurrentLine().replace(TAB_ERROR, '', 1), File=self.FileName, Line=self.CurrentLineNumber)\r
+ self.CurrentLineNumber = CurrentLine\r
+ self.CurrentOffsetWithinLine = CurrentOffset\r
+\r
## __GetFd() method\r
#\r
# Get FD section contents and store its data into FD dictionary of self.Profile\r
if not self.__GetNextHexNumber() and not self.__GetNextDecimalNumber():\r
raise Warning("expected Hex FV extension entry type value At Line ", self.FileName, self.CurrentLineNumber)\r
\r
- FvObj.FvExtEntryTypeValue += [self.__Token]\r
+ FvObj.FvExtEntryTypeValue.append(self.__Token)\r
\r
if not self.__IsToken( "{"):\r
raise Warning("expected '{'", self.FileName, self.CurrentLineNumber)\r
if not self.__IsKeyword ("FILE") and not self.__IsKeyword ("DATA"):\r
raise Warning("expected 'FILE' or 'DATA'", self.FileName, self.CurrentLineNumber)\r
\r
- FvObj.FvExtEntryType += [self.__Token]\r
+ FvObj.FvExtEntryType.append(self.__Token)\r
\r
if self.__Token == 'DATA':\r
\r
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)\r
\r
DataString = DataString.rstrip(",")\r
- FvObj.FvExtEntryData += [DataString]\r
+ FvObj.FvExtEntryData.append(DataString)\r
\r
if self.__Token == 'FILE':\r
\r
if not self.__GetNextToken():\r
raise Warning("expected FV Extension Entry file path At Line ", self.FileName, self.CurrentLineNumber)\r
\r
- FvObj.FvExtEntryData += [self.__Token]\r
+ FvObj.FvExtEntryData.append(self.__Token)\r
\r
if not self.__IsToken( "}"):\r
raise Warning("expected '}'", self.FileName, self.CurrentLineNumber)\r
import sys\r
try:\r
test_file = sys.argv[1]\r
- except IndexError, v:\r
- print "Usage: %s filename" % sys.argv[0]\r
+ except IndexError as v:\r
+ print("Usage: %s filename" % sys.argv[0])\r
sys.exit(1)\r
\r
parser = FdfParser(test_file)\r
try:\r
parser.ParseFile()\r
parser.CycleReferenceCheck()\r
- except Warning, X:\r
- print str(X)\r
+ except Warning as X:\r
+ print(str(X))\r
else:\r
- print "Success!"\r
+ print("Success!")\r
\r