VfrCompiler tool is updated.
authorlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 24 Nov 2008 11:52:48 +0000 (11:52 +0000)
committerlgao4 <lgao4@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 24 Nov 2008 11:52:48 +0000 (11:52 +0000)
1. Add Framework package Header for the framework vfr file.
2. Update StatementExpression function to extend OpCode Scope only for the root expression.

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1372 7335b38e-4728-0410-8992-fb3ffe349368

Source/C/VfrCompile/VfrFormPkg.cpp
Source/C/VfrCompile/VfrSyntax.g

index efe797a..3fb865b 100644 (file)
@@ -426,9 +426,21 @@ CFormPkg::GenCFile (
     return Ret;\r
   }\r
 \r
-  fprintf (pFile, "  // ARRAY LENGTH\n");\r
-  PkgLength = PkgHdr->Length + sizeof (UINT32);\r
-  _WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, "  ", (CHAR8 *)&PkgLength, sizeof (UINT32));\r
+  //\r
+  // For framework vfr file, the extension framework header will be added.\r
+  //\r
+  if (VfrCompatibleMode) {\r
+         fprintf (pFile, "  // FRAMEWORK PACKAGE HEADER Length\n");\r
+         PkgLength = PkgHdr->Length + sizeof (UINT32) + 2;\r
+         _WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, "  ", (CHAR8 *)&PkgLength, sizeof (UINT32));   \r
+         fprintf (pFile, "\n\n  // FRAMEWORK PACKAGE HEADER Type\n");\r
+         PkgLength = 3;\r
+         _WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, "  ", (CHAR8 *)&PkgLength, sizeof (UINT16));   \r
+       } else {\r
+         fprintf (pFile, "  // ARRAY LENGTH\n");\r
+         PkgLength = PkgHdr->Length + sizeof (UINT32);\r
+         _WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, "  ", (CHAR8 *)&PkgLength, sizeof (UINT32));   \r
+       }\r
 \r
   fprintf (pFile, "\n\n  // PACKAGE HEADER\n");\r
   _WRITE_PKG_LINE(pFile, BYTES_PRE_LINE, "  ", (CHAR8 *)PkgHdr, sizeof (EFI_HII_PACKAGE_HEADER));\r
index 12083dc..646bc84 100644 (file)
@@ -2295,13 +2295,39 @@ vfrStatementInvalidSaveRestoreDefaults :
 #token QuestionRefVal("questionrefval")         "questionrefval"\r
 #token StringRefVal("stringrefval")             "stringrefval"\r
 \r
+//\r
+// Root expression extension function called by other function.\r
+//\r
 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :\r
-                             << if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>\r
+  << if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>\r
+  andTerm[$RootLevel, $ExpOpCount]\r
+  (\r
+    L:OR andTerm[$RootLevel, $ExpOpCount]              << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>\r
+  )*\r
+                                                       << \r
+                                                          //\r
+                                                          // Extend OpCode Scope only for the root expression.\r
+                                                          // \r
+                                                          if ($ExpOpCount > 1 && $RootLevel == 0) {\r
+                                                            if (_SET_SAVED_OPHDR_SCOPE()) { \r
+                                                              CIfrEnd EObj;\r
+                                                              if (mCIfrOpHdrLineNo != 0) { \r
+                                                                EObj.SetLineNo (mCIfrOpHdrLineNo);\r
+                                                              }\r
+                                                            }\r
+                                                          }\r
+                                                       >>\r
+  ;\r
+\r
+//\r
+// Add new sub function for the sub expression extension to remember the ExpOpCount\r
+// This funciton is only called by sub expression.\r
+//\r
+vfrStatementExpressionSub [UINT32 RootLevel, UINT32 & ExpOpCount] :\r
   andTerm[$RootLevel, $ExpOpCount]\r
   (\r
     L:OR andTerm[$RootLevel, $ExpOpCount]              << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>\r
   )*\r
