Fixed a type issue.
[people/mcb30/basetools.git] / Source / C / VfrCompile / VfrSyntax.g
1 /*++\r
2 Copyright (c) 2004 - 2008, Intel Corporation\r
3 All rights reserved. This program and the accompanying materials\r
4 are licensed and made available under the terms and conditions of the BSD License\r
5 which accompanies this distribution.  The full text of the license may be found at\r
6 http://opensource.org/licenses/bsd-license.php\r
7 \r
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
10 \r
11 Module Name:\r
12   VfrSyntax.g\r
13 \r
14 Abstract:\r
15 \r
16 --*/\r
17 \r
18 #header<<\r
19 \r
20 #include "EfiVfr.h"\r
21 #include "VfrFormPkg.h"\r
22 #include "VfrError.h"\r
23 #include "VfrUtilityLib.h"\r
24 #include "AToken.h"\r
25 #include "ATokPtr.h"\r
26 >>\r
27 \r
28 <<\r
29 #include "stdio.h"\r
30 #include "PBlackBox.h"\r
31 #include "DLexerBase.h"\r
32 #include "VfrLexer.h"\r
33 #include "AToken.h"\r
34 \r
35 #define GET_LINENO(Obj)       ((Obj)->getLine())\r
36 #define SET_LINE_INFO(Obj, L) {(Obj).SetLineNo((L)->getLine());} while (0)\r
37 #define CRT_END_OP(Obj)       {CIfrEnd EObj; EObj.SetLineNo ((Obj)->getLine());} while (0)\r
38 \r
39 typedef ANTLRCommonToken ANTLRToken;\r
40 \r
41 class CVfrDLGLexer : public VfrLexer\r
42 {\r
43 public:\r
44   CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};\r
45   INT32 errstd (char *Text)\r
46   {\r
47     printf ("unrecognized input '%s'\n", Text);\r
48   }\r
49 };\r
50 \r
51 UINT8\r
52 VfrParserStart (\r
53   IN FILE *File\r
54   )\r
55 {\r
56   ParserBlackBox<CVfrDLGLexer, EfiVfrParser, ANTLRToken> VfrParser(File);\r
57   return VfrParser.parser()->vfrProgram();\r
58 }\r
59 >>\r
60 \r
61 //\r
62 // Define a lexical class for parsing quoted strings. Basically\r
63 // starts with a double quote, and ends with a double quote that\r
64 // is not preceeded with a backslash.\r
65 //\r
66 #lexclass QUOTED_STRING\r
67 #token TheString            "~[\"]*\"" << mode (START); >>\r
68 \r
69 //\r
70 // Define a lexclass for skipping over C++ style comments\r
71 //\r
72 #lexclass CPP_COMMENT\r
73 #token "~[\n]*"       << skip (); >>\r
74 #token "\n"           << skip (); mode (START); newline (); >>\r
75 \r
76 //\r
77 // Standard lexclass is START\r
78 //\r
79 #lexclass START\r
80 \r
81 //\r
82 // Find start of C++ style comments\r
83 //\r
84 #token "//"       << skip (); mode (CPP_COMMENT); >>\r
85 \r
86 //\r
87 // Skip whitespace\r
88 //\r
89 #token "[\ \t]"   << skip (); >>\r
90 \r
91 //\r
92 // Skip over newlines, but count them\r
93 //\r
94 #token "\n"       << skip (); newline (); >>\r
95 \r
96 //\r
97 // Skip over 'extern' in any included .H file\r
98 //\r
99 #token "extern"   << skip (); mode (CPP_COMMENT); >>\r
100 \r
101 //\r
102 // Tokens for the different keywords. Syntax is:\r
103 // TokenName("ErrorMessageText")    "TokenString"\r
104 //   where:\r
105 //     TokenName is the token name (must be capitalized) that is used in the rules\r
106 //     ErrorMessageText is the string the compiler emits when it detects a syntax error\r
107 //     TokenString is the actual matching string used in the user script\r
108 //\r
109 #token FormPkgType("formpkgtype")               "formpkgtype"\r
110 #token OpenBrace("{")                           "\{"\r
111 #token CloseBrace("}")                          "\}"\r
112 #token OpenParen("(")                           "\("\r
113 #token CloseParen(")")                          "\)"\r
114 #token OpenBracket("[")                         "\["\r
115 #token CloseBracket("]")                        "\]"\r
116 \r
117 #token LineDefinition                           "#line\ [0-9]+\ \"~[\"]+\"[\ \t]*\n" << gCVfrErrorHandle.ParseFileScopeRecord (begexpr (), line ()); skip (); newline (); >>\r
118 #token DevicePath("devicepath")                 "devicepath"\r
119 #token FormSet("formset")                       "formset"\r
120 #token FormSetId("formsetid")                   "formsetid"\r
121 #token EndFormSet("endformset")                 "endformset"\r
122 #token Title("title")                           "title"\r
123 #token FormId("formid")                         "formid"\r
124 #token OneOf("oneof")                           "oneof"\r
125 #token EndOneOf("endoneof")                     "endoneof"\r
126 #token Prompt("prompt")                         "prompt"\r
127 #token OrderedList("orderedlist")               "orderedlist"\r
128 #token MaxContainers("maxcontainers")           "maxcontainers"\r
129 #token EndList("endlist")                       "endlist"\r
130 #token EndForm("endform")                       "endform"\r
131 #token Form("form")                             "form"\r
132 #token Subtitle("subtitle")                     "subtitle"\r
133 #token Help("help")                             "help"\r
134 #token Text("text")                             "text"\r
135 #token Option("option")                         "option"\r
136 #token FLAGS("flags")                           "flags"\r
137 #token Date("date")                             "date"\r
138 #token EndDate("enddate")                       "enddate"\r
139 #token Year("year")                             "year"\r
140 #token Month("month")                           "month"\r
141 #token Day("day")                               "day"\r
142 #token Time("time")                             "time"\r
143 #token EndTime("endtime")                       "endtime"\r
144 #token Hour("hour")                             "hour"\r
145 #token Minute("minute")                         "minute"\r
146 #token Second("second")                         "second"\r
147 #token GrayOutIf("grayoutif")                   "grayoutif"\r
148 #token Label("label")                           "label"\r
149 #token Timeout("timeout")                       "timeout"\r
150 #token Inventory("inventory")                   "inventory"\r
151 #token NonNvDataMap("_NON_NV_DATA_MAP")         "_NON_NV_DATA_MAP"\r
152 #token Struct("struct")                         "struct"\r
153 #token Boolean("BOOLEAN")                       "BOOLEAN"\r
154 #token Uint64("UINT64")                         "UINT64"\r
155 #token Uint32("UINT32")                         "UINT32"\r
156 #token Uint16("UINT16")                         "UINT16"\r
157 #token Char16("CHAR16")                         "CHAR16"\r
158 #token Uint8("UINT8")                           "UINT8"\r
159 #token Uuid("guid")                             "guid"\r
160 #token CheckBox("checkbox")                     "checkbox"\r
161 #token EndCheckBox("endcheckbox")               "endcheckbox"\r
162 #token Numeric("numeric")                       "numeric"\r
163 #token EndNumeric("endnumeric")                 "endnumeric"\r
164 #token Minimum("minimum")                       "minimum"\r
165 #token Maximum("maximum")                       "maximum"\r
166 #token STEP("step")                             "step"\r
167 #token Default("default")                       "default"\r
168 #token Password("password")                     "password"\r
169 #token EndPassword("endpassword")               "endpassword"\r
170 #token String("string")                         "string"\r
171 #token EndString("endstring")                   "endstring"\r
172 #token MinSize("minsize")                       "minsize"\r
173 #token MaxSize("maxsize")                       "maxsize"\r
174 #token Encoding("encoding")                     "encoding"\r
175 #token SuppressIf("suppressif")                 "suppressif"\r
176 #token DisableIf("disableif")                   "disableif"\r
177 #token Hidden("hidden")                         "hidden"\r
178 #token Goto("goto")                             "goto"\r
179 #token FormSetGuid("formsetguid")               "formsetguid"\r
180 #token InconsistentIf("inconsistentif")         "inconsistentif"\r
181 #token NoSubmitIf("nosubmitif")                 "nosubmitif"\r
182 #token EndIf("endif")                           "endif"\r
183 #token Key("key")                               "key"\r
184 #token DefaultFlag("DEFAULT")                   "DEFAULT"\r
185 #token ManufacturingFlag("MANUFACTURING")       "MANUFACTURING"\r
186 #token InteractiveFlag("INTERACTIVE")           "INTERACTIVE"\r
187 #token NVAccessFlag("NV_ACCESS")                "NV_ACCESS"\r
188 #token ResetRequiredFlag("RESET_REQUIRED")      "RESET_REQUIRED"\r
189 #token LateCheckFlag("LATE_CHECK")              "LATE_CHECK"\r
190 #token ReadOnlyFlag("READ_ONLY")                "READ_ONLY"\r
191 #token CallBackFlag("INTERACTIVE")              "INTERACTIVE"\r
192 #token OptionOnlyFlag("OPTIONS_ONLY")           "OPTIONS_ONLY"\r
193 #token Class("class")                           "class"\r
194 #token Subclass("subclass")                     "subclass"\r
195 #token TypeDef("typedef")                       "typedef"\r
196 #token Restore("restore")                       "restore"\r
197 #token Save("save")                             "save"\r
198 #token Defaults("defaults")                     "defaults"\r
199 #token Banner("banner")                         "banner"\r
200 #token Align("align")                           "align"\r
201 #token Left("left")                             "left"\r
202 #token Right("right")                           "right"\r
203 #token Center("center")                         "center"\r
204 #token Line("line")                             "line"\r
205 #token Name("name")                             "name"\r
206 \r
207 #token VarId("varid")                           "varid"\r
208 #token Question("question")                     "question"\r
209 #token QuestionId("questionid")                 "questionid"\r
210 #token Image("image")                           "image"\r
211 #token Locked("locked")                         "locked"\r
212 #token Rule("rule")                             "rule"\r
213 #token EndRule("endrule")                       "endrule"\r
214 #token Value("value")                           "value"\r
215 #token ResetButton("resetbutton")               "resetbutton"\r
216 #token EndResetButton("endresetbutton")         "endresetbutton"\r
217 #token DefaultStore("defaultstore")             "defaultstore"\r
218 #token Attribute("attribute")                   "attribute"\r
219 #token Varstore("varstore")                     "varstore"\r
220 #token Efivarstore("efivarstore")               "efivarstore"\r
221 #token VarSize("varsize")                       "varsize"\r
222 #token NameValueVarStore("namevaluevarstore")   "namevaluevarstore"\r
223 #token Action("action")                         "action"\r
224 #token Config("config")                         "config"\r
225 #token EndAction("endaction")                   "endaction"\r
226 #token Refresh("refresh")                       "refresh"\r
227 #token Interval("interval")                     "interval"\r
228 #token VarstoreDevice("varstoredevice")         "varstoredevice"\r
229 //\r
230 // Define the class and subclass tokens\r
231 //\r
232 #token ClassNonDevice("NONDEVICE")                        "NON_DEVICE"\r
233 #token ClassDiskDevice("DISK_DEVICE")                     "DISK_DEVICE"\r
234 #token ClassVideoDevice("VIDEO_DEVICE")                   "VIDEO_DEVICE"\r
235 #token ClassNetworkDevice("NETWORK_DEVICE")               "NETWORK_DEVICE"\r
236 #token ClassInputDevice("INPUT_DEVICE")                   "INPUT_DEVICE"\r
237 #token ClassOnBoardDevice("ONBOARD_DEVICE")               "ONBOARD_DEVICE"\r
238 #token ClassOtherDevice("OTHER_DEVICE")                   "OTHER_DEVICE"\r
239 \r
240 #token SubclassSetupApplication("SETUP_APPLICATION")      "SETUP_APPLICATION"\r
241 #token SubclassGeneralApplication("GENERAL_APPLICATION")  "GENERAL_APPLICATION"\r
242 #token SubclassFrontPage("FRONT_PAGE")                    "FRONT_PAGE"\r
243 #token SubclassSingleUse("SINGLE_USE")                    "SINGLE_USE"\r
244 \r
245 //\r
246 // This is the overall definition of a VFR form definition script.\r
247 //\r
248 \r
249 vfrProgram > [UINT8 Return] :\r
250   << mParserStatus = 0; >>\r
251   (\r
252       vfrPragmaPackDefinition\r
253     | vfrDataStructDefinition\r
254   )*\r
255   vfrFormSetDefinition\r
256   << $Return = mParserStatus; >>\r
257   ;\r
258 \r
259 pragmaPackShowDef :\r
260   L:"show"                                          << mCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >>\r
261   ;\r
262 \r
263 pragmaPackStackDef :\r
264   <<\r
265      UINT32 LineNum;\r
266      UINT8  PackAction;\r
267      CHAR8  *Identifier = NULL;\r
268      UINT32 PackNumber  = DEFAULT_PACK_ALIGN;\r
269   >>\r
270   (\r
271       L1:"push"                                     << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >>\r
272     | L2:"pop"                                      << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >>\r
273   )\r
274   {\r
275     "," ID:StringIdentifier                         << Identifier = ID->getText(); >>\r
276   }\r
277   {\r
278     "," N:Number                                    << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >>\r
279   }\r
280                                                     << mCVfrVarDataTypeDB.Pack (LineNum, PackAction, Identifier, PackNumber); >>\r
281   ;\r
282 \r
283 pragmaPackNumber :\r
284   <<\r
285      UINT32 LineNum;\r
286      UINT32 PackNumber = DEFAULT_PACK_ALIGN;\r
287   >>\r
288   N:Number                                          << LineNum = N->getLine(); PackNumber = _STOU32(N->getText()); >>\r
289                                                     << mCVfrVarDataTypeDB.Pack (LineNum, VFR_PACK_ASSIGN, NULL, PackNumber); >>\r
290   ;\r
291 \r
292 vfrPragmaPackDefinition :\r
293   "\#pragma" "pack" "\("\r
294   {\r
295       pragmaPackShowDef\r
296     | pragmaPackStackDef\r
297     | pragmaPackNumber\r
298   }\r
299   "\)"\r
300   ;\r
301 \r
302 vfrDataStructDefinition :\r
303   { TypeDef } Struct                                << mCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>\r
304   { NonNvDataMap }\r
305   {\r
306     N1:StringIdentifier                             << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>\r
307   }\r
308   OpenBrace\r
309     vfrDataStructFields\r
310   CloseBrace\r
311   {\r
312     N2:StringIdentifier                             << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>\r
313   }\r
314   ";"                                               << mCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>\r
315   ;\r
316 \r
317 vfrDataStructFields :\r
318   (\r
319      dataStructField64     |\r
320          dataStructField32     |\r
321          dataStructField16     |\r
322          dataStructField8      |\r
323      dataStructFieldBool   |\r
324          dataStructFieldString |\r
325          dataStructFieldDate   |\r
326          dataStructFieldTime   |\r
327      dataStructFieldUser\r
328   )*\r
329   ;\r
330 \r
331 dataStructField64 :\r
332   << UINT32 ArrayNum = 0; >>\r
333   "UINT64"\r
334   N:StringIdentifier\r
335   {\r
336     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
337   }\r
338   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT64", ArrayNum), N); >>\r
339   ;\r
340 \r
341 dataStructField32 :\r
342   << UINT32 ArrayNum = 0; >>\r
343   "UINT32"\r
344   N:StringIdentifier\r
345   {\r
346     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
347   }\r
348   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT32", ArrayNum), N); >>\r
349   ;\r
350 \r
351 dataStructField16 :\r
352   << UINT32 ArrayNum = 0; >>\r
353   ("UINT16" | "CHAR16")\r
354   N:StringIdentifier\r
355   {\r
356     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
357   }\r
358   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT16", ArrayNum), N); >>\r
359   ;\r
360 \r
361 dataStructField8 :\r
362   << UINT32 ArrayNum = 0; >>\r
363   "UINT8"\r
364   N:StringIdentifier\r
365   {\r
366     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
367   }\r
368   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "UINT8", ArrayNum), N); >>\r
369   ;\r
370 \r
371 dataStructFieldBool :\r
372   << UINT32 ArrayNum = 0; >>\r
373   "BOOLEAN"\r
374   N:StringIdentifier\r
375   {\r
376     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
377   }\r
378   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "BOOLEAN", ArrayNum), N); >>\r
379   ;\r
380 \r
381 dataStructFieldString :\r
382   << UINT32 ArrayNum = 0; >>\r
383   "EFI_STRING_ID"\r
384   N:StringIdentifier\r
385   {\r
386     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
387   }\r
388   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_STRING_ID", ArrayNum), N); >>\r
389   ;\r
390 \r
391 dataStructFieldDate :\r
392   << UINT32 ArrayNum = 0; >>\r
393   "EFI_HII_DATE"\r
394   N:StringIdentifier\r
395   {\r
396     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
397   }\r
398   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_HII_DATE", ArrayNum), N); >>\r
399   ;\r
400 \r
401 dataStructFieldTime :\r
402   << UINT32 ArrayNum = 0; >>\r
403   "EFI_HII_TIME"\r
404   N:StringIdentifier\r
405   {\r
406     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
407   }\r
408   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), "EFI_HII_TIME", ArrayNum), N); >>\r
409   ;\r
410 \r
411 dataStructFieldUser :\r
412   << UINT32 ArrayNum = 0; >>\r
413   T:StringIdentifier\r
414   N:StringIdentifier\r
415   {\r
416     OpenBracket I:Number CloseBracket               << ArrayNum = _STOU32(I->getText()); >>\r
417   }\r
418   ";"                                               << _PCATCH(mCVfrVarDataTypeDB.DataTypeAddField (N->getText(), T->getText(), ArrayNum), T); >>\r
419   ;\r
420 \r
421 //*****************************************************************************\r
422 //\r
423 // the syntax of GUID definition\r
424 //\r
425 guidSubDefinition [EFI_GUID &Guid] :\r
426   G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number\r
427                                                     <<\r
428                                                                                                            Guid.Data4[0] = _STOU8(G4->getText());\r
429                                                                                                            Guid.Data4[1] = _STOU8(G5->getText());\r
430                                                                                                            Guid.Data4[2] = _STOU8(G6->getText());\r
431                                                                                                            Guid.Data4[3] = _STOU8(G7->getText());\r
432                                                                                                            Guid.Data4[4] = _STOU8(G8->getText());\r
433                                                                                                            Guid.Data4[5] = _STOU8(G9->getText());\r
434                                                                                                            Guid.Data4[6] = _STOU8(G10->getText());\r
435                                                                                                            Guid.Data4[7] = _STOU8(G11->getText());\r
436                                                     >>\r
437   ;\r
438 \r
439 guidDefinition [EFI_GUID &Guid] :\r
440   OpenBrace\r
441     G1:Number "," G2:Number "," G3:Number ","\r
442                                                     <<\r
443                                                        Guid.Data1 = _STOU32 (G1->getText());\r
444                                                        Guid.Data2 = _STOU16 (G2->getText());\r
445                                                        Guid.Data3 = _STOU16 (G3->getText());\r
446                                                     >>\r
447     (\r
448         OpenBrace guidSubDefinition[Guid] CloseBrace\r
449       | guidSubDefinition[Guid]\r
450     )\r
451   CloseBrace\r
452   ;\r
453 \r
454 //*****************************************************************************\r
455 //\r
456 // the syntax of form set definition\r
457 //\r
458 vfrFormSetDefinition :\r
459   <<\r
460      EFI_GUID    Guid;\r
461      CIfrFormSet FSObj;\r
462      UINT16      C, SC;\r
463   >>\r
464   L:FormSet                                         << SET_LINE_INFO (FSObj, L); >>\r
465   Uuid "=" guidDefinition[Guid] ","                 << FSObj.SetGuid (&Guid); >>\r
466   Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","  << FSObj.SetFormSetTitle (_STOSID(S1->getText())); >>\r
467   Help  "=" "STRING_TOKEN" "\(" S2:Number "\)" ","  << FSObj.SetHelp (_STOSID(S2->getText())); >>\r
468   {\r
469     Class "=" classDefinition[C] ","                << {CIfrClass CObj; CObj.SetClass(C);} >>\r
470   }\r
471   {\r
472     Subclass "=" subclassDefinition[SC] ","         << {CIfrSubClass SCObj; SCObj.SetSubClass(SC);} >>\r
473   }\r
474                                                     <<\r
475                                                        _DeclareStandardDefaultStorage (GET_LINENO (L));\r
476                                                        //_DeclareDefaultLinearVarStore (GET_LINENO (L));\r
477                                                     >>\r
478   vfrFormSetList\r
479   E:EndFormSet                                      << CRT_END_OP (E); >>\r
480   ";"\r
481   ;\r
482 \r
483 vfrFormSetList :\r
484   (\r
485     vfrFormDefinition             |\r
486     vfrStatementImage             |\r
487     vfrStatementVarStoreLinear    |\r
488     vfrStatementVarStoreEfi       |\r
489     vfrStatementVarStoreNameValue |\r
490     vfrStatementDefaultStore      |\r
491     vfrStatementDisableIfFormSet\r
492   )*\r
493   ;\r
494 \r
495 vfrStatementDefaultStore :\r
496   << UINT16  DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; >>\r
497   D:DefaultStore N:StringIdentifier ","\r
498   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)"\r
499   {\r
500     "," Attribute "=" A:Number                      << DefaultId = _STOU16(A->getText()); >>\r
501   }\r
502                                                     <<\r
503                                                        if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {\r
504                                                          CIfrDefaultStore DSObj;\r
505                                                          _PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();\r
506                                                                                                                  DSObj.SetLineNo(D->getLine());\r
507                                                          DSObj.SetDefaultName (_STOSID(S->getText()));\r
508                                                          DSObj.SetDefaultId (DefaultId);\r
509                                                                                                            } else {\r
510                                                          _PCATCH(mCVfrDefaultStore.ReRegisterDefaultStoreById (DefaultId, N->getText(), _STOSID(S->getText()))), D->getLine();\r
511                                                                                                            }\r
512                                                     >>\r
513   ";"\r
514   ;\r
515 \r
516 vfrStatementVarStoreLinear :\r
517   <<\r
518      EFI_GUID        Guid;\r
519      CIfrVarStore    VSObj;\r
520      CHAR8           *TypeName;\r
521          UINT32          LineNum;\r
522      EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;\r
523      UINT32          Size;\r
524   >>\r
525   V:Varstore                                        << VSObj.SetLineNo(V->getLine()); >>\r
526   (\r
527       TN:StringIdentifier ","                       << TypeName = TN->getText(); LineNum = TN->getLine(); >>\r
528         | U8:"UINT8" ","                                << TypeName = "UINT8"; LineNum = U8->getLine(); >>\r
529         | U16:"UINT16" ","                              << TypeName = "UINT16"; LineNum = U16->getLine(); >>\r
530         | U32:"UINT32" ","                              << TypeName = "UINT32"; LineNum = U32->getLine(); >>\r
531         | U64:"UINT64" ","                              << TypeName = "UINT64"; LineNum = U64->getLine(); >>\r
532         | D:"EFI_HII_DATE" ","                          << TypeName = "EFI_HII_DATE"; LineNum = D->getLine(); >>\r
533         | T:"EFI_HII_TIME" ","                          << TypeName = "EFI_HII_TIME"; LineNum = T->getLine(); >>\r
534   )\r
535   { Key "=" Number "," }                            // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR\r
536   {\r
537     VarId "=" ID:Number ","                         <<\r
538                                                        _PCATCH(\r
539                                                          (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,\r
540                                                          (INTN)TRUE,\r
541                                                          ID,\r
542                                                          "varid 0 is not allowed."\r
543                                                          );\r
544                                                     >>\r
545   }\r
546   Name "=" SN:StringIdentifier ","\r
547   Uuid "=" guidDefinition[Guid]\r
548                                                     <<\r
549                                                        _PCATCH(mCVfrDataStorage.DeclareBufferVarStore (\r
550                                                                                   SN->getText(),\r
551                                                                                   &Guid,\r
552                                                                                   &mCVfrVarDataTypeDB,\r
553                                                                                   TypeName,\r
554                                                                                                                                                                   VarStoreId\r
555                                                                                   ), LineNum);\r
556                                                     >>\r
557                                                     <<\r
558                                                        VSObj.SetGuid (&Guid);\r
559                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
560                                                        VSObj.SetVarStoreId (VarStoreId);\r
561                                                        _PCATCH(mCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);\r
562                                                        VSObj.SetSize (Size);\r
563                                                        VSObj.SetName (SN->getText());\r
564                                                     >>\r
565   ";"\r
566   ;\r
567 \r
568 vfrStatementVarStoreEfi :\r
569   <<\r
570      EFI_GUID        Guid;\r
571      CIfrVarStoreEfi VSEObj;\r
572      EFI_VARSTORE_ID VarStoreId;\r
573      UINT32          Attr = 0;\r
574   >>\r
575   E:Efivarstore                                     << VSEObj.SetLineNo(E->getLine()); >>\r
576   SN:StringIdentifier ","\r
577   Attribute "=" vfrVarStoreEfiAttr[Attr] ( "\|" vfrVarStoreEfiAttr[Attr] )* ","\r
578                                                     << VSEObj.SetAttributes (Attr); >>\r
579   Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","\r
580   VarSize "=" N:Number ","\r
581   Uuid "=" guidDefinition[Guid]                     << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>\r
582                                                     <<\r
583                                                        VSEObj.SetGuid (&Guid);\r
584                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
585                                                        VSEObj.SetVarStoreId (VarStoreId);\r
586                                                     >>\r
587   ";"\r
588   ;\r
589 \r
590 vfrVarStoreEfiAttr [UINT32 & Attr] :\r
591   N:Number                                          << $Attr |= _STOU32(N->getText()); >>\r
592   ;\r
593 \r
594 vfrStatementVarStoreNameValue :\r
595   <<\r
596      EFI_GUID              Guid;\r
597      CIfrVarStoreNameValue VSNVObj;\r
598      EFI_VARSTORE_ID       VarStoreId;\r
599   >>\r
600   L:NameValueVarStore                               << VSNVObj.SetLineNo(L->getLine()); >>\r
601   SN:StringIdentifier ","                           << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreBegin (SN->getText()), SN); >>\r
602   (\r
603     Name "=" "STRING_TOKEN" "\(" N:Number "\)" ","  << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>\r
604   )+\r
605   Uuid "=" guidDefinition[Guid]                     << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>\r
606                                                     <<\r
607                                                        VSNVObj.SetGuid (&Guid);\r
608                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);\r
609                                                        VSNVObj.SetVarStoreId (VarStoreId);\r
610                                                     >>\r
611   ";"\r
612   ;\r
613 \r
614 //\r
615 // keep classDeinition and validClassNames for compatibility but not generate\r
616 // any IFR object\r
617 //\r
618 classDefinition[UINT16 & Class] :\r
619   << $Class = 0; >>\r
620   validClassNames[$Class] ( "\|" validClassNames[$Class] )*\r
621   ;\r
622 \r
623 validClassNames[UINT16 & Class] :\r
624     ClassNonDevice                                  << $Class |= EFI_NON_DEVICE_CLASS; >>\r
625   | ClassDiskDevice                                 << $Class |= EFI_DISK_DEVICE_CLASS; >>\r
626   | ClassVideoDevice                                << $Class |= EFI_VIDEO_DEVICE_CLASS; >>\r
627   | ClassNetworkDevice                              << $Class |= EFI_NETWORK_DEVICE_CLASS; >>\r
628   | ClassInputDevice                                << $Class |= EFI_INPUT_DEVICE_CLASS; >>\r
629   | ClassOnBoardDevice                              << $Class |= EFI_ON_BOARD_DEVICE_CLASS; >>\r
630   | ClassOtherDevice                                << $Class |= EFI_OTHER_DEVICE_CLASS; >>\r
631   | N:Number                                        << $Class |= _STOU16(N->getText()); >>\r
632   ;\r
633 \r
634 subclassDefinition[UINT16 & SubClass] :\r
635   << $SubClass = 0; >>\r
636     SubclassSetupApplication                        << $SubClass |= EFI_SETUP_APPLICATION_SUBCLASS; >>\r
637   | SubclassGeneralApplication                      << $SubClass |= EFI_GENERAL_APPLICATION_SUBCLASS; >>\r
638   | SubclassFrontPage                               << $SubClass |= EFI_FRONT_PAGE_SUBCLASS; >>\r
639   | SubclassSingleUse                               << $SubClass |= EFI_SINGLE_USE_SUBCLASS; >>\r
640   | N:Number                                        << $SubClass |= _STOU16(N->getText()); >>\r
641   ;\r
642 \r
643 vfrStatementDisableIfFormSet :\r
644   << CIfrDisableIf DIObj; >>\r
645   D:DisableIf                                       << DIObj.SetLineNo(D->getLine()); >>\r
646   vfrStatementExpression[0] ";"\r
647   vfrFormSetList\r
648   E:EndIf                                           << CRT_END_OP (E); >>\r
649   ";"\r
650   ;\r
651 \r
652 //*****************************************************************************\r
653 //\r
654 // the syntax of question header and statement header\r
655 //\r
656 vfrStatementHeader[CIfrStatementHeader *SHObj] :\r
657   Prompt "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << $SHObj->SetPrompt (_STOSID(S1->getText())); >>\r
658   Help   "=" "STRING_TOKEN" "\(" S2:Number "\)"     << $SHObj->SetHelp (_STOSID(S2->getText())); >>\r
659   ;\r
660 \r
661 vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:\r
662   <<\r
663      EFI_VARSTORE_INFO Info;\r
664          EFI_QUESTION_ID   QId       = EFI_QUESTION_ID_INVALID;\r
665      CHAR8             *QName    = NULL;\r
666      CHAR8             *VarIdStr = NULL;\r
667   >>\r
668   {\r
669     Name "=" QN:StringIdentifier ","                <<\r
670                                                        QName = QN->getText();\r
671                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");\r
672                                                     >>\r
673   }\r
674   { V:VarId "=" vfrStorageVarId[Info, VarIdStr] "," }\r
675   {\r
676     QuestionId "=" ID:Number ","                    <<\r
677                                                        QId = _STOQID(ID->getText());\r
678                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");\r
679                                                     >>\r
680   }\r
681                                                     <<\r
682                                                        switch (QType) {\r
683                                                        case QUESTION_NORMAL:\r
684                                                          mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);\r
685                                                          break;\r
686                                                                                                            case QUESTION_DATE:\r
687                                                                                                                  mCVfrQuestionDB.RegisterNewDateQuestion (QName, VarIdStr, QId);\r
688                                                                                                                  break;\r
689                                                                                                            case QUESTION_TIME:\r
690                                                                                                                  mCVfrQuestionDB.RegisterNewTimeQuestion (QName, VarIdStr, QId);\r
691                                                                                                                  break;\r
692                                                                                                            default:\r
693                                                                                                                  _PCATCH(VFR_RETURN_FATAL_ERROR);\r
694                                                                                                            }\r
695                                                        $QHObj.SetQuestionId (QId);\r
696                                                        $QHObj.SetVarStoreInfo (&Info);\r
697                                                     >>\r
698   vfrStatementHeader[&$QHObj]\r
699                                                     << _SAVE_CURRQEST_VARINFO (Info); >>\r
700                                                                                                         << if (VarIdStr != NULL) delete VarIdStr; >>\r
701   ;\r
702 \r
703 vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :\r
704   <<\r
705          EFI_QUESTION_ID   QId = EFI_QUESTION_ID_INVALID;\r
706      CHAR8             *QName = NULL;\r
707   >>\r
708   {\r
709     Name "=" QN:StringIdentifier ","                <<\r
710                                                        QName = QN->getText();\r
711                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QName), VFR_RETURN_UNDEFINED, QN, "has already been used please used anther name");\r
712                                                     >>\r
713   }\r
714   {\r
715     QuestionId "=" ID:Number ","                    <<\r
716                                                        QId = _STOQID(ID->getText());\r
717                                                        _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");\r
718                                                     >>\r
719   }\r
720                                                     <<\r
721                                                        mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);\r
722                                                        $QHObj->SetQuestionId (QId);\r
723                                                     >>\r
724   vfrStatementHeader[$QHObj]\r
725   ;\r
726 \r
727 questionheaderFlagsField[UINT8 & Flags] :\r
728     ReadOnlyFlag                                    << $Flags |= 0x01; >>\r
729   | CallBackFlag                                    << $Flags |= 0x04; >>\r
730   | ResetRequiredFlag                               << $Flags |= 0x10; >>\r
731   | OptionOnlyFlag                                  << $Flags |= 0x80; >>\r
732   ;\r
733 \r
734 vfrStorageVarId[EFI_VARSTORE_INFO & Info, CHAR8 *&QuestVarIdStr] :\r
735   <<\r
736      UINT32                Idx;\r
737      UINT32                LineNo;\r
738      EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;\r
739      CHAR8                 *VarIdStr    = NULL;\r
740      CHAR8                 *VarStr      = NULL;\r
741      CHAR8                 *SName       = NULL;\r
742      CHAR8                 *TName       = NULL;\r
743   >>\r
744   (\r
745     SN1:StringIdentifier                            << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>\r
746     OpenBracket I1:Number CloseBracket              << Idx = _STOU32(I1->getText()); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>\r
747                                                     <<\r
748                                                        _PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN1);\r
749                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);\r
750                                                                                                            _PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);\r
751                                                                                                         >>\r
752   )\r
753   |\r
754   (\r
755     SN2:StringIdentifier                            << SName = SN2->getText(); _STRCAT(&VarIdStr, SName); >>\r
756                                                     <<\r
757                                                        _PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN2);\r
758                                                        _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN2);\r
759                                                                                                            if (VarStoreType == EFI_VFR_VARSTORE_BUFFER) {\r
760                                                          _PCATCH(mCVfrDataStorage.GetBufferVarStoreDataTypeName(SName, &TName), SN2);\r
761                                                                                                                  _STRCAT(&VarStr, TName);\r
762                                                                                                            }\r
763                                                     >>\r
764 \r
765     (\r
766       "."                                           <<\r
767                                                        _PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);\r
768                                                                                                            _STRCAT(&VarIdStr, "."); _STRCAT(&VarStr, ".");\r
769                                                                                                         >>\r
770       SF:StringIdentifier                           << _STRCAT(&VarIdStr, SF->getText()); _STRCAT(&VarStr, SF->getText()); >>\r
771       {\r
772         OpenBracket I2:Number CloseBracket          << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>\r
773                                                     << _STRCAT(&VarStr, "["); _STRCAT(&VarStr, I2->getText()); _STRCAT(&VarStr, "]"); >>\r
774       }\r
775     )*                                              <<\r
776                                                        switch (VarStoreType) {\r
777                                                        case EFI_VFR_VARSTORE_EFI:\r
778                                                          _PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);\r
779                                                          break;\r
780                                                        case EFI_VFR_VARSTORE_BUFFER:\r
781                                                          _PCATCH(mCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine());\r
782                                                          //_PCATCH(mCVfrDataStorage.BufferVarStoreRequestElementAdd (SName, Info), SN2);\r
783                                                          break;\r
784                                                        case EFI_VFR_VARSTORE_NAME:\r
785                                                        default: break;\r
786                                                        }\r
787 \r
788                                                        QuestVarIdStr = VarIdStr;\r
789                                                        if (VarStr != NULL) {delete VarStr;}\r
790                                                     >>\r
791   )\r
792   ;\r
793 \r
794 vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, CHAR8 *&VarIdStr, UINT32 &LineNo] :\r
795                                                     << VarIdStr = NULL; LineNo = 0; >>\r
796   (\r
797     SN1:StringIdentifier                            << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>\r
798     OpenBracket I1:Number CloseBracket              << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>\r
799                                                     << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>\r
800   )\r
801   |\r
802   (\r
803     SN2:StringIdentifier                            << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>\r
804     (\r
805       "."                                           << _STRCAT (&VarIdStr, "."); >>\r
806       SF:StringIdentifier                           << _STRCAT(&VarIdStr, SF->getText()); >>\r
807       {\r
808         OpenBracket I2:Number CloseBracket          << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>\r
809       }\r
810     )*\r
811                                                     << mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>\r
812   )\r
813   ;\r
814 \r
815 vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :\r
816     N1:Number                                       <<\r
817                                                        switch ($Type) {\r
818                                                        case EFI_IFR_TYPE_NUM_SIZE_8 :\r
819                                                                                                              $Value.u8     = _STOU8(N1->getText());\r
820                                                                                                                  break;\r
821                                                                                                            case EFI_IFR_TYPE_NUM_SIZE_16 :\r
822                                                                                                              $Value.u16    = _STOU16(N1->getText());\r
823                                                                                                                  break;\r
824                                                                                                            case EFI_IFR_TYPE_NUM_SIZE_32 :\r
825                                                                                                              $Value.u32    = _STOU32(N1->getText());\r
826                                                                                                                  break;\r
827                                                                                                            case EFI_IFR_TYPE_NUM_SIZE_64 :\r
828                                                                                                              $Value.u64    = _STOU64(N1->getText());\r
829                                                                                                                  break;\r
830                                                                                                            case EFI_IFR_TYPE_BOOLEAN :\r
831                                                                                                              $Value.b      = _STOU8(N1->getText());\r
832                                                                                                                  break;\r
833                                                                                                            case EFI_IFR_TYPE_STRING :\r
834                                                                                                              $Value.string = _STOU16(N1->getText());\r
835                                                                                                                  break;\r
836                                                                                                            case EFI_IFR_TYPE_TIME :\r
837                                                                                                            case EFI_IFR_TYPE_DATE :\r
838                                                                                                            default :\r
839                                                                                                                  break;\r
840                                                                                                            }\r
841                                                     >>\r
842   | B1:True                                         << $Value.b      = TRUE; >>\r
843   | B2:False                                        << $Value.b      = FALSE; >>\r
844   | O1:One                                          << $Value.u8     = _STOU8(O1->getText()); >>\r
845   | O2:Ones                                         << $Value.u64    = _STOU64(O2->getText()); >>\r
846   | Z:Zero                                          << $Value.u8     = _STOU8(Z->getText()); >>\r
847   | HOUR:Number ":" MINUTE:Number ":" SECOND:Number << $Value.time   = _STOT(HOUR->getText(), MINUTE->getText(), SECOND->getText()); >>\r
848   | YEAR:Number "/" MONTH:Number "/" DAY:Number     << $Value.date   = _STOD(YEAR->getText(), MONTH->getText(), DAY->getText()); >>\r
849   | "STRING_TOKEN" "\(" S1:Number "\)"              << $Value.string = _STOSID(S1->getText()); >>\r
850   ;\r
851 \r
852 //*****************************************************************************\r
853 //\r
854 // the syntax of form definition\r
855 //\r
856 vfrFormDefinition :\r
857   << CIfrForm FObj; >>\r
858   F:Form                                            << FObj.SetLineNo(F->getLine()); >>\r
859   FormId "=" S1:Number ","                          << _PCATCH(FObj.SetFormId (_STOFID(S1->getText())), S1); >>\r
860   Title "=" "STRING_TOKEN" "\(" S2:Number "\)" ";"  << FObj.SetFormTitle (_STOSID(S2->getText())); >>\r
861   (\r
862     vfrStatementImage                        |\r
863     vfrStatementLocked                       |\r
864     vfrStatementRules                        |\r
865     vfrStatementDefault                      |\r
866     vfrStatementStat                         |\r
867     vfrStatementQuestions                    |\r
868     vfrStatementConditional                  |\r
869     vfrStatementLabel                        |\r
870     vfrStatementBanner\r
871     // Just for framework vfr compatibility\r
872     //vfrStatementInvalid\r
873   )*\r
874   E:EndForm                                         << CRT_END_OP (E); >>\r
875   ";"\r
876   ;\r
877 \r
878 vfrStatementRules :\r
879   << CIfrRule RObj; >>\r
880   R:Rule                                            << RObj.SetLineNo(R->getLine()); >>\r
881   S1:StringIdentifier ","                           <<\r
882                                                        mCVfrRulesDB.RegisterRule (S1->getText());\r
883                                                        RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));\r
884                                                     >>\r
885   vfrStatementExpression[0]\r
886   E:EndRule                                         << CRT_END_OP (E); >>\r
887   ";"\r
888   ;\r
889 \r
890 vfrStatementDefault :\r
891   <<\r
892      BOOLEAN               IsExp         = FALSE;\r
893      EFI_IFR_TYPE_VALUE    Val;\r
894      CIfrDefault           DObj;\r
895      EFI_DEFAULT_ID        DefaultId     = EFI_HII_DEFAULT_CLASS_STANDARD;\r
896      CHAR8                 *VarStoreName = NULL;\r
897      EFI_VFR_VARSTORE_TYPE VarStoreType  = EFI_VFR_VARSTORE_INVALID;\r
898   >>\r
899   D:Default                                         << DObj.SetLineNo(D->getLine()); >>\r
900   (\r
901     (\r
902         vfrStatementValue ","                       << IsExp = TRUE; DObj.SetScope (1); >>\r
903       | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","\r
904                                                     << DObj.SetType (_GET_CURRQEST_DATATYPE()); DObj.SetValue(Val); >>\r
905     )\r
906     {\r
907       DefaultStore "=" SN:StringIdentifier ","      << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>\r
908     }\r
909                                                     <<\r
910                                                                                                            _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());\r
911                                                                                                            _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());\r
912                                                                                                            if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {\r
913                                                                                                              _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
914                                                                                                                                                      DefaultId,\r
915                                                                                                                                                                          _GET_CURRQEST_VARTINFO(),\r
916                                                                                                                                                                          VarStoreName,\r
917                                                                                                                                                                          _GET_CURRQEST_DATATYPE (),\r
918                                                                                                                                                                          Val), D->getLine());\r
919                                                                                                            }\r
920                                                                                                         >>\r
921   )\r
922   ;\r
923 \r
924 vfrStatementStat :\r
925   vfrStatementSubTitle        |\r
926   vfrStatementStaticText      |\r
927   vfrStatementCrossReference\r
928   ;\r
929 \r
930 vfrStatementQuestions :\r
931   vfrStatementBooleanType     |\r
932   vfrStatementDate            |\r
933   vfrStatementNumericType     |\r
934   vfrStatementStringType      |\r
935   vfrStatementOrderedList     |\r
936   vfrStatementTime\r
937   ;\r
938 \r
939 vfrStatementConditional :\r
940   vfrStatementDisableIfStat   |\r
941   vfrStatementSuppressIfStat  |\r
942   vfrStatementGrayOutIfStat\r
943   ;\r
944 \r
945 vfrStatementInvalid :\r
946                                                        << _CRT_OP (FALSE); >>\r
947   (\r
948     vfrStatementInvalidHidden          |\r
949     vfrStatementInvalidInconsistentIf  |\r
950     vfrStatementInvalidInventory       |\r
951     vfrStatementInvalidSaveRestoreDefaults\r
952   )\r
953                                                        << _CRT_OP (TRUE); >>\r
954   ;\r
955 \r
956 flagsField :\r
957   Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |\r
958   NVAccessFlag | ResetRequiredFlag | LateCheckFlag\r
959   ;\r
960 \r
961 vfrStatementValue :\r
962   << CIfrValue VObj; >>\r
963   V:Value                                              << VObj.SetLineNo(V->getLine()); >>\r
964   "=" vfrStatementExpression[0]\r
965   ;\r
966 \r
967 vfrStatementSubTitle :\r
968   << CIfrSubtitle SObj; >>\r
969   L:Subtitle                                           << SObj.SetLineNo(L->getLine()); >>\r
970   Text "=" "STRING_TOKEN" "\(" S:Number "\)"           << SObj.SetPrompt (_STOSID(S->getText())); >>\r
971   {\r
972     "," FLAGS "=" vfrSubtitleFlags[SObj]\r
973   }\r
974   { vfrStatementStatTagList "," }\r
975   E:";"                                                << CRT_END_OP (E); >>\r
976   ;\r
977 \r
978 vfrSubtitleFlags [CIfrSubtitle & SObj] :\r
979   << UINT8 LFlags = 0; >>\r
980   subtitleFlagsField[LFlags] ( "\|" subtitleFlagsField[LFlags] )*\r
981                                                        << _PCATCH(SObj.SetFlags (LFlags)); >>\r
982   ;\r
983 \r
984 subtitleFlagsField [UINT8 & Flags] :\r
985     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
986   | "HORIZONTAL"                                       << $Flags |= 0x01; >>\r
987   ;\r
988 \r
989 vfrStatementStaticText :\r
990   <<\r
991      UINT8           Flags   = 0;\r
992      EFI_QUESTION_ID QId     = EFI_QUESTION_ID_INVALID;\r
993      EFI_STRING_ID   TxtTwo  = EFI_STRING_ID_INVALID;\r
994    >>\r
995   T:Text\r
996   Help "=" "STRING_TOKEN" "\(" S1:Number "\)" ","\r
997   Text "=" "STRING_TOKEN" "\(" S2:Number "\)"\r
998   {\r
999     "," Text "=" "STRING_TOKEN" "\(" S3:Number "\)"    << TxtTwo = _STOSID(S3->getText()); >>\r
1000   }\r
1001   {\r
1002     "," F:FLAGS "=" staticTextFlagsField[Flags] ( "\|" staticTextFlagsField[Flags] )*\r
1003     "," Key "=" KN:Number\r
1004   }\r
1005                                                        <<\r
1006                                                           if (Flags & EFI_IFR_FLAG_CALLBACK) {\r
1007                                                             CIfrAction AObj;\r
1008                                                             mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);\r
1009                                                             AObj.SetQuestionId (QId);\r
1010                                                             AObj.SetPrompt (_STOSID(S2->getText()));\r
1011                                                             AObj.SetHelp (_STOSID(S1->getText()));\r
1012                                                             _PCATCH(AObj.SetFlags (Flags), F->getLine());\r
1013                                                             AssignQuestionKey (AObj, KN);\r
1014                                                             CRT_END_OP (T);\r
1015                                                           } else {\r
1016                                                                                                                     CIfrText TObj;\r
1017                                                                                                                     TObj.SetLineNo (T->getLine());\r
1018                                                                                                                         TObj.SetHelp (_STOSID(S1->getText()));\r
1019                                                                                                                         TObj.SetPrompt (_STOSID(S2->getText()));\r
1020                                                                                                                         TObj.SetTextTwo (TxtTwo);\r
1021                                                                                                                   }\r
1022                                                        >>\r
1023   { "," vfrStatementStatTagList }\r
1024   ";"\r
1025   ;\r
1026 \r
1027 staticTextFlagsField[UINT8 & HFlags] :\r
1028     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1029   | questionheaderFlagsField[HFlags]\r
1030   ;\r
1031 \r
1032 vfrStatementCrossReference :\r
1033   vfrStatementGoto            |\r
1034   vfrStatementResetButton\r
1035   ;\r
1036 \r
1037 vfrStatementGoto :\r
1038   <<\r
1039      UINT8               RefType = 1;\r
1040      EFI_STRING_ID       DevPath;\r
1041      EFI_GUID            FSId;\r
1042      EFI_FORM_ID         FId;\r
1043          EFI_QUESTION_ID     QId    = EFI_QUESTION_ID_INVALID;\r
1044      UINT32              BitMask;\r
1045      CIfrQuestionHeader  *QHObj = NULL;\r
1046      CIfrRef             *R1Obj = NULL;\r
1047      CIfrRef2            *R2Obj = NULL;\r
1048      CIfrRef3            *R3Obj = NULL;\r
1049      CIfrRef4            *R4Obj = NULL;\r
1050   >>\r
1051   G:Goto\r
1052   (\r
1053     (\r
1054       DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","\r
1055       FormSetGuid "=" guidDefinition[FSId] ","\r
1056       FormId "=" F1:Number ","\r
1057       Question "=" QN1:Number ","\r
1058                                                        <<\r
1059                                                           RefType = 4;\r
1060                                                           DevPath = _STOSID(P->getText());\r
1061                                                           FId = _STOFID(F1->getText());\r
1062                                                           QId = _STOQID(QN1->getText());\r
1063                                                        >>\r
1064     )\r
1065     |\r
1066     (\r
1067       FormSetGuid "=" guidDefinition[FSId] ","\r
1068       FormId "=" F2:Number ","\r
1069       Question "=" QN2:Number ","\r
1070                                                        <<\r
1071                                                           RefType = 3;\r
1072                                                           FId = _STOFID(F2->getText());\r
1073                                                           QId = _STOQID(QN2->getText());\r
1074                                                        >>\r
1075     )\r
1076     |\r
1077     (\r
1078       FormId "=" F3:Number ","                         << RefType = 2; FId = _STOFID(F3->getText()); >>\r
1079       Question "="\r
1080       (\r
1081           QN3:StringIdentifier ","                     << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>\r
1082         | QN4:Number ","                               << QId = _STOQID(QN4->getText()); >>\r
1083       )\r
1084     )\r
1085     |\r
1086     (\r
1087       F4:Number ","                                    <<\r
1088                                                           RefType = 1;\r
1089                                                           FId = _STOFID(F4->getText());\r
1090                                                        >>\r
1091     )\r
1092   )\r
1093                                                        <<\r
1094                                                           switch (RefType) {\r
1095                                                           case 4:\r
1096                                                             {\r
1097                                                               R4Obj = new CIfrRef4;\r
1098                                                               QHObj = R4Obj;\r
1099                                                               R4Obj->SetLineNo(G->getLine());\r
1100                                                               R4Obj->SetDevicePath (DevPath);\r
1101                                                               R4Obj->SetFormSetId (FSId);\r
1102                                                               R4Obj->SetFormId (FId);\r
1103                                                               R4Obj->SetQuestionId (QId);\r
1104                                                               break;\r
1105                                                             }\r
1106                                                           case 3:\r
1107                                                             {\r
1108                                                               R3Obj = new CIfrRef3;\r
1109                                                               QHObj = R3Obj;\r
1110                                                               R3Obj->SetLineNo(G->getLine());\r
1111                                                               R3Obj->SetFormSetId (FSId);\r
1112                                                               R3Obj->SetFormId (FId);\r
1113                                                               R3Obj->SetQuestionId (QId);\r
1114                                                               break;\r
1115                                                             }\r
1116                                                           case 2:\r
1117                                                             {\r
1118                                                               R2Obj = new CIfrRef2;\r
1119                                                               QHObj = R2Obj;\r
1120                                                               R2Obj->SetLineNo(G->getLine());\r
1121                                                               R2Obj->SetFormId (FId);\r
1122                                                               _PCATCH(R2Obj->SetQuestionId (QId), QN3);\r
1123                                                               break;\r
1124                                                             }\r
1125                                                           case 1:\r
1126                                                             {\r
1127                                                               R1Obj = new CIfrRef;\r
1128                                                               QHObj = R1Obj;\r
1129                                                               R1Obj->SetLineNo(G->getLine());\r
1130                                                               R1Obj->SetFormId (FId);\r
1131                                                               break;\r
1132                                                             }\r
1133                                                           default: break;\r
1134                                                           }\r
1135                                                        >>\r
1136   vfrQuestionHeaderWithNoStorage[QHObj]\r
1137   { "," vfrStatementStatTagList }\r
1138   { "," F:FLAGS  "=" vfrGotoFlags[QHObj, F->getLine()] }\r
1139   {\r
1140     "," Key "=" KN:Number                              << AssignQuestionKey (*QHObj, KN); >>\r
1141   }\r
1142   ";"                                                  << if (R1Obj != NULL) {delete R1Obj;} if (R2Obj != NULL) {delete R2Obj;} if (R3Obj != NULL) {delete R3Obj;} if (R4Obj != NULL) {delete R4Obj;} >>\r
1143   ;\r
1144 \r
1145 vfrGotoFlags [CIfrQuestionHeader *QHObj, UINT32 LineNum] :\r
1146   << UINT8 HFlags = 0; >>\r
1147   gotoFlagsField[HFlags] ( "\|" gotoFlagsField[HFlags] )*\r
1148                                                        << _PCATCH(QHObj->SetFlags (HFlags), LineNum); >>\r
1149   ;\r
1150 \r
1151 gotoFlagsField[UINT8 & HFlags] :\r
1152     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1153   | questionheaderFlagsField[HFlags]\r
1154   ;\r
1155 \r
1156 getStringId :\r
1157   "STRING_TOKEN" "\("\r
1158   IdVal:Number\r
1159   "\)"\r
1160   ;\r
1161 \r
1162 vfrStatementResetButton :\r
1163   <<\r
1164      CIfrResetButton RBObj;\r
1165      UINT16          DefaultId;\r
1166   >>\r
1167   L:ResetButton                                        << RBObj.SetLineNo(L->getLine()); >>\r
1168   DefaultStore\r
1169   "=" N:StringIdentifier ","                           <<\r
1170                                                           _PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());\r
1171                                                           RBObj.SetDefaultId (DefaultId);\r
1172                                                        >>\r
1173   vfrStatementHeader[&RBObj] ","\r
1174   { vfrStatementStatTagList "," }\r
1175   E:EndResetButton                                     << CRT_END_OP (E); >>\r
1176   ";"\r
1177   ;\r
1178 \r
1179 vfrStatementBooleanType :\r
1180   vfrStatementCheckBox |\r
1181   vfrStatementAction\r
1182   ;\r
1183 \r
1184 //*****************************************************\r
1185 // Syntax of checkbox\r
1186 //\r
1187 // Example:\r
1188 //   checkbox\r
1189 //     varid       = MySTestData.mField1,\r
1190 //     prompt      = STRING_TOKEN(STR_CHECK_BOX_PROMPT),\r
1191 //     help        = STRING_TOKEN(STR_CHECK_BOX_HELP),\r
1192 //     flags       = CHECKBOX_DEFAULT | CALLBACK,\r
1193 //     default value = TRUE, defaultstore = MyDefaultStore,\r
1194 //   endcheckbox;\r
1195 //\r
1196 vfrStatementCheckBox :\r
1197   <<\r
1198      CIfrCheckBox       CBObj;\r
1199      EFI_IFR_TYPE_VALUE Val;\r
1200      CHAR8              *VarStoreName = NULL;\r
1201   >>\r
1202   L:CheckBox                                           << CBObj.SetLineNo(L->getLine()); >>\r
1203   vfrQuestionHeader[CBObj] ","\r
1204   {\r
1205     F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","\r
1206                                                        <<\r
1207                                                           _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");\r
1208                                                           Val.b = TRUE;\r
1209                                                           if (CBObj.GetFlags () & 0x01) {\r
1210                                                             _PCATCH(\r
1211                                                               mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
1212                                                                                   EFI_HII_DEFAULT_CLASS_STANDARD,\r
1213                                                                                   _GET_CURRQEST_VARTINFO(),\r
1214                                                                                   VarStoreName,\r
1215                                                                                   _GET_CURRQEST_DATATYPE (),\r
1216                                                                                   Val\r
1217                                                                                   ),\r
1218                                                               VFR_RETURN_SUCCESS,\r
1219                                                               L,\r
1220                                                               "No standard default storage found"\r
1221                                                               );\r
1222                                                           }\r
1223                                                           if (CBObj.GetFlags () & 0x02) {\r
1224                                                             _PCATCH(\r
1225                                                               mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
1226                                                                                   EFI_HII_DEFAULT_CLASS_MANUFACTURING,\r
1227                                                                                   _GET_CURRQEST_VARTINFO(),\r
1228                                                                                   VarStoreName,\r
1229                                                                                   _GET_CURRQEST_DATATYPE (),\r
1230                                                                                   Val\r
1231                                                                                   ),\r
1232                                                               VFR_RETURN_SUCCESS,\r
1233                                                               L,\r
1234                                                               "No manufacturing default storage found"\r
1235                                                               );\r
1236                                                                                                                   }\r
1237                                                                                                            >>\r
1238   }\r
1239   {\r
1240     Key "=" KN:Number  ","                             << AssignQuestionKey (CBObj, KN); >>\r
1241   }\r
1242   vfrStatementQuestionOptionList\r
1243   E:EndCheckBox                                        << CRT_END_OP (E); >>\r
1244   ";"\r
1245   ;\r
1246 \r
1247 vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :\r
1248   <<\r
1249      UINT8 LFlags = 0;\r
1250      UINT8 HFlags = 0;\r
1251   >>\r
1252   checkboxFlagsField[LFlags, HFlags] ( "\|" checkboxFlagsField[LFlags, HFlags] )*\r
1253                                                        << _PCATCH(CBObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1254   ;\r
1255 \r
1256 checkboxFlagsField[UINT8 & LFlags, UINT8 & HFlags] :\r
1257     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1258   | "CHECKBOX_DEFAULT"                                 << $LFlags |= 0x01; >>\r
1259   | "CHECKBOX_DEFAULT_MFG"                             << $LFlags |= 0x02; >>\r
1260   | questionheaderFlagsField[HFlags]\r
1261   ;\r
1262 \r
1263 //*****************************************************\r
1264 // Syntax of action\r
1265 //\r
1266 // Example:\r
1267 //   action\r
1268 //     prompt      = STRING_TOKEN(STR_ACTION_PROMPT),\r
1269 //     help        = STRING_TOKEN(STR_ACTION_HELP),\r
1270 //     flags       = CALLBACK,\r
1271 //     config      = STRING_TOKEN(STR_ACTION_CONFIG),\r
1272 //   endaction;\r
1273 //\r
1274 vfrStatementAction :\r
1275   << CIfrAction AObj; >>\r
1276   L:Action                                             << AObj.SetLineNo(L->getLine()); >>\r
1277   vfrQuestionHeaderWithNoStorage[&AObj] ","\r
1278   { F:FLAGS "=" vfrActionFlags[AObj, F->getLine()] "," }\r
1279   Config "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << AObj.SetQuestionConfig (_STOSID(S->getText())); >>\r
1280   vfrStatementQuestionTagList\r
1281   E:EndAction                                          << CRT_END_OP (E); >>\r
1282   ";"\r
1283   ;\r
1284 \r
1285 vfrActionFlags[CIfrAction & AObj, UINT32 LineNum] :\r
1286   << UINT8 HFlags = 0; >>\r
1287   actionFlagsField[HFlags] ( "\|" actionFlagsField[HFlags] )*\r
1288                                                        << _PCATCH(AObj.SetFlags (HFlags), LineNum); >>\r
1289   ;\r
1290 \r
1291 actionFlagsField[UINT8 & HFlags] :\r
1292     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1293   | questionheaderFlagsField[HFlags]\r
1294   ;\r
1295 \r
1296 vfrStatementDate :\r
1297   <<\r
1298      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
1299      CHAR8              *VarIdStr[3] = {NULL, };\r
1300      CIfrDate           DObj;\r
1301      EFI_IFR_TYPE_VALUE Val;\r
1302   >>\r
1303   L:Date                                               << DObj.SetLineNo(L->getLine()); >>\r
1304   (\r
1305     (\r
1306       vfrQuestionHeader[DObj, QUESTION_DATE] ","\r
1307           { F:FLAGS "=" vfrDateFlags[DObj, F->getLine()] "," }\r
1308       vfrStatementQuestionOptionList\r
1309     )\r
1310     |\r
1311     (\r
1312       Year VarId "=" D1:StringIdentifier "." D1Y:StringIdentifier ","\r
1313                                                        << _STRCAT(&VarIdStr[0], D1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], D1Y->getText()); >>\r
1314       Prompt "=" "STRING_TOKEN" "\(" YP:Number "\)" ","\r
1315       Help   "=" "STRING_TOKEN" "\(" YH:Number "\)" ","\r
1316       minMaxDateStepDefault[Val.date, 0]\r
1317 \r
1318       Month VarId "=" D2:StringIdentifier "." D2M:StringIdentifier ","\r
1319                                                        << _STRCAT(&VarIdStr[1], D2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], D2M->getText()); >>\r
1320       Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","\r
1321       Help   "=" "STRING_TOKEN" "\(" MH:Number "\)" ","\r
1322       minMaxDateStepDefault[Val.date, 1]\r
1323 \r
1324       Day VarId "=" D3:StringIdentifier "." D3D:StringIdentifier ","\r
1325                                                        << _STRCAT(&VarIdStr[2], D3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], D3D->getText()); >>\r
1326       Prompt "=" "STRING_TOKEN" "\(" DP:Number "\)" ","\r
1327       Help   "=" "STRING_TOKEN" "\(" DH:Number "\)" ","\r
1328       minMaxDateStepDefault[Val.date, 2]\r
1329                                                        <<\r
1330                                                           mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
1331                                                           DObj.SetQuestionId (QId);\r
1332                                                           DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);\r
1333                                                                                                                   DObj.SetPrompt (_STOSID(YP->getText()));\r
1334                                                                                                                   DObj.SetHelp (_STOSID(YH->getText()));\r
1335                                                                                                                   if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
1336                                                        >>\r
1337                                                            << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val);} >>\r
1338       ( vfrStatementInconsistentIf )*\r
1339     )\r
1340   )\r
1341   E:EndDate                                            << CRT_END_OP (E); >>\r
1342   ";"\r
1343   ;\r
1344 \r
1345 minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :\r
1346   Minimum   "=" Number ","\r
1347   Maximum   "=" Number ","\r
1348   { "step"    "=" Number "," }\r
1349   {\r
1350     "default" "=" N:Number ","                         <<\r
1351                                                           switch (KeyValue) {\r
1352                                                           case 0: D.Year  = _STOU16(N->getText()); break;\r
1353                                                           case 1: D.Month = _STOU8(N->getText()); break;\r
1354                                                           case 2: D.Day   = _STOU8(N->getText()); break;\r
1355                                                                                                                   }\r
1356                                                        >>\r
1357   }\r
1358   ;\r
1359 \r
1360 vfrDateFlags [CIfrDate & DObj, UINT32 LineNum] :\r
1361   << UINT8 LFlags = 0; >>\r
1362   dateFlagsField[LFlags] ( "\|" dateFlagsField[LFlags] )*\r
1363                                                        << _PCATCH(DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>\r
1364   ;\r
1365 \r
1366 dateFlagsField [UINT8 & Flags] :\r
1367     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
1368   | "YEAR_SUPPRESS"                                    << $Flags |= 0x01; >>\r
1369   | "MONTH_SUPPRESS"                                   << $Flags |= 0x02; >>\r
1370   | "DAY_SUPPRESS"                                     << $Flags |= 0x04; >>\r
1371   | "STORAGE_NORMAL"                                   << $Flags |= 0x00; >>\r
1372   | "STORAGE_TIME"                                     << $Flags |= 0x10; >>\r
1373   | "STORAGE_WAKEUP"                                   << $Flags |= 0x20; >>\r
1374   ;\r
1375 \r
1376 vfrStatementNumericType :\r
1377   vfrStatementNumeric   |\r
1378   vfrStatementOneOf\r
1379   ;\r
1380 \r
1381 vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :\r
1382   <<\r
1383      UINT64 MaxU8 = 0, MinU8 = 0, StepU8 = 0;\r
1384      UINT32 MaxU4 = 0, MinU4 = 0, StepU4 = 0;\r
1385      UINT16 MaxU2 = 0, MinU2 = 0, StepU2 = 0;\r
1386      UINT8  MaxU1 = 0, MinU1 = 0, StepU1 = 0;\r
1387   >>\r
1388   Minimum   "=" I:Number ","\r
1389                                                        <<\r
1390                                                           switch (_GET_CURRQEST_DATATYPE ()) {\r
1391                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : MinU8 = _STOU64(I->getText()); break;\r
1392                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : MinU4 = _STOU32(I->getText()); break;\r
1393                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : MinU2 = _STOU16(I->getText()); break;\r
1394                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  MinU1 = _STOU8(I->getText());  break;\r
1395                                                           }\r
1396                                                                                                            >>\r
1397   Maximum   "=" A:Number ","\r
1398                                                        <<\r
1399                                                           switch (_GET_CURRQEST_DATATYPE ()) {\r
1400                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : MaxU8 = _STOU64(A->getText()); break;\r
1401                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : MaxU4 = _STOU32(A->getText()); break;\r
1402                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : MaxU2 = _STOU16(A->getText()); break;\r
1403                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  MaxU1 = _STOU8(A->getText());  break;\r
1404                                                           }\r
1405                                                                                                            >>\r
1406   {\r
1407     STEP    "=" S:Number ","\r
1408                                                        <<\r
1409                                                           switch (_GET_CURRQEST_DATATYPE ()) {\r
1410                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : StepU8 = _STOU64(S->getText()); break;\r
1411                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : StepU4 = _STOU32(S->getText()); break;\r
1412                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : StepU2 = _STOU16(S->getText()); break;\r
1413                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  StepU1 = _STOU8(S->getText());  break;\r
1414                                                           }\r
1415                                                                                                            >>\r
1416   }\r
1417                                                        <<\r
1418                                                           switch (_GET_CURRQEST_DATATYPE ()) {\r
1419                                                           case EFI_IFR_TYPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break;\r
1420                                                           case EFI_IFR_TYPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break;\r
1421                                                           case EFI_IFR_TYPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break;\r
1422                                                           case EFI_IFR_TYPE_NUM_SIZE_8 :  $MMSDObj.SetMinMaxStepData (MinU1, MaxU1, StepU1);  break;\r
1423                                                           }\r
1424                                                                                                            >>\r
1425   ;\r
1426 \r
1427 vfrStatementNumeric :\r
1428   <<\r
1429      CIfrNumeric NObj;\r
1430   >>\r
1431   L:Numeric                                            << NObj.SetLineNo(L->getLine()); >>\r
1432   vfrQuestionHeader[NObj] ","                          << _PCATCH(NObj.SetFlags (NObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>\r
1433   { F:FLAGS "=" vfrNumericFlags[NObj, F->getLine()] "," }\r
1434   {\r
1435     Key   "=" KN:Number ","                            << AssignQuestionKey (NObj, KN); >>\r
1436   }\r
1437   vfrSetMinMaxStep[NObj]\r
1438   vfrStatementQuestionOptionList\r
1439   E:EndNumeric                                         << CRT_END_OP (E); >>\r
1440   ";"\r
1441   ;\r
1442 \r
1443 vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :\r
1444   <<\r
1445      UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
1446      UINT8 HFlags = 0;\r
1447   >>\r
1448   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
1449                                                        << _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1450   ;\r
1451 \r
1452 numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
1453     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1454   | "DISPLAY_INT_DEC"                                  << $LFlags |= 0x00; >>\r
1455   | "DISPLAY_UINT_DEC"                                 << $LFlags |= 0x10; >>\r
1456   | "DISPLAY_UINT_HEX"                                 << $LFlags |= 0x20; >>\r
1457   | questionheaderFlagsField[HFlags]\r
1458   ;\r
1459 \r
1460 vfrStatementOneOf :\r
1461   <<\r
1462      CIfrOneOf OObj;\r
1463   >>\r
1464   L:OneOf                                              << OObj.SetLineNo(L->getLine()); >>\r
1465   vfrQuestionHeader[OObj] ","                          << _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>\r
1466   { F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }\r
1467   {\r
1468     vfrSetMinMaxStep[OObj]\r
1469   }\r
1470   vfrStatementQuestionOptionList\r
1471   E:EndOneOf                                           << CRT_END_OP (E); >>\r
1472   ";"\r
1473   ;\r
1474 \r
1475 vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :\r
1476   <<\r
1477      UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
1478      UINT8 HFlags = 0;\r
1479   >>\r
1480   numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*\r
1481                                                        << _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1482   ;\r
1483 \r
1484 vfrStatementStringType :\r
1485   vfrStatementString    |\r
1486   vfrStatementPassword\r
1487   ;\r
1488 \r
1489 vfrStatementString :\r
1490   <<\r
1491      CIfrString SObj;\r
1492   >>\r
1493   L:String                                             << SObj.SetLineNo(L->getLine()); >>\r
1494   vfrQuestionHeader[SObj] ","\r
1495   { F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }\r
1496   {\r
1497     Key "=" KN:Number ","                              << AssignQuestionKey (SObj, KN); >>\r
1498   }\r
1499   MinSize "=" MIN:Number ","                           << SObj.SetMinSize (_STOU8(MIN->getText())); >>\r
1500   MaxSize "=" MAX:Number ","                           << SObj.SetMaxSize (_STOU8(MAX->getText())); >>\r
1501   vfrStatementQuestionOptionList\r
1502   E:EndString                                          << CRT_END_OP (E); >>\r
1503   ";"\r
1504   ;\r
1505 \r
1506 vfrStringFlagsField [CIfrString & SObj, UINT32 LineNum] :\r
1507   <<\r
1508      UINT8 LFlags = 0;\r
1509      UINT8 HFlags = 0;\r
1510   >>\r
1511   stringFlagsField[HFlags, LFlags] ( "\|" stringFlagsField[HFlags, LFlags] )*\r
1512                                                        << _PCATCH(SObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1513   ;\r
1514 \r
1515 stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
1516     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1517   | "MULTI_LINE"                                       << $LFlags = 0x01; >>\r
1518   | questionheaderFlagsField[HFlags]\r
1519   ;\r
1520 \r
1521 vfrStatementPassword :\r
1522   <<\r
1523      CIfrPassword PObj;\r
1524   >>\r
1525   L:Password                                           << PObj.SetLineNo(L->getLine()); >>\r
1526   vfrQuestionHeader[PObj] ","\r
1527   { F:FLAGS "=" vfrPasswordFlagsField[PObj, F->getLine()] "," }\r
1528   {\r
1529     Key "=" KN:Number ","                              << AssignQuestionKey (PObj, KN); >>\r
1530   }\r
1531   MinSize "=" MIN:Number ","                           << PObj.SetMinSize (_STOU16(MIN->getText())); >>\r
1532   MaxSize "=" MAX:Number ","                           << PObj.SetMaxSize (_STOU16(MAX->getText())); >>\r
1533   { Encoding "=" Number "," }\r
1534   vfrStatementQuestionOptionList\r
1535   E:EndPassword                                        << CRT_END_OP (E); >>\r
1536   ";"\r
1537   ;\r
1538 \r
1539 vfrPasswordFlagsField [CIfrPassword & PObj, UINT32 LineNum] :\r
1540   << UINT8 HFlags = 0; >>\r
1541   passwordFlagsField[HFlags] ( "\|" passwordFlagsField[HFlags] )*\r
1542                                                        << _PCATCH(PObj.SetFlags(HFlags), LineNum); >>\r
1543   ;\r
1544 \r
1545 passwordFlagsField [UINT8 & HFlags] :\r
1546     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1547   | questionheaderFlagsField[HFlags]\r
1548   ;\r
1549 \r
1550 vfrStatementOrderedList :\r
1551   <<\r
1552      CIfrOrderedList OLObj;\r
1553   >>\r
1554   L:OrderedList                                        << OLObj.SetLineNo(L->getLine()); >>\r
1555   vfrQuestionHeader[OLObj] ","\r
1556                                                        << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >>\r
1557   {\r
1558     MaxContainers "=" M:Number ","                     << OLObj.SetMaxContainers (_STOU8(M->getText())); >>\r
1559   }\r
1560   { F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }\r
1561   vfrStatementQuestionOptionList\r
1562   E:EndList                                            << CRT_END_OP (E); >>\r
1563   ";"\r
1564   ;\r
1565 \r
1566 vfrOrderedListFlags [CIfrOrderedList & OLObj, UINT32 LineNum] :\r
1567   <<\r
1568      UINT8 HFlags = 0;\r
1569      UINT8 LFlags = 0;\r
1570   >>\r
1571   orderedlistFlagsField[HFlags, LFlags] ( "\|" orderedlistFlagsField[HFlags, LFlags] )*\r
1572                                                        << _PCATCH(OLObj.SetFlags (HFlags, LFlags), LineNum); >>\r
1573   ;\r
1574 \r
1575 orderedlistFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
1576     N:Number                                           << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>\r
1577   | "UNIQUE"                                           << $LFlags |= 0x01; >>\r
1578   | "NOEMPTY"                                          << $LFlags |= 0x02; >>\r
1579   | questionheaderFlagsField[HFlags]\r
1580   ;\r
1581 \r
1582 vfrStatementTime :\r
1583   <<\r
1584      EFI_QUESTION_ID    QId          = EFI_QUESTION_ID_INVALID;\r
1585      CHAR8              *VarIdStr[3] = {NULL, };\r
1586      CIfrTime           TObj;\r
1587      EFI_IFR_TYPE_VALUE Val;\r
1588   >>\r
1589   L:Time                                               << TObj.SetLineNo(L->getLine()); >>\r
1590   (\r
1591     (\r
1592       vfrQuestionHeader[TObj, QUESTION_TIME] ","\r
1593           { F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }\r
1594       vfrStatementDefault\r
1595     )\r
1596     |\r
1597     (\r
1598       Hour VarId "=" T1:StringIdentifier "." T1H:StringIdentifier ","\r
1599                                                        << _STRCAT(&VarIdStr[0], T1->getText()); _STRCAT(&VarIdStr[0], "."); _STRCAT(&VarIdStr[0], T1H->getText()); >>\r
1600       Prompt "=" "STRING_TOKEN" "\(" HP:Number "\)" ","\r
1601       Help   "=" "STRING_TOKEN" "\(" HH:Number "\)" ","\r
1602       minMaxTimeStepDefault[Val.time, 0]\r
1603 \r
1604       Minute VarId "=" T2:StringIdentifier "." T2M:StringIdentifier ","\r
1605                                                        << _STRCAT(&VarIdStr[1], T2->getText()); _STRCAT(&VarIdStr[1], "."); _STRCAT(&VarIdStr[1], T2M->getText()); >>\r
1606       Prompt "=" "STRING_TOKEN" "\(" MP:Number "\)" ","\r
1607       Help   "=" "STRING_TOKEN" "\(" MH:Number "\)" ","\r
1608       minMaxTimeStepDefault[Val.time, 1]\r
1609 \r
1610       Second VarId "=" T3:StringIdentifier "." T3S:StringIdentifier ","\r
1611                                                        << _STRCAT(&VarIdStr[2], T3->getText()); _STRCAT(&VarIdStr[2], "."); _STRCAT(&VarIdStr[2], T3S->getText()); >>\r
1612       Prompt "=" "STRING_TOKEN" "\(" SP:Number "\)" ","\r
1613       Help   "=" "STRING_TOKEN" "\(" SH:Number "\)" ","\r
1614       minMaxTimeStepDefault[Val.time, 2]\r
1615                                                        <<\r
1616                                                           mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);\r
1617                                                           TObj.SetQuestionId (QId);\r
1618                                                           TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);\r
1619                                                                                                                   TObj.SetPrompt (_STOSID(HP->getText()));\r
1620                                                                                                                   TObj.SetHelp (_STOSID(HH->getText()));\r
1621                                                                                                                   if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }\r
1622                                                        >>\r
1623                                                        << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val);} >>\r
1624     )\r
1625   )\r
1626   E:EndTime                                            << CRT_END_OP (E); >>\r
1627   ";"\r
1628   ;\r
1629 \r
1630 minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :\r
1631   Minimum   "=" Number ","\r
1632   Maximum   "=" Number ","\r
1633   { "step"    "=" Number "," }\r
1634   {\r
1635     "default" "=" N:Number ","                         <<\r
1636                                                           switch (KeyValue) {\r
1637                                                           case 0: T.Hour   = _STOU8(N->getText()); break;\r
1638                                                           case 1: T.Minute = _STOU8(N->getText()); break;\r
1639                                                           case 2: T.Second = _STOU8(N->getText()); break;\r
1640                                                                                                                   }\r
1641                                                        >>\r
1642   }\r
1643   ;\r
1644 \r
1645 vfrTimeFlags [CIfrTime & TObj, UINT32 LineNum] :\r
1646   << UINT8 LFlags = 0; >>\r
1647   timeFlagsField[LFlags] ( "\|" timeFlagsField[LFlags] )*\r
1648                                                        << _PCATCH(TObj.SetFlags(EFI_IFR_QUESTION_FLAG_DEFAULT, LFlags), LineNum); >>\r
1649   ;\r
1650 \r
1651 timeFlagsField [UINT8 & Flags] :\r
1652     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
1653   | "HOUR_SUPPRESS"                                    << $Flags |= 0x01; >>\r
1654   | "MINUTE_SUPPRESS"                                  << $Flags |= 0x02; >>\r
1655   | "SECOND_SUPPRESS"                                  << $Flags |= 0x04; >>\r
1656   | "STORAGE_NORMAL"                                   << $Flags |= 0x00; >>\r
1657   | "STORAGE_TIME"                                     << $Flags |= 0x10; >>\r
1658   | "STORAGE_WAKEUP"                                   << $Flags |= 0x20; >>\r
1659   ;\r
1660 \r
1661 vfrStatementQuestionTag :\r
1662   vfrStatementStatTag ","       |\r
1663   vfrStatementInconsistentIf    |\r
1664   vfrStatementNoSubmitIf        |\r
1665   vfrStatementDisableIfQuest    |\r
1666   vfrStatementRefresh           |\r
1667   vfrStatementVarstoreDevice\r
1668   ;\r
1669 \r
1670 vfrStatementQuestionTagList :\r
1671   ( vfrStatementQuestionTag )*\r
1672   ;\r
1673 \r
1674 vfrStatementQuestionOptionTag :\r
1675   vfrStatementSuppressIfQuest   |\r
1676   vfrStatementValue             |\r
1677   vfrStatementDefault           |\r
1678   vfrStatementOptions\r
1679   ;\r
1680 \r
1681 vfrStatementQuestionOptionList :\r
1682   (\r
1683     vfrStatementQuestionTag     |\r
1684     vfrStatementQuestionOptionTag\r
1685   )*\r
1686   ;\r
1687 \r
1688 vfrStatementStatList :\r
1689   vfrStatementStat                        |\r
1690   vfrStatementQuestions                   |\r
1691   vfrStatementConditional                 |\r
1692   // Just for framework vfr compatibility\r
1693   vfrStatementLabel\r
1694   //vfrStatementInvalid\r
1695   ;\r
1696 \r
1697 vfrStatementDisableIfStat :\r
1698   << CIfrDisableIf DIObj; >>\r
1699   L:DisableIf                                          << DIObj.SetLineNo(L->getLine()); >>\r
1700   vfrStatementExpression[0] ";"\r
1701   ( vfrStatementStatList )*\r
1702   E:EndIf                                              << CRT_END_OP (E); >>\r
1703   ";"\r
1704   ;\r
1705 \r
1706 vfrStatementSuppressIfStat :\r
1707   << CIfrSuppressIf SIObj; >>\r
1708   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
1709   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
1710   vfrStatementExpression[0] ";"\r
1711   ( vfrStatementStatList )*\r
1712   E:EndIf                                              << CRT_END_OP (E); >>\r
1713   ";"\r
1714   ;\r
1715 \r
1716 vfrStatementGrayOutIfStat :\r
1717   << CIfrGrayOutIf GOIObj; >>\r
1718   L:GrayOutIf                                          << GOIObj.SetLineNo(L->getLine()); >>\r
1719   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
1720   vfrStatementExpression[0]\r
1721   ";"\r
1722   ( vfrStatementStatList )*\r
1723   E:EndIf                                              << CRT_END_OP (E); >>\r
1724   ";"\r
1725   ;\r
1726 \r
1727 vfrImageTag :\r
1728   << CIfrImage IObj; >>\r
1729   L:Image "=" "IMAGE_TOKEN" "\(" S1:Number "\)"        << IObj.SetImageId (_STOSID(S1->getText())); IObj.SetLineNo(L->getLine()); >>\r
1730   ;\r
1731 \r
1732 vfrLockedTag :\r
1733   << CIfrLocked LObj; >>\r
1734   L:Locked                                             << LObj.SetLineNo(L->getLine()); >>\r
1735   ;\r
1736 \r
1737 vfrStatementStatTag :\r
1738   vfrImageTag  |\r
1739   vfrLockedTag\r
1740   ;\r
1741 \r
1742 vfrStatementStatTagList :\r
1743   vfrStatementStatTag ( "," vfrStatementStatTag )*\r
1744   ;\r
1745 \r
1746 vfrStatementImage :\r
1747   vfrImageTag\r
1748   ";"\r
1749   ;\r
1750 \r
1751 vfrStatementLocked :\r
1752   vfrLockedTag\r
1753   ";"\r
1754   ;\r
1755 \r
1756 vfrStatementInconsistentIf :\r
1757   << CIfrInconsistentIf IIObj; >>\r
1758   L:InconsistentIf                                     << IIObj.SetLineNo(L->getLine()); >>\r
1759   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << IIObj.SetError (_STOSID(S->getText())); >>\r
1760   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
1761   vfrStatementExpression[0]\r
1762   E:EndIf                                              << CRT_END_OP (E); >>\r
1763   ;\r
1764 \r
1765 vfrStatementNoSubmitIf :\r
1766   << CIfrNoSubmitIf NSIObj; >>\r
1767   L:NoSubmitIf                                         << NSIObj.SetLineNo(L->getLine()); >>\r
1768   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","     << NSIObj.SetError (_STOSID(S->getText())); >>\r
1769   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
1770   vfrStatementExpression[0]\r
1771   E:EndIf                                              << CRT_END_OP (E); >>\r
1772   ;\r
1773 \r
1774 vfrStatementDisableIfQuest :\r
1775   << CIfrDisableIf DIObj; >>\r
1776   L:DisableIf                                          << DIObj.SetLineNo(L->getLine()); >>\r
1777   vfrStatementExpression[0] ";"\r
1778   vfrStatementQuestionOptionList\r
1779   E:EndIf                                              << CRT_END_OP (E); >>\r
1780   ;\r
1781 \r
1782 vfrStatementRefresh :\r
1783   << CIfrRefresh RObj; >>\r
1784   L:Refresh                                            << RObj.SetLineNo(L->getLine()); >>\r
1785   Interval "=" I:Number                                << RObj.SetRefreshInterval (_STOU8(I->getText())); >>\r
1786   ;\r
1787 \r
1788 vfrStatementVarstoreDevice :\r
1789   << CIfrVarStoreDevice VDObj; >>\r
1790   L:VarstoreDevice                                     << VDObj.SetLineNo(L->getLine()); >>\r
1791   "=" "STRING_TOKEN" "\(" S:Number "\)" ","            << VDObj.SetDevicePath (_STOSID(S->getText())); >>\r
1792   ;\r
1793 \r
1794 vfrStatementSuppressIfQuest :\r
1795   << CIfrSuppressIf SIObj; >>\r
1796   L:SuppressIf                                         << SIObj.SetLineNo(L->getLine()); >>\r
1797   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
1798   vfrStatementExpression[0] ";"\r
1799   vfrStatementQuestionOptionList\r
1800   E:EndIf                                              << CRT_END_OP (E); >>\r
1801   ;\r
1802 \r
1803 vfrStatementOptions :\r
1804   vfrStatementOneOfOption\r
1805   ;\r
1806 \r
1807 vfrStatementOneOfOption :\r
1808   <<\r
1809      EFI_IFR_TYPE_VALUE Val;\r
1810      CIfrOneOfOption    OOOObj;\r
1811      CHAR8              *VarStoreName = NULL;\r
1812 \r
1813   >>\r
1814   L:Option                                             << OOOObj.SetLineNo(L->getLine()); >>\r
1815   Text  "=" "STRING_TOKEN" "\(" S:Number "\)" ","      << OOOObj.SetOption (_STOSID(S->getText())); >>\r
1816   Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","    << OOOObj.SetType (_GET_CURRQEST_DATATYPE()); OOOObj.SetValue (Val); >>\r
1817   F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]\r
1818                                                        <<\r
1819                                                           if (OOOObj.GetFlags () & 0x10) {\r
1820                                                             _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());\r
1821                                                             _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (\r
1822                                                                                                                                                     EFI_HII_DEFAULT_CLASS_STANDARD,\r
1823                                                                                                                                                                         _GET_CURRQEST_VARTINFO(),\r
1824                                                                                                                                                                         VarStoreName,\r
1825                                                                                                                                                                     _GET_CURRQEST_DATATYPE (),\r
1826                                                                                                                                                                         Val\r
1827                                                                                                                                                                         ), L->getLine());\r
1828                                                           }\r
1829                                                        >>\r
1830   (\r
1831     "," vfrImageTag                                    << OOOObj.SetScope (1); CIfrEnd EOOOObj; >>\r
1832   )*\r
1833   ";"\r
1834   ;\r
1835 \r
1836 vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :\r
1837   <<\r
1838      UINT8 LFlags = _GET_CURRQEST_DATATYPE();\r
1839      UINT8 HFlags = 0;\r
1840   >>\r
1841   oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*\r
1842                                                        << _PCATCH(gCurrentQuestion->SetFlags(HFlags), LineNum); >>\r
1843                                                        << _PCATCH(OOOObj.SetFlags(LFlags), LineNum); >>\r
1844   ;\r
1845 \r
1846 oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] :\r
1847     N:Number                                           << $LFlags |= _STOU8(N->getText()); >>\r
1848   | "OPTION_DEFAULT"                                   << $LFlags |= 0x10; >>\r
1849   | "OPTION_DEFAULT_MFG"                               << $LFlags |= 0x20; >>\r
1850   | InteractiveFlag                                    << $HFlags |= 0x04; >>\r
1851   | NVAccessFlag                                       << $HFlags |= 0x08; >>\r
1852   | ResetRequiredFlag                                  << $HFlags |= 0x10; >>\r
1853   | LateCheckFlag                                      << $HFlags |= 0x20; >>\r
1854   | ManufacturingFlag                                  << $LFlags |= 0x20; >>\r
1855   | DefaultFlag                                        << $LFlags |= 0x10; >>\r
1856   ;\r
1857 \r
1858 vfrStatementLabel :\r
1859   << CIfrLabel LObj; >>\r
1860   L:Label                                              << LObj.SetLineNo(L->getLine()); >>\r
1861   N:Number                                             << LObj.SetNumber (_STOU16(N->getText())); >>\r
1862   ";"\r
1863   ;\r
1864 \r
1865 vfrStatementBanner :\r
1866   << CIfrBanner BObj; >>\r
1867   B:Banner { "," }                                     << BObj.SetLineNo(B->getLine()); >>\r
1868   Title "=" "STRING_TOKEN" "\(" S:Number "\)" ","      << BObj.SetTitle (_STOSID(S->getText())); >>\r
1869   (\r
1870     (\r
1871       Line L:Number ","                                << BObj.SetLine (_STOU16(L->getText())); >>\r
1872       Align\r
1873       (\r
1874           Left                                         << BObj.SetAlign (0); >>\r
1875         | Center                                       << BObj.SetAlign (1); >>\r
1876         | Right                                        << BObj.SetAlign (2); >>\r
1877       ) ";"\r
1878     )\r
1879     |\r
1880     (\r
1881       Timeout "=" T:Number ";"                         << {CIfrTimeout TObj(_STOU16(T->getText()));} >>\r
1882     )\r
1883   )\r
1884   ;\r
1885 \r
1886 //******************************************************************************\r
1887 //\r
1888 // keep some syntax for compatibility but not generate any IFR object\r
1889 //\r
1890 vfrStatementInvalidHidden :\r
1891   Hidden\r
1892   Value "=" Number ","\r
1893   Key "=" Number ";"\r
1894   ;\r
1895 \r
1896 vfrStatementInvalidInconsistentIf :\r
1897   InconsistentIf\r
1898   Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","\r
1899   { FLAGS "=" flagsField ( "\|" flagsField )* "," }\r
1900   vfrStatementExpression[0]\r
1901   EndIf\r
1902   ";"\r
1903   ;\r
1904 \r
1905 vfrStatementInvalidInventory :\r
1906   Inventory\r
1907   Help "=" "STRING_TOKEN" "\(" Number "\)" ","\r
1908   Text "=" "STRING_TOKEN" "\(" Number "\)" ","\r
1909   {\r
1910     Text  "=" "STRING_TOKEN" "\(" Number "\)"\r
1911   }\r
1912   ";"\r
1913   ;\r
1914 \r
1915 vfrStatementInvalidSaveRestoreDefaults :\r
1916   (Save | Restore)\r
1917   Defaults ","\r
1918   FormId "=" Number  ","\r
1919   Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","\r
1920   Help   "=" "STRING_TOKEN" "\(" Number "\)"\r
1921   { "," FLAGS "=" flagsField ( "\|" flagsField )* }\r
1922   { "," Key   "=" Number }\r
1923   ";"\r
1924   ;\r
1925 \r
1926 //******************************************************************************\r
1927 //\r
1928 // The syntax of expression\r
1929 //\r
1930 #token Dup("dup")                               "dup"\r
1931 #token VarEqVal("vareqval")                     "vareqval"\r
1932 #token Var("var")                               "var"\r
1933 #token IdEqVal("ideqval")                       "ideqval"\r
1934 #token IdEqId("ideqid")                         "ideqid"\r
1935 #token IdEqValList("ideqvallist")               "ideqvallist"\r
1936 #token QuestionRef("questionref")               "questionref"\r
1937 #token RuleRef("ruleref")                       "ruleref"\r
1938 #token StringRef("stringref")                   "stringref"\r
1939 #token PushThis("pushthis")                     "pushthis"\r
1940 #token True("TRUE")                             "TRUE"\r
1941 #token False("FALSE")                           "FALSE"\r
1942 #token One("ONE")                               "ONE"\r
1943 #token Ones("ONES")                             "ONES"\r
1944 #token Zero("ZERO")                             "ZERO"\r
1945 #token Undefined("UNDEFINED")                   "UNDEFINED"\r
1946 #token Version("VERSOPM")                       "VERSION"\r
1947 #token Length("length")                         "length"\r
1948 #token AND("AND")                               "AND"\r
1949 #token OR("OR")                                 "OR"\r
1950 #token NOT("NOT")                               "NOT"\r
1951 #token BitWiseNot("~")                          "\~"\r
1952 #token BoolVal("boolval")                       "boolval"\r
1953 #token StringVal("stringval")                   "stringval"\r
1954 #token UnIntVal("unintval")                     "unintval"\r
1955 #token ToUpper("toupper")                       "toupper"\r
1956 #token ToLower("tolower")                       "tolower"\r
1957 #token Match("match")                           "match"\r
1958 #token Catenate("catenate")                     "catenate"\r
1959 #token QuestionRefVal("questionrefval")         "questionrefval"\r
1960 #token StringRefVal("stringrefval")             "stringrefval"\r
1961 \r
1962 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :\r
1963                                                                                                            << if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>\r
1964   andTerm[$RootLevel, $ExpOpCount]\r
1965   (\r
1966     L:OR andTerm[$RootLevel, $ExpOpCount]              << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>\r
1967   )*\r
1968                                                        << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; } >>\r
1969   ;\r
1970 \r
1971 andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
1972   bitwiseorTerm[$RootLevel, $ExpOpCount]\r
1973   (\r
1974     L:AND bitwiseorTerm [$RootLevel, $ExpOpCount]       << $ExpOpCount++; CIfrAnd AObj(L->getLine()); >>\r
1975   )*\r
1976   ;\r
1977 \r
1978 bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
1979   bitwiseandTerm[$RootLevel, $ExpOpCount]\r
1980   (\r
1981     L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount]      << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>\r
1982   )*\r
1983   ;\r
1984 \r
1985 bitwiseandTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
1986   equalTerm[$RootLevel, $ExpOpCount]\r
1987   (\r
1988     L:"&" equalTerm[$RootLevel, $ExpOpCount]            << $ExpOpCount++; CIfrBitWiseAnd BWAObj(L->getLine()); >>\r
1989   )*\r
1990   ;\r
1991 \r
1992 equalTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
1993   compareTerm[$RootLevel, $ExpOpCount]\r
1994   (\r
1995     (\r
1996       L1:"==" compareTerm[$RootLevel, $ExpOpCount]      << $ExpOpCount++; CIfrEqual EObj(L1->getLine()); >>\r
1997     )\r
1998     |\r
1999     (\r
2000       L2:"!=" compareTerm[$RootLevel, $ExpOpCount]      << $ExpOpCount++; CIfrNotEqual NEObj(L2->getLine()); >>\r
2001     )\r
2002   )*\r
2003   ;\r
2004 \r
2005 compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2006   shiftTerm[$RootLevel, $ExpOpCount]\r
2007   (\r
2008     (\r
2009       L1:"<" shiftTerm[$RootLevel, $ExpOpCount]         << $ExpOpCount++; CIfrLessThan LTObj(L1->getLine()); >>\r
2010     )\r
2011     |\r
2012     (\r
2013       L2:"<=" shiftTerm[$RootLevel, $ExpOpCount]        << $ExpOpCount++; CIfrLessEqual LEObj(L2->getLine()); >>\r
2014     )\r
2015     |\r
2016     (\r
2017       L3:">" shiftTerm[$RootLevel, $ExpOpCount]         << $ExpOpCount++; CIfrGreaterThan GTObj(L3->getLine()); >>\r
2018     )\r
2019     |\r
2020     (\r
2021       L4:">=" shiftTerm[$RootLevel, $ExpOpCount]        << $ExpOpCount++; CIfrGreaterEqual GEObj(L4->getLine()); >>\r
2022     )\r
2023   )*\r
2024   ;\r
2025 \r
2026 shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2027   addMinusTerm[$RootLevel, $ExpOpCount]\r
2028   (\r
2029     (\r
2030       L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount]    << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>\r
2031     )\r
2032     |\r
2033     (\r
2034       L2:"\>>" addMinusTerm[$RootLevel, $ExpOpCount]    << $ExpOpCount++; CIfrShiftRight SRObj(L2->getLine()); >>\r
2035     )\r
2036   )*\r
2037   ;\r
2038 \r
2039 addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2040   multdivmodTerm[$RootLevel, $ExpOpCount]\r
2041   (\r
2042     (\r
2043       L1:"\+" multdivmodTerm[$RootLevel, $ExpOpCount]   << $ExpOpCount++; CIfrAdd AObj(L1->getLine()); >>\r
2044     )\r
2045     |\r
2046     (\r
2047       L2:"\-" multdivmodTerm[$RootLevel, $ExpOpCount]   << $ExpOpCount++; CIfrSubtract SObj(L2->getLine()); >>\r
2048     )\r
2049   )*\r
2050   ;\r
2051 \r
2052 multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2053   castTerm[$RootLevel, $ExpOpCount]\r
2054   (\r
2055     (\r
2056       L1:"\*" castTerm[$RootLevel, $ExpOpCount]         << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>\r
2057     )\r
2058     |\r
2059     (\r
2060       L2:"/" castTerm[$RootLevel, $ExpOpCount]          << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>\r
2061     )\r
2062     |\r
2063     (\r
2064       L3:"%" castTerm[$RootLevel, $ExpOpCount]          << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>\r
2065     )\r
2066   )*\r
2067   ;\r
2068 \r
2069 castTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2070   << UINT8 CastType = 0xFF; >>\r
2071   (\r
2072     L:"\("\r
2073     (\r
2074         Boolean                                         << CastType = 0; >>\r
2075       | Uint64                                          << CastType = 1; >>\r
2076       | Uint32                                          << CastType = 1; >>\r
2077       | Uint16                                          << CastType = 1; >>\r
2078       | Uint8                                           << CastType = 1; >>\r
2079     )\r
2080     "\)"\r
2081   )*\r
2082   atomTerm[$RootLevel, $ExpOpCount]\r
2083                                                         <<\r
2084                                                            switch (CastType) {\r
2085                                                            case 0: { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } break;\r
2086                                                            case 1: { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } break;\r
2087                                                            }\r
2088                                                                                                                 >>\r
2089   ;\r
2090 \r
2091 atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2092     vfrExpressionCatenate[$RootLevel, $ExpOpCount]\r
2093   | vfrExpressionMatch[$RootLevel, $ExpOpCount]\r
2094   | vfrExpressionParen[$RootLevel, $ExpOpCount]\r
2095   | vfrExpressionBuildInFunction[$RootLevel, $ExpOpCount]\r
2096   | vfrExpressionConstant[$RootLevel, $ExpOpCount]\r
2097   | vfrExpressionUnaryOp[$RootLevel, $ExpOpCount]\r
2098   | vfrExpressionTernaryOp[$RootLevel, $ExpOpCount]\r
2099   | (\r
2100       L:NOT\r
2101       atomTerm[$RootLevel, $ExpOpCount]                 << { CIfrNot NObj(L->getLine()); $ExpOpCount++; } >>\r
2102     )\r
2103   ;\r
2104 \r
2105 vfrExpressionCatenate [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2106   L:Catenate\r
2107   "\("\r
2108   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2109   ","\r
2110   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2111   "\)"                                                 << { CIfrCatenate CObj(L->getLine()); $ExpOpCount++; } >>\r
2112   ;\r
2113 \r
2114 vfrExpressionMatch [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2115   L:Match\r
2116   "\("\r
2117   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2118   ","\r
2119   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2120   "\)"                                                 << { CIfrMatch MObj(L->getLine()); $ExpOpCount++; } >>\r
2121   ;\r
2122 \r
2123 vfrExpressionParen [UINT32 & RootLevel, UINT32 & ExpOpCount]:\r
2124   "\("\r
2125   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2126   "\)"\r
2127   ;\r
2128 \r
2129 vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2130     dupExp[$RootLevel, $ExpOpCount]\r
2131   | ideqvalExp[$RootLevel, $ExpOpCount]\r
2132   | ideqidExp[$RootLevel, $ExpOpCount]\r
2133   | ideqvallistExp[$RootLevel, $ExpOpCount]\r
2134   | questionref13Exp[$RootLevel, $ExpOpCount]\r
2135   | rulerefExp[$RootLevel, $ExpOpCount]\r
2136   | stringref1Exp[$RootLevel, $ExpOpCount]\r
2137   | pushthisExp[$RootLevel, $ExpOpCount]\r
2138   ;\r
2139 \r
2140 dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2141   L:Dup                                                << { CIfrDup DObj(L->getLine()); _SAVE_OPHDR_COND(DObj, ($ExpOpCount == 0)); $ExpOpCount++; } >>\r
2142   ;\r
2143 \r
2144 ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2145   <<\r
2146      EFI_QUESTION_ID QId;\r
2147      UINT32          Mask;\r
2148      UINT16          ConstVal;\r
2149      CHAR8           *VarIdStr;\r
2150      UINT32          LineNo;\r
2151   >>\r
2152   L:IdEqVal\r
2153   vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]\r
2154   (\r
2155     (\r
2156       "=="\r
2157       V1:Number                                        << ConstVal = _STOU16(V1->getText()); >>\r
2158                                                        <<\r
2159                                                                                                               if (Mask == 0) {\r
2160                                                                                                                         CIfrEqIdVal EIVObj (L->getLine());\r
2161                                                                                                                         _SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));\r
2162                                                                                                                         EIVObj.SetQuestionId (QId, VarIdStr, LineNo);\r
2163                                                                                                                         EIVObj.SetValue (ConstVal);\r
2164                                                                                                                         $ExpOpCount++;\r
2165                                                                                                                   } else {\r
2166                                                                                                                         IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);\r
2167                                                                                                                   }\r
2168                                                                                                            >>\r
2169     )\r
2170     |\r
2171     (\r
2172       "<="\r
2173       V2:Number                                        << ConstVal = _STOU16(V2->getText()); >>\r
2174                                                        << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_EQUAL); >>\r
2175     )\r
2176     |\r
2177     (\r
2178       "<"\r
2179       V3:Number                                        << ConstVal = _STOU16(V3->getText()); >>\r
2180                                                        << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, LESS_THAN); >>\r
2181     )\r
2182     |\r
2183     (\r
2184       ">="\r
2185       V4:Number                                        << ConstVal = _STOU16(V4->getText()); >>\r
2186                                                        << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_EQUAL); >>\r
2187     )\r
2188     |\r
2189     (\r
2190       ">"\r
2191       V5:Number                                        << ConstVal = _STOU16(V5->getText()); >>\r
2192                                                        << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >>\r
2193     )\r
2194   )\r
2195   ;\r
2196 \r
2197 ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2198   <<\r
2199      EFI_QUESTION_ID QId[2];\r
2200      UINT32          Mask[2];\r
2201      CHAR8           *VarIdStr[2];\r
2202      UINT32          LineNo[2];\r
2203   >>\r
2204   L:IdEqId\r
2205   vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]\r
2206   (\r
2207     (\r
2208       "=="\r
2209       vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]\r
2210                                                        <<\r
2211                                                                                                               if (Mask[0] & Mask[1]) {\r
2212                                                                                                                         IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], EQUAL);\r
2213                                                                                                                   } else {\r
2214                                                             CIfrEqIdId      EIIObj(L->getLine());\r
2215                                                                                                                         _SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));\r
2216                                                             EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);\r
2217                                                                                                                         EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);\r
2218                                                                                                                         $ExpOpCount++;\r
2219                                                                                                                   }\r
2220                                                                                                            >>\r
2221     )\r
2222     |\r
2223     (\r
2224       "<="\r
2225       vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]\r
2226                                                        << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_EQUAL); >>\r
2227     )\r
2228     |\r
2229     (\r
2230       "<"\r
2231       vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]\r
2232                                                        << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], LESS_THAN); >>\r
2233     )\r
2234     |\r
2235     (\r
2236       ">="\r
2237       vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]\r
2238                                                        << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_EQUAL); >>\r
2239     )\r
2240     |\r
2241     (\r
2242       ">"\r
2243       vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]\r
2244                                                        << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_THAN); >>\r
2245     )\r
2246   )\r
2247   ;\r
2248 \r
2249 ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2250   <<\r
2251      UINT16          ListLen = 0;\r
2252      EFI_QUESTION_ID QId;\r
2253      UINT32          Mask;\r
2254      UINT16          ValueList[EFI_IFR_MAX_LENGTH] = {0,};\r
2255      CHAR8           *VarIdStr;\r
2256      UINT32          LineNo;\r
2257   >>\r
2258   L:IdEqValList\r
2259   vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]\r
2260   "=="\r
2261   (\r
2262     V:Number                                           << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>\r
2263   )+\r
2264                                                        <<\r
2265                                                                                                               if (Mask != 0) {\r
2266                                                             IdEqListDoSpecial ($ExpOpCount, LineNo, QId, VarIdStr, Mask, ListLen, ValueList);\r
2267                                                                                                                   } else {\r
2268                                                                                             UINT16       Index;\r
2269                                                             CIfrEqIdList EILObj(L->getLine());\r
2270                                                                                                                         _SAVE_OPHDR_COND (EILObj, ($ExpOpCount == 0));\r
2271                                                             EILObj.SetQuestionId (QId, VarIdStr, LineNo);\r
2272                                                                                                                         EILObj.SetListLength (ListLen);\r
2273                                                                                                                         for (Index = 0; Index < ListLen; Index++) {\r
2274                                                                                                                           EILObj.SetValueList (Index, ValueList[Index]);\r
2275                                                                                                                         }\r
2276                                                                                                                         $ExpOpCount++;\r
2277                                                                                                                   }\r
2278                                                                                                            >>\r
2279   ;\r
2280 \r
2281 vareqvarlExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2282   L:VarEqVal Var "\(" V1:Number "\)" "==" V2:Number    <<\r
2283                                                           {\r
2284                                                             CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());\r
2285                                                             _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));\r
2286                                                             U64Obj1.SetValue (_STOU64(V1->getText()));\r
2287                                                             U64Obj2.SetValue (_STOU64(V2->getText()));\r
2288                                                           }\r
2289                                                        >>\r
2290                                                        << {CIfrEqual EObj(L->getLine()); } >>\r
2291                                                                                                            << $ExpOpCount += 3; >>\r
2292   ;\r
2293 \r
2294 questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2295   <<\r
2296      UINT8           Type = 0x1;\r
2297      EFI_STRING_ID   DevPath;\r
2298      EFI_GUID        Guid;\r
2299          EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;\r
2300      UINT32          BitMask;\r
2301      CHAR8           *QName = NULL;\r
2302      UINT32          LineNo = 0;\r
2303   >>\r
2304   L:QuestionRef\r
2305   (\r
2306     (\r
2307                                                        << Type = 0x3; >>\r
2308       {\r
2309         Path "=" "STRING_TOKEN" "\(" S:Number "\)"     << Type = 0x4; DevPath = _STOSID(S->getText()); >>\r
2310       }\r
2311       {\r
2312         Uuid "=" guidDefinition[Guid]                  << Type = 0x5; >>\r
2313       }\r
2314     )\r
2315     |\r
2316     (\r
2317       "\("\r
2318           (\r
2319           QN:StringIdentifier                          <<\r
2320                                                           QName  = QN->getText();\r
2321                                                                                                                   LineNo = QN->getLine();\r
2322                                                           mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask);\r
2323                                                        >>\r
2324         | ID:Number                                    << QId = _STOQID(ID->getText()); >>\r
2325       )\r
2326       "\)"\r
2327     )\r
2328   )\r
2329                                                        <<\r
2330                                                           switch (Type) {\r
2331                                                           case 0x1: {CIfrQuestionRef1 QR1Obj(L->getLine()); _SAVE_OPHDR_COND (QR1Obj, ($ExpOpCount == 0)); QR1Obj.SetQuestionId (QId, QName, LineNo); break;}\r
2332                                                           case 0x3: {CIfrQuestionRef3 QR3Obj(L->getLine()); _SAVE_OPHDR_COND (QR3Obj, ($ExpOpCount == 0)); break;}\r
2333                                                           case 0x4: {CIfrQuestionRef3_2 QR3_2Obj(L->getLine()); _SAVE_OPHDR_COND (QR3_2Obj, ($ExpOpCount == 0)); QR3_2Obj.SetDevicePath (DevPath); break;}\r
2334                                                           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
2335                                                           }\r
2336                                                           $ExpOpCount++;\r
2337                                                        >>\r
2338   ;\r
2339 \r
2340 rulerefExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2341   L:RuleRef\r
2342   "\(" RN:StringIdentifier "\)"                        << { CIfrRuleRef RRObj(L->getLine()); _SAVE_OPHDR_COND (RRObj, ($ExpOpCount == 0)); RRObj.SetRuleId (mCVfrRulesDB.GetRuleId (RN->getText())); } $ExpOpCount++; >>\r
2343   ;\r
2344 \r
2345 //******************************************************\r
2346 // PARSE:\r
2347 //   stringref (STR_FORM_SET_TITLE)\r
2348 //\r
2349 stringref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2350   L:StringRef\r
2351   "\(" S:Number "\)"                                   << { CIfrStringRef1 SR1Obj(L->getLine()); _SAVE_OPHDR_COND (SR1Obj, ($ExpOpCount == 0)); SR1Obj.SetStringId (_STOSID(S->getText())); $ExpOpCount++; } >>\r
2352   ;\r
2353 \r
2354 pushthisExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2355   L:PushThis                                           << { CIfrThis TObj(L->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0)); $ExpOpCount++; } >>\r
2356   ;\r
2357 \r
2358 vfrExpressionConstant[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2359     L1:True                                            << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2360   | L2:False                                           << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2361   | L3:One                                             << CIfrOne OObj(L3->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2362   | L4:Ones                                            << CIfrOnes OObj(L4->getLine()); _SAVE_OPHDR_COND (OObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2363   | L5:Zero                                            << CIfrZero ZObj(L5->getLine()); _SAVE_OPHDR_COND (ZObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2364   | L6:Undefined                                       << CIfrUndefined UObj(L6->getLine()); _SAVE_OPHDR_COND (UObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2365   | L7:Version                                         << CIfrVersion VObj(L7->getLine()); _SAVE_OPHDR_COND (VObj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2366   | V:Number                                           << CIfrUint64 U64Obj(V->getLine()); U64Obj.SetValue (_STOU64(V->getText())); _SAVE_OPHDR_COND (U64Obj, ($ExpOpCount == 0)); $ExpOpCount++; >>\r
2367   ;\r
2368 \r
2369 vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2370     lengthExp[$RootLevel, $ExpOpCount]\r
2371   | bitwisenotExp[$RootLevel, $ExpOpCount]\r
2372   | question2refExp[$RootLevel, $ExpOpCount]\r
2373   | stringref2Exp[$RootLevel, $ExpOpCount]\r
2374   | toboolExp[$RootLevel, $ExpOpCount]\r
2375   | unintExp[$RootLevel, $ExpOpCount]\r
2376   | toupperExp[$RootLevel, $ExpOpCount]\r
2377   | tolwerExp[$RootLevel, $ExpOpCount]\r
2378   ;\r
2379 \r
2380 lengthExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2381   L:Length\r
2382   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2383                                                        << { CIfrLength LObj(L->getLine()); $ExpOpCount++; } >>\r
2384   ;\r
2385 \r
2386 bitwisenotExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2387   L:BitWiseNot\r
2388   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2389                                                        << { CIfrBitWiseNot BWNObj(L->getLine()); $ExpOpCount++; } >>\r
2390   ;\r
2391 \r
2392 question2refExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2393   L:QuestionRefVal\r
2394   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2395                                                        << { CIfrQuestionRef2 QR2Obj(L->getLine()); $ExpOpCount++; } >>\r
2396   ;\r
2397 \r
2398 stringref2Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2399   L:StringRefVal\r
2400   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2401                                                        << { CIfrStringRef2 SR2Obj(L->getLine()); $ExpOpCount++; } >>\r
2402   ;\r
2403 \r
2404 toboolExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2405   L:BoolVal\r
2406   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2407                                                        << { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } >>\r
2408   ;\r
2409 \r
2410 tostringExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2411   << UINT8 Fmt = 0; >>\r
2412   L:StringVal\r
2413   {\r
2414     Format "=" F:Number ","                            << Fmt = _STOU8(F->getText()); >>\r
2415   }\r
2416   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2417                                                        << { CIfrToString TSObj(L->getLine()); TSObj.SetFormat (Fmt); $ExpOpCount++; } >>\r
2418   ;\r
2419 \r
2420 unintExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2421   L:UnIntVal\r
2422   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2423                                                        << { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } >>\r
2424   ;\r
2425 \r
2426 toupperExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2427   L:ToUpper\r
2428   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2429                                                        << { CIfrToUpper TUObj(L->getLine()); $ExpOpCount++; } >>\r
2430   ;\r
2431 \r
2432 tolwerExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2433   L:ToLower\r
2434   "\(" vfrStatementExpression[$RootLevel + 1, $ExpOpCount] "\)"\r
2435                                                        << { CIfrToLower TLObj(L->getLine()); $ExpOpCount++; } >>\r
2436   ;\r
2437 \r
2438 vfrExpressionTernaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2439     conditionalExp[$RootLevel, $ExpOpCount]\r
2440   | findExp[$RootLevel, $ExpOpCount]\r
2441   | midExp[$RootLevel, $ExpOpCount]\r
2442   | tokenExp[$RootLevel, $ExpOpCount]\r
2443   | spanExp[$RootLevel, $ExpOpCount]\r
2444   ;\r
2445 \r
2446 #token Cond("cond")                                    "cond"\r
2447 #token Find("find")                                    "find"\r
2448 #token Mid("mid")                                      "mid"\r
2449 #token Tok("token")                                    "token"\r
2450 #token Span("span")                                    "span"\r
2451 \r
2452 conditionalExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2453   L:Cond "\("\r
2454   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2455   "?"\r
2456   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2457   ":"\r
2458   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2459   "\)"                                                 << { CIfrConditional CObj(L->getLine()); $ExpOpCount++; } >>\r
2460   ;\r
2461 \r
2462 findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2463   << UINT8 Format; >>\r
2464   L:Find "\("\r
2465   findFormat[Format] ( "\|" findFormat[Format] )*\r
2466   ","\r
2467   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2468   ","\r
2469   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2470   ","\r
2471   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2472   "\)"                                                 << { CIfrFind FObj(L->getLine()); FObj.SetFormat (Format); $ExpOpCount++; } >>\r
2473   ;\r
2474 \r
2475 findFormat [UINT8 & Format] :\r
2476     "SENSITIVE"                                        << $Format = 0x00; >>\r
2477   | "INSENSITIVE"                                      << $Format = 0x01; >>\r
2478   ;\r
2479 \r
2480 midExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2481   L:Mid "\("\r
2482   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2483   ","\r
2484   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2485   ","\r
2486   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2487   "\)"                                                 << { CIfrMid MObj(L->getLine()); $ExpOpCount++; } >>\r
2488   ;\r
2489 \r
2490 tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2491   L:Tok "\("\r
2492   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2493   ","\r
2494   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2495   ","\r
2496   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2497   "\)"                                                 << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>\r
2498   ;\r
2499 \r
2500 spanExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :\r
2501   << UINT8 Flags = 0; >>\r
2502   S:Span "\("\r
2503   FLAGS "=" spanFlags[Flags] ( "\|" spanFlags[Flags] )*\r
2504   ","\r
2505   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2506   ","\r
2507   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2508   ","\r
2509   vfrStatementExpression[$RootLevel + 1, $ExpOpCount]\r
2510   "\)"                                                 << { CIfrSpan SObj(S->getLine()); SObj.SetFlags(Flags); $ExpOpCount++; } >>\r
2511   ;\r
2512 \r
2513 spanFlags [UINT8 & Flags] :\r
2514     N:Number                                           << $Flags |= _STOU8(N->getText()); >>\r
2515   | "LAST_NON_MATCH"                                   << $Flags |= 0x00; >>\r
2516   | "FIRST_NON_MATCH"                                  << $Flags |= 0x01; >>\r
2517   ;\r
2518 \r
2519 #token StringIdentifier("string identifier")    "[A-Za-z_][A-Za-z_0-9]*"\r
2520 #token Number("numeric value")                  "(0x[0-9A-Fa-f]+) | [0-9]+"\r
2521 \r
2522 //******************************************************************************\r
2523 //\r
2524 // Parser class definition.\r
2525 //\r
2526 class EfiVfrParser {\r
2527 <<\r
2528 private:\r
2529   UINT8               mParserStatus;\r
2530 \r
2531   CVfrDefaultStore    mCVfrDefaultStore;\r
2532   CVfrVarDataTypeDB   mCVfrVarDataTypeDB;\r
2533   CVfrDataStorage     mCVfrDataStorage;\r
2534   CVfrQuestionDB      mCVfrQuestionDB;\r
2535   CVfrRulesDB         mCVfrRulesDB;\r
2536 \r
2537   CIfrOpHeader        *mCIfrOpHdr;\r
2538   VOID                _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN);\r
2539   VOID                _CLEAR_SAVED_OPHDR (VOID);\r
2540   VOID                _SET_SAVED_OPHDR_SCOPE (VOID);\r
2541 \r
2542 \r
2543   EFI_VARSTORE_INFO   mCurrQestVarInfo;\r
2544 \r
2545   VOID                _CRT_OP (IN BOOLEAN);\r
2546 \r
2547   VOID                _SAVE_CURRQEST_VARINFO (IN EFI_VARSTORE_INFO &);\r
2548   EFI_VARSTORE_INFO & _GET_CURRQEST_VARTINFO (VOID);\r
2549 \r
2550   UINT8               _GET_CURRQEST_DATATYPE ();\r
2551   UINT32              _GET_CURRQEST_VARSIZE ();\r
2552 \r
2553 public:\r
2554   VOID                _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN CHAR8 *);\r
2555   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE);\r
2556   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);\r
2557   VOID                _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);\r
2558 \r
2559   VOID                syn     (ANTLRAbstractToken  *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);\r
2560 \r
2561   CHAR8*              TrimHex (IN CHAR8 *, OUT BOOLEAN *);\r
2562   UINT8               _STOU8  (IN CHAR8 *);\r
2563   UINT16              _STOU16 (IN CHAR8 *);\r
2564   UINT32              _STOU32 (IN CHAR8 *);\r
2565   UINT64              _STOU64 (IN CHAR8 *);\r
2566   EFI_HII_DATE        _STOD   (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *);\r
2567   EFI_HII_TIME        _STOT   (IN CHAR8 *, IN CHAR8 *, IN CHAR8 *);\r
2568 \r
2569   EFI_STRING_ID       _STOSID (IN CHAR8 *);\r
2570   EFI_FORM_ID         _STOFID (IN CHAR8 *);\r
2571   EFI_QUESTION_ID     _STOQID (IN CHAR8 *);\r
2572 \r
2573   VOID                _STRCAT (IN OUT CHAR8 **, IN CHAR8 *);\r
2574 \r
2575   VOID                _CRGUID (EFI_GUID *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *);\r
2576   VOID                _DeclareDefaultLinearVarStore (IN UINT32);\r
2577   VOID                _DeclareStandardDefaultStorage (IN UINT32);\r
2578 \r
2579 \r
2580   VOID                AssignQuestionKey (IN CIfrQuestionHeader &, IN ANTLRTokenPtr);\r
2581 \r
2582   VOID                ConvertIdExpr         (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32);\r
2583   VOID                IdEqValDoSpecial      (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN EFI_COMPARE_TYPE);\r
2584   VOID                IdEqIdDoSpecial       (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN EFI_COMPARE_TYPE);\r
2585   VOID                IdEqListDoSpecial     (IN UINT32 &, IN UINT32, IN EFI_QUESTION_ID, IN CHAR8 *, IN UINT32, IN UINT16, IN UINT16 *);\r
2586 >>\r
2587 }\r
2588 \r
2589 <<\r
2590 VOID\r
2591 EfiVfrParser::_SAVE_OPHDR_COND (\r
2592   IN CIfrOpHeader &OpHdr,\r
2593   IN BOOLEAN      Cond\r
2594   )\r
2595 {\r
2596   if (Cond == TRUE) {\r
2597 #ifdef VFREXP_DEBUG\r
2598     printf ("######_SAVE_OPHDR_COND\n");