# This file is used to parse meta files\r
#\r
# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
+# (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import re\r
import time\r
TAB_ELSE.upper() : MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE,\r
TAB_END_IF.upper() : MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF,\r
TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION,\r
+ TAB_ERROR.upper() : MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR,\r
}\r
\r
# Valid names in define section\r
Scope = [[TAB_COMMON, TAB_COMMON, TAB_COMMON]]\r
if ItemType == MODEL_META_DATA_INCLUDE:\r
Scope = self._Scope\r
+ elif ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR:\r
+ Scope = self._Scope\r
if ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF:\r
# Remove all directives between !if and !endif, including themselves\r
while self._DirectiveStack:\r
EdkLogger.error("Parser", FORMAT_INVALID, "Redundant '!endif'",\r
File=self.MetaFile, Line=self._LineIndex + 1,\r
ExtraData=self._CurrentLine)\r
- elif ItemType != MODEL_META_DATA_INCLUDE:\r
+ elif ItemType not in {MODEL_META_DATA_INCLUDE, MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR}:\r
# Break if there's a !else is followed by a !elseif\r
if ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF and \\r
self._DirectiveStack and \\r
MODEL_META_DATA_BUILD_OPTION : self.__ProcessBuildOption,\r
MODEL_UNKNOWN : self._Skip,\r
MODEL_META_DATA_USER_EXTENSION : self._SkipUserExtension,\r
+ MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR : self._ProcessError,\r
}\r
\r
self._Table = MetaFileStorage(self._RawTable.Cur, self.MetaFile, MODEL_FILE_DSC, True)\r
self._InSubsection = False\r
try:\r
Processer[self._ItemType]()\r
- except EvaluationException, Excpt:\r
+ except EvaluationException as Excpt:\r
# \r
# Only catch expression evaluation error here. We need to report\r
# the precise number of line on which the error occurred\r
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),\r
File=self._FileWithError, ExtraData=' '.join(self._ValueList),\r
Line=self._LineIndex + 1)\r
- except MacroException, Excpt:\r
+ except MacroException as Excpt:\r
EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),\r
File=self._FileWithError, ExtraData=' '.join(self._ValueList),\r
Line=self._LineIndex + 1)\r
GlobalData.gPlatformDefines.update(self._FileLocalMacros)\r
self._PostProcessed = True\r
self._Content = None\r
+ def _ProcessError(self):\r
+ if not self._Enabled:\r
+ return\r
+ EdkLogger.error('Parser', ERROR_STATEMENT, self._ValueList[1], File=self.MetaFile, Line=self._LineIndex + 1)\r
\r
def __ProcessSectionHeader(self):\r
self._SectionName = self._ValueList[0]\r
Macros.update(GlobalData.gGlobalDefines)\r
try:\r
Result = ValueExpression(self._ValueList[1], Macros)()\r
- except SymbolNotFound, Exc:\r
+ except SymbolNotFound as Exc:\r
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1])\r
Result = False\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
\r
self.IncludedFiles.add (IncludedFile1)\r
\r
- # Does not allow lower level included file to include upper level included file\r
- if Parser._From != Owner and int(Owner) > int (Parser._From):\r
- EdkLogger.error('parser', FILE_ALREADY_EXIST, File=self._FileWithError,\r
- Line=self._LineIndex + 1, ExtraData="{0} is already included at a higher level.".format(IncludedFile1))\r
-\r
-\r
# set the parser status with current status\r
Parser._SectionName = self._SectionName\r
if self._InSubsection:\r
\r
# update current status with sub-parser's status\r
self._SectionName = Parser._SectionName\r
- self._SectionType = Parser._SectionType\r
+ if not self._InSubsection:\r
+ self._SectionType = Parser._SectionType\r
+ self._SubsectionType = Parser._SubsectionType\r
+ self._InSubsection = Parser._InSubsection\r
+\r
self._Scope = Parser._Scope\r
self._Enabled = Parser._Enabled\r
\r
if PcdValue and "." not in self._ValueList[0]:\r
try:\r
ValList[Index] = ValueExpression(PcdValue, self._Macros)(True)\r
- except WrnExpression, Value:\r
+ except WrnExpression as Value:\r
ValList[Index] = Value.result\r
except:\r
pass\r
try:\r
self._ValueList[2] = '|'.join(ValList)\r
except Exception:\r
- print ValList\r
+ print(ValList)\r
\r
def __ProcessComponent(self):\r
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)\r
try:\r
self._GuidDict.update(self._AllPcdDict)\r
ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True)\r
- except BadExpression, Value:\r
+ except BadExpression as Value:\r
EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
# check format of default value against the datum type\r
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])\r