-                                                       << if ($ExpOpCount > 1) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj;} >>\r
   ;\r
 \r
 andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -2441,24 +2467,24 @@ atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
 vfrExpressionCatenate [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
   L:Catenate\r
   "\("\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrCatenate CObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 vfrExpressionMatch [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
   L:Match\r
   "\("\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrMatch MObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 vfrExpressionParen [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
   "\("\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"\r
   ;\r
 \r
@@ -2475,7 +2501,7 @@ vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :
   ;\r
 \r
 dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
-  L:Dup                                                << { CIfrDup DObj(L->getLine()); _SAVE_OPHDR_COND(DObj, ($ExpOpCount == 0)); $ExpOpCount++; } >>\r
+  L:Dup                                                << { CIfrDup DObj(L->getLine()); _SAVE_OPHDR_COND(DObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -2520,7 +2546,7 @@ vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                        <<\r
                                                           if (Mask == 0) {\r
                                                             CIfrEqIdVal EIVObj (L->getLine());\r
-                                                            _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));\r
+                                                            _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0), L->getLine());\r
                                                             EIVObj.SetQuestionId (QId, VarIdStr, LineNo);\r
                                                             EIVObj.SetValue (ConstVal);\r
                                                             $ExpOpCount++;\r
@@ -2573,7 +2599,7 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                        <<\r
                                                           if (Mask == 0) {\r
                                                             CIfrEqIdVal EIVObj (L->getLine());\r
-                                                            _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));\r
+                                                            _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0), L->getLine());\r
                                                             EIVObj.SetQuestionId (QId, VarIdStr, LineNo);\r
                                                             EIVObj.SetValue (ConstVal);\r
                                                             $ExpOpCount++;\r
@@ -2627,7 +2653,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                   IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], EQUAL);\r
                                 } else {\r
                                   CIfrEqIdId      EIIObj(L->getLine());\r
-                                  _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));\r
+                                  _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0), L->getLine());\r
                                   EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);\r
                                   EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);\r
                                   $ExpOpCount++;\r
@@ -2682,7 +2708,7 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
                                                           } else {\r
                                                             UINT16       Index;\r
                                                             CIfrEqIdList EILObj(L->getLine());\r
-                                                            _SAVE_OPHDR_COND (EILObj, ($ExpOpCount == 0));\r
+                                                            _SAVE_OPHDR_COND (EILObj, ($ExpOpCount == 0), L->getLine());\r
                                                             if (QId != EFI_QUESTION_ID_INVALID) {\r
                                                               EILObj.SetQuestionId (QId, VarIdStr, LineNo);\r
                                                             }\r
@@ -2736,10 +2762,10 @@ questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   )\r
                                                        <<\r
                                                           switch (Type) {\r
-                                                          case 0x1: {CIfrQuestionRef1 QR1Obj(L->getLine()); _SAVE_OPHDR_COND (QR1Obj, ($ExpOpCount == 0)); QR1Obj.SetQuestionId (QId, QName, LineNo); break;}\r
-                                                          case 0x3: {CIfrQuestionRef3 QR3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3Obj, ($ExpOpCount == 0)); break;}\r
-                                                          case 0x4: {CIfrQuestionRef3_2 QR3_2Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_2Obj, ($ExpOpCount == 0)); QR3_2Obj.SetDevicePath (DevPath); break;}\r
-                                                          case 0x5: {CIfrQuestionRef3_3 QR3_3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_3Obj, ($ExpOpCount == 0)); QR3_3Obj.SetDevicePath (DevPath); QR3_3Obj.SetGuid (&Guid); break;}\r
+                                                          case 0x1: {CIfrQuestionRef1 QR1Obj(L->getLine()); _SAVE_OPHDR_COND (QR1Obj, ($ExpOpCount == 0), L->getLine()); QR1Obj.SetQuestionId (QId, QName, LineNo); break;}\r
+                                                          case 0x3: {CIfrQuestionRef3 QR3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3Obj, ($ExpOpCount == 0), L->getLine()); break;}\r
+                                                          case 0x4: {CIfrQuestionRef3_2 QR3_2Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_2Obj, ($ExpOpCount == 0), L->getLine()); QR3_2Obj.SetDevicePath (DevPath); break;}\r
+                                                          case 0x5: {CIfrQuestionRef3_3 QR3_3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_3Obj, ($ExpOpCount == 0), L->getLine()); QR3_3Obj.SetDevicePath (DevPath); QR3_3Obj.SetGuid (&Guid); break;}\r
                                                           }\r
                                                           $ExpOpCount++;\r
                                                        >>\r
@@ -2747,7 +2773,7 @@ questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
 \r
 rulerefExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:RuleRef\r
-  "\(" RN:StringIdentifier "\)"                        << { CIfrRuleRef RRObj(L->getLine()); _SAVE_OPHDR_COND (RRObj, ($ExpOpCount == 0)); RRObj.SetRuleId (mCVfrRulesDB.GetRuleId (RN->getText())); } $ExpOpCount++; >>\r
+  "\(" RN:StringIdentifier "\)"                        << { CIfrRuleRef RRObj(L->getLine()); _SAVE_OPHDR_COND (RRObj, ($ExpOpCount == 0), L->getLine()); RRObj.SetRuleId (mCVfrRulesDB.GetRuleId (RN->getText())); } $ExpOpCount++; >>\r
   ;\r
 \r
 //******************************************************\r
@@ -2756,22 +2782,22 @@ rulerefExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
 //\r
 stringref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:StringRef\r
-  "\(" S:Number "\)"                                   << { CIfrStringRef1 SR1Obj(L->getLine()); _SAVE_OPHDR_COND (SR1Obj, ($ExpOpCount == 0)); SR1Obj.SetStringId (_STOSID(S->getText())); $ExpOpCount++; } >>\r
+  "\(" S:Number "\)"                                   << { CIfrStringRef1 SR1Obj(L->getLine()); _SAVE_OPHDR_COND (SR1Obj, ($ExpOpCount == 0), L->getLine()); SR1Obj.SetStringId (_STOSID(S->getText())); $ExpOpCount++; } >>\r
   ;\r
 \r
 pushthisExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
-  L:PushThis                                           << { CIfrThis TObj(L->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0)); $ExpOpCount++; } >>\r
+  L:PushThis                                           << { CIfrThis TObj(L->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 vfrExpressionConstant[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
-    L1:True                                            << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
-  | L2:False                                           << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
-  | L3:One                                             << CIfrOne OObj(L3->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
-  | L4:Ones                                            << CIfrOnes OObj(L4->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
-  | L5:Zero                                            << CIfrZero ZObj(L5->getLine()); _SAVE_OPHDR_COND (ZObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
-  | L6:Undefined                                       << CIfrUndefined UObj(L6->getLine()); _SAVE_OPHDR_COND (UObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
-  | L7:Version                                         << CIfrVersion VObj(L7->getLine()); _SAVE_OPHDR_COND (VObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
-  | V:Number                                           << CIfrUint64 U64Obj(V->getLine()); U64Obj.SetValue (_STOU64(V->getText())); _SAVE_OPHDR_COND (U64Obj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
+    L1:True                                            << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L1->getLine()); $ExpOpCount++; >>\r
+  | L2:False                                           << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0), L2->getLine()); $ExpOpCount++; >>\r
+  | L3:One                                             << CIfrOne OObj(L3->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0), L3->getLine()); $ExpOpCount++; >>\r
+  | L4:Ones                                            << CIfrOnes OObj(L4->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0), L4->getLine()); $ExpOpCount++; >>\r
+  | L5:Zero                                            << CIfrZero ZObj(L5->getLine()); _SAVE_OPHDR_COND (ZObj, ($ExpOpCount == 0), L5->getLine()); $ExpOpCount++; >>\r
+  | L6:Undefined                                       << CIfrUndefined UObj(L6->getLine()); _SAVE_OPHDR_COND (UObj, ($ExpOpCount == 0), L6->getLine()); $ExpOpCount++; >>\r
+  | L7:Version                                         << CIfrVersion VObj(L7->getLine()); _SAVE_OPHDR_COND (VObj, ($ExpOpCount == 0), L7->getLine()); $ExpOpCount++; >>\r
+  | V:Number                                           << CIfrUint64 U64Obj(V->getLine()); U64Obj.SetValue (_STOU64(V->getText())); _SAVE_OPHDR_COND (U64Obj, ($ExpOpCount == 0), V->getLine()); $ExpOpCount++; >>\r
   ;\r
 \r
 vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
@@ -2787,31 +2813,31 @@ vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
 \r
 lengthExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:Length\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrLength LObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 bitwisenotExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:BitWiseNot\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrBitWiseNot BWNObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 question2refExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:QuestionRefVal\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrQuestionRef2 QR2Obj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 stringref2Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:StringRefVal\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrStringRef2 SR2Obj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 toboolExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:BoolVal\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
@@ -2821,25 +2847,25 @@ tostringExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   {\r
     Format "=" F:Number ","                            << Fmt = _STOU8(F->getText()); >>\r
   }\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrToString TSObj(L->getLine()); TSObj.SetFormat (Fmt); $ExpOpCount++; } >>\r
   ;\r
 \r
 unintExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:UnIntVal\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 toupperExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:ToUpper\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrToUpper TUObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 tolwerExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:ToLower\r
-  "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
+  "\(" vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount] "\)"\r
                                                        << { CIfrToLower TLObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
@@ -2859,11 +2885,11 @@ vfrExpressionTernaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
 \r
 conditionalExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:Cond "\("\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "?"\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ":"\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrConditional CObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
@@ -2872,11 +2898,11 @@ findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   L:Find "\("\r
   findFormat[Format] ( "\|" findFormat[Format] )*\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrFind FObj(L->getLine()); FObj.SetFormat (Format); $ExpOpCount++; } >>\r
   ;\r
 \r
@@ -2887,21 +2913,21 @@ findFormat [UINT8 & Format] :
 \r
 midExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:Mid "\("\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrMid MObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
 tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
   L:Tok "\("\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>\r
   ;\r
 \r
@@ -2910,11 +2936,11 @@ spanExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
   S:Span "\("\r
   FLAGS "=" spanFlags[Flags] ( "\|" spanFlags[Flags] )*\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   ","\r
-  vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
+  vfrStatementExpressionSub[$RootLevel + 1, $ExpOpCount]\r
   "\)"                                                 << { CIfrSpan SObj(S->getLine()); SObj.SetFlags(Flags); $ExpOpCount++; } >>\r
   ;\r
 \r
@@ -2944,9 +2970,10 @@ private:
   CVfrRulesDB         mCVfrRulesDB;\r
 \r
   CIfrOpHeader        *mCIfrOpHdr;\r
-  VOID                _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN);\r
+  UINT32              mCIfrOpHdrLineNo;\r
+  VOID                _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, UINT32 LineNo = 0);\r
   VOID                _CLEAR_SAVED_OPHDR (VOID);\r
-  VOID                _SET_SAVED_OPHDR_SCOPE (VOID);\r
+  BOOLEAN             _SET_SAVED_OPHDR_SCOPE (VOID);\r
 \r
 \r
   EFI_VARSTORE_INFO   mCurrQestVarInfo;\r
@@ -3011,7 +3038,8 @@ public:
 VOID\r
 EfiVfrParser::_SAVE_OPHDR_COND (\r
   IN CIfrOpHeader &OpHdr,\r
-  IN BOOLEAN      Cond\r
+  IN BOOLEAN      Cond,\r
+  IN UINT32       LineNo\r
   )\r
 {\r
   if (Cond == TRUE) {\r
@@ -3024,7 +3052,8 @@ EfiVfrParser::_SAVE_OPHDR_COND (
 #endif\r
       return ;\r
     }\r
-  mCIfrOpHdr = new CIfrOpHeader(OpHdr);\r
+    mCIfrOpHdr       = new CIfrOpHeader(OpHdr);\r
+    mCIfrOpHdrLineNo = LineNo;\r
   }\r
 }\r
 \r
@@ -3036,10 +3065,11 @@ EfiVfrParser::_CLEAR_SAVED_OPHDR (
 #if 0\r
   printf ("######_CLEAR_SAVED_OPHDR\n");\r
 #endif\r
-  mCIfrOpHdr = NULL;\r
+  mCIfrOpHdr       = NULL;\r
+  mCIfrOpHdrLineNo = 0;\r
 }\r
 \r
-VOID\r
+BOOLEAN\r
 EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (\r
   VOID\r
   )\r
@@ -3047,7 +3077,14 @@ EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
 #if 0\r
   printf ("#######_SET_SAVED_OPHDR_SCOPE\n");\r
 #endif\r
-  mCIfrOpHdr->SetScope (1);\r
+  if (mCIfrOpHdr != NULL) {\r
+    mCIfrOpHdr->SetScope (1);\r
+    return TRUE;\r
+  }\r
+  //\r
+  // IfrOpHdr is not set, FALSE is return.\r
+  //\r
+  return FALSE;\r
 }\r
 \r
 VOID\r