1 NoEcho('
2 /******************************************************************************
3  *
4  * Module Name: aslrules.y - Main Bison/Yacc production rules
5  *
6  *****************************************************************************/
7 
8 /*
9  * Copyright (C) 2000 - 2015, Intel Corp.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions, and the following disclaimer,
17  *    without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  *    substantially similar to the "NO WARRANTY" disclaimer below
20  *    ("Disclaimer") and any redistribution must be conditioned upon
21  *    including a substantially similar Disclaimer requirement for further
22  *    binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  *    of any contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44 
45 ')
46 
47 /*******************************************************************************
48  *
49  * ASL Root and Secondary Terms
50  *
51  ******************************************************************************/
52 
53 /*
54  * Root term. Allow multiple #line directives before the definition block
55  * to handle output from preprocessors
56  */
57 AslCode
58     : DefinitionBlockList           {$<n>$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_ASL_CODE),1, $1);}
59     | error                         {YYABORT; $$ = NULL;}
60     ;
61 
62 
63 /*
64  * Note concerning support for "module-level code".
65  *
66  * ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control
67  * methods (the so-called module-level code.) This support was explicitly
68  * removed in ACPI 2.0, but this type of code continues to be created by
69  * BIOS vendors. In order to support the disassembly and recompilation of
70  * such code (and the porting of ASL code to iASL), iASL supports this
71  * code in violation of the current ACPI specification.
72  *
73  * The grammar change to support module-level code is to revert the
74  * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the
75  * original use of {TermList} instead (see below.) This allows the use
76  * of Type1 and Type2 opcodes at module level.
77  */
78 DefinitionBlockTerm
79     : PARSEOP_DEFINITION_BLOCK '('  {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);}
80         String ','
81         String ','
82         ByteConst ','
83         String ','
84         String ','
85         DWordConst
86         ')'                         {TrSetEndLineNumber ($<n>3);}
87             '{' TermList '}'        {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);}
88     ;
89 
90 DefinitionBlockList
91     : DefinitionBlockTerm
92     | DefinitionBlockTerm
93         DefinitionBlockList         {$$ = TrLinkPeerNodes (2, $1,$2);}
94     ;
95 
96 SuperName
97     : NameString                    {}
98     | ArgTerm                       {}
99     | LocalTerm                     {}
100     | DebugTerm                     {}
101     | Type6Opcode                   {}
102 
103 Target
104     :                               {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */
105     | ','                           {$$ = TrCreateNullTarget ();} /* Placeholder is a ZeroOp object */
106     | ',' SuperName                 {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);}
107     ;
108 
109 TermArg
110     : Type2Opcode                   {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
111     | DataObject                    {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
112     | NameString                    {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
113     | ArgTerm                       {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
114     | LocalTerm                     {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
115     ;
116 
117 /*
118  NOTE: Removed from TermArg due to reduce/reduce conflicts:
119     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
120     | Type2StringOpcode             {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
121     | Type2BufferOpcode             {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
122     | Type2BufferOrStringOpcode     {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
123 
124 */
125 
126 MethodInvocationTerm
127     : NameString '('                {TrUpdateNode (PARSEOP_METHODCALL, $1);}
128         ArgList ')'                 {$$ = TrLinkChildNode ($1,$4);}
129     ;
130 
131 /* OptionalCount must appear before ByteList or an incorrect reduction will result */
132 
133 OptionalCount
134     :                               {$$ = TrCreateLeafNode (PARSEOP_ONES);}       /* Placeholder is a OnesOp object */
135     | ','                           {$$ = TrCreateLeafNode (PARSEOP_ONES);}       /* Placeholder is a OnesOp object */
136     | ',' TermArg                   {$$ = $2;}
137     ;
138 
139 VarPackageLengthTerm
140     :                               {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);}
141     | TermArg                       {$$ = $1;}
142     ;
143 
144 
145 /******* List Terms **************************************************/
146 
147 ArgList
148     :                               {$$ = NULL;}
149     | TermArg
150     | ArgList ','                   /* Allows a trailing comma at list end */
151     | ArgList ','
152         TermArg                     {$$ = TrLinkPeerNode ($1,$3);}
153     ;
154 
155 ByteList
156     :                               {$$ = NULL;}
157     | ByteConstExpr
158     | ByteList ','                  /* Allows a trailing comma at list end */
159     | ByteList ','
160         ByteConstExpr               {$$ = TrLinkPeerNode ($1,$3);}
161     ;
162 
163 DWordList
164     :                               {$$ = NULL;}
165     | DWordConstExpr
166     | DWordList ','                 /* Allows a trailing comma at list end */
167     | DWordList ','
168         DWordConstExpr              {$$ = TrLinkPeerNode ($1,$3);}
169     ;
170 
171 FieldUnitList
172     :                               {$$ = NULL;}
173     | FieldUnit
174     | FieldUnitList ','             /* Allows a trailing comma at list end */
175     | FieldUnitList ','
176         FieldUnit                   {$$ = TrLinkPeerNode ($1,$3);}
177     ;
178 
179 FieldUnit
180     : FieldUnitEntry                {}
181     | OffsetTerm                    {}
182     | AccessAsTerm                  {}
183     | ConnectionTerm                {}
184     ;
185 
186 FieldUnitEntry
187     : ',' AmlPackageLengthTerm      {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);}
188     | NameSeg ','
189         AmlPackageLengthTerm        {$$ = TrLinkChildNode ($1,$3);}
190     ;
191 
192 ObjectList
193     :                               {$$ = NULL;}
194     | ObjectList Object             {$$ = TrLinkPeerNode ($1,$2);}
195     | error                         {$$ = AslDoError(); yyclearin;}
196     ;
197 
198 Object
199     : CompilerDirective             {}
200     | NamedObject                   {}
201     | NameSpaceModifier             {}
202     ;
203 
204 PackageList
205     :                               {$$ = NULL;}
206     | PackageElement
207     | PackageList ','               /* Allows a trailing comma at list end */
208     | PackageList ','
209         PackageElement              {$$ = TrLinkPeerNode ($1,$3);}
210     ;
211 
212 PackageElement
213     : DataObject                    {}
214     | NameString                    {}
215     ;
216 
217     /* Rules for specifying the type of one method argument or return value */
218 
219 ParameterTypePackage
220     :                               {$$ = NULL;}
221     | ObjectTypeKeyword             {$$ = $1;}
222     | ParameterTypePackage ','
223         ObjectTypeKeyword           {$$ = TrLinkPeerNodes (2,$1,$3);}
224     ;
225 
226 ParameterTypePackageList
227     :                               {$$ = NULL;}
228     | ObjectTypeKeyword             {$$ = $1;}
229     | '{' ParameterTypePackage '}'  {$$ = $2;}
230     ;
231 
232 OptionalParameterTypePackage
233     :                               {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);}
234     | ',' ParameterTypePackageList  {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);}
235     ;
236 
237     /* Rules for specifying the types for method arguments */
238 
239 ParameterTypesPackage
240     : ParameterTypePackageList      {$$ = $1;}
241     | ParameterTypesPackage ','
242         ParameterTypePackageList    {$$ = TrLinkPeerNodes (2,$1,$3);}
243     ;
244 
245 ParameterTypesPackageList
246     :                               {$$ = NULL;}
247     | ObjectTypeKeyword             {$$ = $1;}
248     | '{' ParameterTypesPackage '}' {$$ = $2;}
249     ;
250 
251 OptionalParameterTypesPackage
252     :                               {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);}
253     | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);}
254     ;
255 
256     /* ACPI 3.0 -- allow semicolons between terms */
257 
258 TermList
259     :                               {$$ = NULL;}
260     | TermList Term                 {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);}
261     | TermList Term ';'             {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);}
262     | TermList ';' Term             {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);}
263     | TermList ';' Term ';'         {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);}
264     ;
265 
266 Term
267     : Object                        {}
268     | Type1Opcode                   {}
269     | Type2Opcode                   {}
270     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
271     | Type2StringOpcode             {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
272     | Type2BufferOpcode             {}
273     | Type2BufferOrStringOpcode     {}
274     | error                         {$$ = AslDoError(); yyclearin;}
275     ;
276 
277 /*
278  * Case-Default list; allow only one Default term and unlimited Case terms
279  */
280 CaseDefaultTermList
281     :                               {$$ = NULL;}
282     | CaseTerm  {}
283     | DefaultTerm   {}
284     | CaseDefaultTermList
285         CaseTerm                    {$$ = TrLinkPeerNode ($1,$2);}
286     | CaseDefaultTermList
287         DefaultTerm                 {$$ = TrLinkPeerNode ($1,$2);}
288 
289 /* Original - attempts to force zero or one default term within the switch */
290 
291 /*
292 CaseDefaultTermList
293     :                               {$$ = NULL;}
294     | CaseTermList
295         DefaultTerm
296         CaseTermList                {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));}
297     | CaseTermList
298         CaseTerm                    {$$ = TrLinkPeerNode ($1,$2);}
299     ;
300 
301 CaseTermList
302     :                               {$$ = NULL;}
303     | CaseTerm                      {}
304     | CaseTermList
305         CaseTerm                    {$$ = TrLinkPeerNode ($1,$2);}
306     ;
307 */
308 
309 
310 /*******************************************************************************
311  *
312  * ASL Data and Constant Terms
313  *
314  ******************************************************************************/
315 
316 DataObject
317     : BufferData                    {}
318     | PackageData                   {}
319     | IntegerData                   {}
320     | StringData                    {}
321     ;
322 
323 BufferData
324     : Type5Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
325     | Type2BufferOrStringOpcode     {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
326     | Type2BufferOpcode             {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
327     | BufferTerm                    {}
328     ;
329 
330 PackageData
331     : PackageTerm                   {}
332     ;
333 
334 IntegerData
335     : Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
336     | Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
337     | Integer                       {}
338     | ConstTerm                     {}
339     ;
340 
341 StringData
342     : Type2StringOpcode             {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
343     | String                        {}
344     ;
345 
346 ByteConst
347     : Integer                       {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
348     ;
349 
350 WordConst
351     : Integer                       {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
352     ;
353 
354 DWordConst
355     : Integer                       {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
356     ;
357 
358 QWordConst
359     : Integer                       {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
360     ;
361 
362 /*
363  * The NODE_COMPILE_TIME_CONST flag in the following constant expressions
364  * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes
365  * to simple integers. It is an error if these types of expressions cannot be
366  * reduced, since the AML grammar for ****ConstExpr requires a simple constant.
367  * Note: The required byte length of the constant is passed through to the
368  * constant folding code in the node AmlLength field.
369  */
370 ByteConstExpr
371     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);}
372     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);}
373     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
374     | ByteConst                     {}
375     ;
376 
377 WordConstExpr
378     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);}
379     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);}
380     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
381     | WordConst                     {}
382     ;
383 
384 DWordConstExpr
385     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);}
386     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);}
387     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
388     | DWordConst                    {}
389     ;
390 
391 QWordConstExpr
392     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);}
393     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);}
394     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
395     | QWordConst                    {}
396     ;
397 
398 ConstTerm
399     : ConstExprTerm                 {}
400     | PARSEOP_REVISION              {$$ = TrCreateLeafNode (PARSEOP_REVISION);}
401     ;
402 
403 ConstExprTerm
404     : PARSEOP_ZERO                  {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);}
405     | PARSEOP_ONE                   {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);}
406     | PARSEOP_ONES                  {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);}
407     | PARSEOP___DATE__              {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);}
408     | PARSEOP___FILE__              {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);}
409     | PARSEOP___LINE__              {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);}
410     | PARSEOP___PATH__              {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);}
411     ;
412 
413 Integer
414     : PARSEOP_INTEGER               {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);}
415     ;
416 
417 String
418     : PARSEOP_STRING_LITERAL        {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);}
419     ;
420 
421 
422 /*******************************************************************************
423  *
424  * ASL Opcode Terms
425  *
426  ******************************************************************************/
427 
428 CompilerDirective
429     : IncludeTerm                   {}
430     | ExternalTerm                  {}
431     ;
432 
433 NamedObject
434     : BankFieldTerm                 {}
435     | CreateBitFieldTerm            {}
436     | CreateByteFieldTerm           {}
437     | CreateDWordFieldTerm          {}
438     | CreateFieldTerm               {}
439     | CreateQWordFieldTerm          {}
440     | CreateWordFieldTerm           {}
441     | DataRegionTerm                {}
442     | DeviceTerm                    {}
443     | EventTerm                     {}
444     | FieldTerm                     {}
445     | FunctionTerm                  {}
446     | IndexFieldTerm                {}
447     | MethodTerm                    {}
448     | MutexTerm                     {}
449     | OpRegionTerm                  {}
450     | PowerResTerm                  {}
451     | ProcessorTerm                 {}
452     | ThermalZoneTerm               {}
453     ;
454 
455 NameSpaceModifier
456     : AliasTerm                     {}
457     | NameTerm                      {}
458     | ScopeTerm                     {}
459     ;
460 
461 /* For ObjectType: SuperName except for MethodInvocationTerm */
462 
463 ObjectTypeName
464     : NameString                    {}
465     | ArgTerm                       {}
466     | LocalTerm                     {}
467     | DebugTerm                     {}
468     | RefOfTerm                     {}
469     | DerefOfTerm                   {}
470     | IndexTerm                     {}
471 
472 /*    | MethodInvocationTerm          {} */  /* Caused reduce/reduce with Type6Opcode->MethodInvocationTerm */
473     ;
474 
475 RequiredTarget
476     : ',' SuperName                 {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);}
477     ;
478 
479 SimpleTarget
480     : NameString                    {}
481     | LocalTerm                     {}
482     | ArgTerm                       {}
483     ;
484 
485 /* Opcode types */
486 
487 Type1Opcode
488     : BreakTerm                     {}
489     | BreakPointTerm                {}
490     | ContinueTerm                  {}
491     | FatalTerm                     {}
492     | ElseIfTerm                    {}
493     | LoadTerm                      {}
494     | NoOpTerm                      {}
495     | NotifyTerm                    {}
496     | ReleaseTerm                   {}
497     | ResetTerm                     {}
498     | ReturnTerm                    {}
499     | SignalTerm                    {}
500     | SleepTerm                     {}
501     | StallTerm                     {}
502     | SwitchTerm                    {}
503     | UnloadTerm                    {}
504     | WhileTerm                     {}
505     ;
506 
507 Type2Opcode
508     : AcquireTerm                   {}
509     | CondRefOfTerm                 {}
510     | CopyObjectTerm                {}
511     | DerefOfTerm                   {}
512     | ObjectTypeTerm                {}
513     | RefOfTerm                     {}
514     | SizeOfTerm                    {}
515     | StoreTerm                     {}
516     | EqualsTerm                    {}
517     | TimerTerm                     {}
518     | WaitTerm                      {}
519     | MethodInvocationTerm          {}
520     ;
521 
522 /*
523  * Type 3/4/5 opcodes
524  */
525 Type2IntegerOpcode                  /* "Type3" opcodes */
526     : Expression                    {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
527     | AddTerm                       {}
528     | AndTerm                       {}
529     | DecTerm                       {}
530     | DivideTerm                    {}
531     | FindSetLeftBitTerm            {}
532     | FindSetRightBitTerm           {}
533     | FromBCDTerm                   {}
534     | IncTerm                       {}
535     | IndexTerm                     {}
536     | LAndTerm                      {}
537     | LEqualTerm                    {}
538     | LGreaterTerm                  {}
539     | LGreaterEqualTerm             {}
540     | LLessTerm                     {}
541     | LLessEqualTerm                {}
542     | LNotTerm                      {}
543     | LNotEqualTerm                 {}
544     | LoadTableTerm                 {}
545     | LOrTerm                       {}
546     | MatchTerm                     {}
547     | ModTerm                       {}
548     | MultiplyTerm                  {}
549     | NAndTerm                      {}
550     | NOrTerm                       {}
551     | NotTerm                       {}
552     | OrTerm                        {}
553     | ShiftLeftTerm                 {}
554     | ShiftRightTerm                {}
555     | SubtractTerm                  {}
556     | ToBCDTerm                     {}
557     | ToIntegerTerm                 {}
558     | XOrTerm                       {}
559     ;
560 
561 Type2StringOpcode                   /* "Type4" Opcodes */
562     : ToDecimalStringTerm           {}
563     | ToHexStringTerm               {}
564     | ToStringTerm                  {}
565     ;
566 
567 Type2BufferOpcode                   /* "Type5" Opcodes */
568     : ToBufferTerm                  {}
569     | ConcatResTerm                 {}
570     ;
571 
572 Type2BufferOrStringOpcode
573     : ConcatTerm                    {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
574     | PrintfTerm                    {}
575     | FprintfTerm                   {}
576     | MidTerm                       {}
577     ;
578 
579 /*
580  * A type 3 opcode evaluates to an Integer and cannot have a destination operand
581  */
582 Type3Opcode
583     : EISAIDTerm                    {}
584     ;
585 
586 /* Obsolete
587 Type4Opcode
588     : ConcatTerm                    {}
589     | ToDecimalStringTerm           {}
590     | ToHexStringTerm               {}
591     | MidTerm                       {}
592     | ToStringTerm                  {}
593     ;
594 */
595 
596 Type5Opcode
597     : ResourceTemplateTerm          {}
598     | UnicodeTerm                   {}
599     | ToPLDTerm                     {}
600     | ToUUIDTerm                    {}
601     ;
602 
603 Type6Opcode
604     : RefOfTerm                     {}
605     | DerefOfTerm                   {}
606     | IndexTerm                     {}
607     | IndexExpTerm                  {}
608     | MethodInvocationTerm          {}
609     ;
610 
611 
612 /*******************************************************************************
613  *
614  * ASL Primary Terms
615  *
616  ******************************************************************************/
617 
618 AccessAsTerm
619     : PARSEOP_ACCESSAS '('
620         AccessTypeKeyword
621         OptionalAccessAttribTerm
622         ')'                         {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);}
623     | PARSEOP_ACCESSAS '('
624         error ')'                   {$$ = AslDoError(); yyclearin;}
625     ;
626 
627 AcquireTerm
628     : PARSEOP_ACQUIRE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_ACQUIRE);}
629         SuperName
630         ',' WordConstExpr
631         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$6);}
632     | PARSEOP_ACQUIRE '('
633         error ')'                   {$$ = AslDoError(); yyclearin;}
634     ;
635 
636 AddTerm
637     : PARSEOP_ADD '('               {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);}
638         TermArg
639         TermArgItem
640         Target
641         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
642     | PARSEOP_ADD '('
643         error ')'                   {$$ = AslDoError(); yyclearin;}
644     ;
645 
646 AliasTerm
647     : PARSEOP_ALIAS '('             {$<n>$ = TrCreateLeafNode (PARSEOP_ALIAS);}
648         NameString
649         NameStringItem
650         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,
651                                         TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));}
652     | PARSEOP_ALIAS '('
653         error ')'                   {$$ = AslDoError(); yyclearin;}
654     ;
655 
656 AndTerm
657     : PARSEOP_AND '('               {$<n>$ = TrCreateLeafNode (PARSEOP_AND);}
658         TermArg
659         TermArgItem
660         Target
661         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
662     | PARSEOP_AND '('
663         error ')'                   {$$ = AslDoError(); yyclearin;}
664     ;
665 
666 ArgTerm
667     : PARSEOP_ARG0                  {$$ = TrCreateLeafNode (PARSEOP_ARG0);}
668     | PARSEOP_ARG1                  {$$ = TrCreateLeafNode (PARSEOP_ARG1);}
669     | PARSEOP_ARG2                  {$$ = TrCreateLeafNode (PARSEOP_ARG2);}
670     | PARSEOP_ARG3                  {$$ = TrCreateLeafNode (PARSEOP_ARG3);}
671     | PARSEOP_ARG4                  {$$ = TrCreateLeafNode (PARSEOP_ARG4);}
672     | PARSEOP_ARG5                  {$$ = TrCreateLeafNode (PARSEOP_ARG5);}
673     | PARSEOP_ARG6                  {$$ = TrCreateLeafNode (PARSEOP_ARG6);}
674     ;
675 
676 BankFieldTerm
677     : PARSEOP_BANKFIELD '('         {$<n>$ = TrCreateLeafNode (PARSEOP_BANKFIELD);}
678         NameString
679         NameStringItem
680         TermArgItem
681         ',' AccessTypeKeyword
682         ',' LockRuleKeyword
683         ',' UpdateRuleKeyword
684         ')' '{'
685             FieldUnitList '}'       {$$ = TrLinkChildren ($<n>3,7,$4,$5,$6,$8,$10,$12,$15);}
686     | PARSEOP_BANKFIELD '('
687         error ')' '{' error '}'     {$$ = AslDoError(); yyclearin;}
688     ;
689 
690 BreakTerm
691     : PARSEOP_BREAK                 {$$ = TrCreateNode (PARSEOP_BREAK, 0);}
692     ;
693 
694 BreakPointTerm
695     : PARSEOP_BREAKPOINT            {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);}
696     ;
697 
698 BufferTerm
699     : PARSEOP_BUFFER '('            {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER);}
700         OptionalTermArg
701         ')' '{'
702             BufferTermData '}'      {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
703     | PARSEOP_BUFFER '('
704         error ')'                   {$$ = AslDoError(); yyclearin;}
705     ;
706 
707 BufferTermData
708     : ByteList                      {}
709     | StringData                    {}
710     ;
711 
712 CaseTerm
713     : PARSEOP_CASE '('              {$<n>$ = TrCreateLeafNode (PARSEOP_CASE);}
714         DataObject
715         ')' '{'
716             TermList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
717     | PARSEOP_CASE '('
718         error ')'                   {$$ = AslDoError(); yyclearin;}
719     ;
720 
721 ConcatTerm
722     : PARSEOP_CONCATENATE '('       {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATE);}
723         TermArg
724         TermArgItem
725         Target
726         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
727     | PARSEOP_CONCATENATE '('
728         error ')'                   {$$ = AslDoError(); yyclearin;}
729     ;
730 
731 ConcatResTerm
732     : PARSEOP_CONCATENATERESTEMPLATE '('    {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);}
733         TermArg
734         TermArgItem
735         Target
736         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
737     | PARSEOP_CONCATENATERESTEMPLATE '('
738         error ')'                   {$$ = AslDoError(); yyclearin;}
739     ;
740 
741 ConnectionTerm
742     : PARSEOP_CONNECTION '('
743         NameString
744         ')'                         {$$ = TrCreateNode (PARSEOP_CONNECTION,1,$3);}
745     | PARSEOP_CONNECTION '('        {$<n>$ = TrCreateLeafNode (PARSEOP_CONNECTION);}
746         ResourceMacroTerm
747         ')'                         {$$ = TrLinkChildren ($<n>3, 1,
748                                             TrLinkChildren (TrCreateLeafNode (PARSEOP_RESOURCETEMPLATE), 3,
749                                                 TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
750                                                 TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
751                                                 $4));}
752     | PARSEOP_CONNECTION '('
753         error ')'                   {$$ = AslDoError(); yyclearin;}
754     ;
755 
756 CondRefOfTerm
757     : PARSEOP_CONDREFOF '('         {$<n>$ = TrCreateLeafNode (PARSEOP_CONDREFOF);}
758         SuperName
759         Target
760         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
761     | PARSEOP_CONDREFOF '('
762         error ')'                   {$$ = AslDoError(); yyclearin;}
763     ;
764 
765 ContinueTerm
766     : PARSEOP_CONTINUE              {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);}
767     ;
768 
769 CopyObjectTerm
770     : PARSEOP_COPYOBJECT '('        {$<n>$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);}
771         TermArg
772         ',' SimpleTarget
773         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));}
774     | PARSEOP_COPYOBJECT '('
775         error ')'                   {$$ = AslDoError(); yyclearin;}
776     ;
777 
778 CreateBitFieldTerm
779     : PARSEOP_CREATEBITFIELD '('    {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);}
780         TermArg
781         TermArgItem
782         NameStringItem
783         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
784     | PARSEOP_CREATEBITFIELD '('
785         error ')'                   {$$ = AslDoError(); yyclearin;}
786     ;
787 
788 CreateByteFieldTerm
789     : PARSEOP_CREATEBYTEFIELD '('   {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEBYTEFIELD);}
790         TermArg
791         TermArgItem
792         NameStringItem
793         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
794     | PARSEOP_CREATEBYTEFIELD '('
795         error ')'                   {$$ = AslDoError(); yyclearin;}
796     ;
797 
798 CreateDWordFieldTerm
799     : PARSEOP_CREATEDWORDFIELD '('  {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEDWORDFIELD);}
800         TermArg
801         TermArgItem
802         NameStringItem
803         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
804     | PARSEOP_CREATEDWORDFIELD '('
805         error ')'                   {$$ = AslDoError(); yyclearin;}
806     ;
807 
808 CreateFieldTerm
809     : PARSEOP_CREATEFIELD '('       {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEFIELD);}
810         TermArg
811         TermArgItem
812         TermArgItem
813         NameStringItem
814         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,TrSetNodeFlags ($7, NODE_IS_NAME_DECLARATION));}
815     | PARSEOP_CREATEFIELD '('
816         error ')'                   {$$ = AslDoError(); yyclearin;}
817     ;
818 
819 CreateQWordFieldTerm
820     : PARSEOP_CREATEQWORDFIELD '('  {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEQWORDFIELD);}
821         TermArg
822         TermArgItem
823         NameStringItem
824         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
825     | PARSEOP_CREATEQWORDFIELD '('
826         error ')'                   {$$ = AslDoError(); yyclearin;}
827     ;
828 
829 CreateWordFieldTerm
830     : PARSEOP_CREATEWORDFIELD '('   {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEWORDFIELD);}
831         TermArg
832         TermArgItem
833         NameStringItem
834         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
835     | PARSEOP_CREATEWORDFIELD '('
836         error ')'                   {$$ = AslDoError(); yyclearin;}
837     ;
838 
839 DataRegionTerm
840     : PARSEOP_DATATABLEREGION '('   {$<n>$ = TrCreateLeafNode (PARSEOP_DATATABLEREGION);}
841         NameString
842         TermArgItem
843         TermArgItem
844         TermArgItem
845         ')'                         {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$6,$7);}
846     | PARSEOP_DATATABLEREGION '('
847         error ')'                   {$$ = AslDoError(); yyclearin;}
848     ;
849 
850 DebugTerm
851     : PARSEOP_DEBUG                 {$$ = TrCreateLeafNode (PARSEOP_DEBUG);}
852     ;
853 
854 DecTerm
855     : PARSEOP_DECREMENT '('         {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);}
856         SuperName
857         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
858     | PARSEOP_DECREMENT '('
859         error ')'                   {$$ = AslDoError(); yyclearin;}
860     ;
861 
862 DefaultTerm
863     : PARSEOP_DEFAULT '{'           {$<n>$ = TrCreateLeafNode (PARSEOP_DEFAULT);}
864         TermList '}'                {$$ = TrLinkChildren ($<n>3,1,$4);}
865     | PARSEOP_DEFAULT '{'
866         error '}'                   {$$ = AslDoError(); yyclearin;}
867     ;
868 
869 DerefOfTerm
870     : PARSEOP_DEREFOF '('           {$<n>$ = TrCreateLeafNode (PARSEOP_DEREFOF);}
871         TermArg
872         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
873     | PARSEOP_DEREFOF '('
874         error ')'                   {$$ = AslDoError(); yyclearin;}
875     ;
876 
877 DeviceTerm
878     : PARSEOP_DEVICE '('            {$<n>$ = TrCreateLeafNode (PARSEOP_DEVICE);}
879         NameString
880         ')' '{'
881             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
882     | PARSEOP_DEVICE '('
883         error ')'                   {$$ = AslDoError(); yyclearin;}
884     ;
885 
886 DivideTerm
887     : PARSEOP_DIVIDE '('            {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);}
888         TermArg
889         TermArgItem
890         Target
891         Target
892         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);}
893     | PARSEOP_DIVIDE '('
894         error ')'                   {$$ = AslDoError(); yyclearin;}
895     ;
896 
897 EISAIDTerm
898     : PARSEOP_EISAID '('
899         StringData ')'              {$$ = TrUpdateNode (PARSEOP_EISAID, $3);}
900     | PARSEOP_EISAID '('
901         error ')'                   {$$ = AslDoError(); yyclearin;}
902     ;
903 
904 ElseIfTerm
905     : IfTerm ElseTerm               {$$ = TrLinkPeerNode ($1,$2);}
906     ;
907 
908 ElseTerm
909     :                               {$$ = NULL;}
910     | PARSEOP_ELSE '{'              {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);}
911         TermList '}'                {$$ = TrLinkChildren ($<n>3,1,$4);}
912 
913     | PARSEOP_ELSE '{'
914         error '}'                   {$$ = AslDoError(); yyclearin;}
915 
916     | PARSEOP_ELSE
917         error                       {$$ = AslDoError(); yyclearin;}
918 
919     | PARSEOP_ELSEIF '('            {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);}
920         TermArg                     {$<n>$ = TrCreateLeafNode (PARSEOP_IF);}
921         ')' '{'
922             TermList '}'            {TrLinkChildren ($<n>5,2,$4,$8);}
923         ElseTerm                    {TrLinkPeerNode ($<n>5,$11);}
924                                     {$$ = TrLinkChildren ($<n>3,1,$<n>5);}
925 
926     | PARSEOP_ELSEIF '('
927         error ')'                   {$$ = AslDoError(); yyclearin;}
928 
929     | PARSEOP_ELSEIF
930         error                       {$$ = AslDoError(); yyclearin;}
931     ;
932 
933 EventTerm
934     : PARSEOP_EVENT '('             {$<n>$ = TrCreateLeafNode (PARSEOP_EVENT);}
935         NameString
936         ')'                         {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));}
937     | PARSEOP_EVENT '('
938         error ')'                   {$$ = AslDoError(); yyclearin;}
939     ;
940 
941 ExternalTerm
942     : PARSEOP_EXTERNAL '('
943         NameString
944         OptionalObjectTypeKeyword
945         OptionalParameterTypePackage
946         OptionalParameterTypesPackage
947         ')'                         {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);}
948     | PARSEOP_EXTERNAL '('
949         error ')'                   {$$ = AslDoError(); yyclearin;}
950     ;
951 
952 FatalTerm
953     : PARSEOP_FATAL '('             {$<n>$ = TrCreateLeafNode (PARSEOP_FATAL);}
954         ByteConstExpr
955         ',' DWordConstExpr
956         TermArgItem
957         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);}
958     | PARSEOP_FATAL '('
959         error ')'                   {$$ = AslDoError(); yyclearin;}
960     ;
961 
962 FieldTerm
963     : PARSEOP_FIELD '('             {$<n>$ = TrCreateLeafNode (PARSEOP_FIELD);}
964         NameString
965         ',' AccessTypeKeyword
966         ',' LockRuleKeyword
967         ',' UpdateRuleKeyword
968         ')' '{'
969             FieldUnitList '}'       {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);}
970     | PARSEOP_FIELD '('
971         error ')' '{' error '}'     {$$ = AslDoError(); yyclearin;}
972     ;
973 
974 FindSetLeftBitTerm
975     : PARSEOP_FINDSETLEFTBIT '('    {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);}
976         TermArg
977         Target
978         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
979     | PARSEOP_FINDSETLEFTBIT '('
980         error ')'                   {$$ = AslDoError(); yyclearin;}
981     ;
982 
983 FindSetRightBitTerm
984     : PARSEOP_FINDSETRIGHTBIT '('   {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);}
985         TermArg
986         Target
987         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
988     | PARSEOP_FINDSETRIGHTBIT '('
989         error ')'                   {$$ = AslDoError(); yyclearin;}
990     ;
991 
992 FprintfTerm
993     : PARSEOP_FPRINTF '('            {$<n>$ = TrCreateLeafNode (PARSEOP_FPRINTF);}
994         TermArg ','
995         StringData
996         PrintfArgList
997         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);}
998     | PARSEOP_FPRINTF '('
999         error ')'                   {$$ = AslDoError(); yyclearin;}
1000     ;
1001 
1002 FromBCDTerm
1003     : PARSEOP_FROMBCD '('           {$<n>$ = TrCreateLeafNode (PARSEOP_FROMBCD);}
1004         TermArg
1005         Target
1006         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1007     | PARSEOP_FROMBCD '('
1008         error ')'                   {$$ = AslDoError(); yyclearin;}
1009     ;
1010 
1011 FunctionTerm
1012     : PARSEOP_FUNCTION '('          {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);}
1013         NameString
1014         OptionalParameterTypePackage
1015         OptionalParameterTypesPackage
1016         ')' '{'
1017             TermList '}'            {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),
1018                                         TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),
1019                                         TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL),
1020                                         TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);}
1021     | PARSEOP_FUNCTION '('
1022         error ')'                   {$$ = AslDoError(); yyclearin;}
1023     ;
1024 
1025 IfTerm
1026     : PARSEOP_IF '('                {$<n>$ = TrCreateLeafNode (PARSEOP_IF);}
1027         TermArg
1028         ')' '{'
1029             TermList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1030 
1031     | PARSEOP_IF '('
1032         error ')'                   {$$ = AslDoError(); yyclearin;}
1033     ;
1034 
1035 IncludeTerm
1036     : PARSEOP_INCLUDE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE);}
1037         String  ')'                 {TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);}
1038         TermList
1039         IncludeEndTerm              {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);}
1040     ;
1041 
1042 IncludeEndTerm
1043     : PARSEOP_INCLUDE_END           {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);}
1044     ;
1045 
1046 IncTerm
1047     : PARSEOP_INCREMENT '('         {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);}
1048         SuperName
1049         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1050     | PARSEOP_INCREMENT '('
1051         error ')'                   {$$ = AslDoError(); yyclearin;}
1052     ;
1053 
1054 IndexFieldTerm
1055     : PARSEOP_INDEXFIELD '('        {$<n>$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);}
1056         NameString
1057         NameStringItem
1058         ',' AccessTypeKeyword
1059         ',' LockRuleKeyword
1060         ',' UpdateRuleKeyword
1061         ')' '{'
1062             FieldUnitList '}'       {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);}
1063     | PARSEOP_INDEXFIELD '('
1064         error ')' '{' error '}'     {$$ = AslDoError(); yyclearin;}
1065     ;
1066 
1067 IndexTerm
1068     : PARSEOP_INDEX '('             {$<n>$ = TrCreateLeafNode (PARSEOP_INDEX);}
1069         TermArg
1070         TermArgItem
1071         Target
1072         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1073     | PARSEOP_INDEX '('
1074         error ')'                   {$$ = AslDoError(); yyclearin;}
1075     ;
1076 
1077 LAndTerm
1078     : PARSEOP_LAND '('              {$<n>$ = TrCreateLeafNode (PARSEOP_LAND);}
1079         TermArg
1080         TermArgItem
1081         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1082     | PARSEOP_LAND '('
1083         error ')'                   {$$ = AslDoError(); yyclearin;}
1084     ;
1085 
1086 LEqualTerm
1087     : PARSEOP_LEQUAL '('            {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);}
1088         TermArg
1089         TermArgItem
1090         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1091     | PARSEOP_LEQUAL '('
1092         error ')'                   {$$ = AslDoError(); yyclearin;}
1093     ;
1094 
1095 LGreaterEqualTerm
1096     : PARSEOP_LGREATEREQUAL '('     {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);}
1097         TermArg
1098         TermArgItem
1099         ')'                         {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
1100     | PARSEOP_LGREATEREQUAL '('
1101         error ')'                   {$$ = AslDoError(); yyclearin;}
1102     ;
1103 
1104 LGreaterTerm
1105     : PARSEOP_LGREATER '('          {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);}
1106         TermArg
1107         TermArgItem
1108         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1109     | PARSEOP_LGREATER '('
1110         error ')'                   {$$ = AslDoError(); yyclearin;}
1111     ;
1112 
1113 LLessEqualTerm
1114     : PARSEOP_LLESSEQUAL '('        {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);}
1115         TermArg
1116         TermArgItem
1117         ')'                         {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
1118     | PARSEOP_LLESSEQUAL '('
1119         error ')'                   {$$ = AslDoError(); yyclearin;}
1120     ;
1121 
1122 LLessTerm
1123     : PARSEOP_LLESS '('             {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);}
1124         TermArg
1125         TermArgItem
1126         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1127     | PARSEOP_LLESS '('
1128         error ')'                   {$$ = AslDoError(); yyclearin;}
1129     ;
1130 
1131 LNotEqualTerm
1132     : PARSEOP_LNOTEQUAL '('         {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);}
1133         TermArg
1134         TermArgItem
1135         ')'                         {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
1136     | PARSEOP_LNOTEQUAL '('
1137         error ')'                   {$$ = AslDoError(); yyclearin;}
1138     ;
1139 
1140 LNotTerm
1141     : PARSEOP_LNOT '('              {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);}
1142         TermArg
1143         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1144     | PARSEOP_LNOT '('
1145         error ')'                   {$$ = AslDoError(); yyclearin;}
1146     ;
1147 
1148 LoadTableTerm
1149     : PARSEOP_LOADTABLE '('         {$<n>$ = TrCreateLeafNode (PARSEOP_LOADTABLE);}
1150         TermArg
1151         TermArgItem
1152         TermArgItem
1153         OptionalListString
1154         OptionalListString
1155         OptionalReference
1156         ')'                         {$$ = TrLinkChildren ($<n>3,6,$4,$5,$6,$7,$8,$9);}
1157     | PARSEOP_LOADTABLE '('
1158         error ')'                   {$$ = AslDoError(); yyclearin;}
1159     ;
1160 
1161 LoadTerm
1162     : PARSEOP_LOAD '('              {$<n>$ = TrCreateLeafNode (PARSEOP_LOAD);}
1163         NameString
1164         RequiredTarget
1165         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1166     | PARSEOP_LOAD '('
1167         error ')'                   {$$ = AslDoError(); yyclearin;}
1168     ;
1169 
1170 LocalTerm
1171     : PARSEOP_LOCAL0                {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);}
1172     | PARSEOP_LOCAL1                {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);}
1173     | PARSEOP_LOCAL2                {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);}
1174     | PARSEOP_LOCAL3                {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);}
1175     | PARSEOP_LOCAL4                {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);}
1176     | PARSEOP_LOCAL5                {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);}
1177     | PARSEOP_LOCAL6                {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);}
1178     | PARSEOP_LOCAL7                {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);}
1179     ;
1180 
1181 LOrTerm
1182     : PARSEOP_LOR '('               {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);}
1183         TermArg
1184         TermArgItem
1185         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1186     | PARSEOP_LOR '('
1187         error ')'                   {$$ = AslDoError(); yyclearin;}
1188     ;
1189 
1190 MatchTerm
1191     : PARSEOP_MATCH '('             {$<n>$ = TrCreateLeafNode (PARSEOP_MATCH);}
1192         TermArg
1193         ',' MatchOpKeyword
1194         TermArgItem
1195         ',' MatchOpKeyword
1196         TermArgItem
1197         TermArgItem
1198         ')'                         {$$ = TrLinkChildren ($<n>3,6,$4,$6,$7,$9,$10,$11);}
1199     | PARSEOP_MATCH '('
1200         error ')'                   {$$ = AslDoError(); yyclearin;}
1201     ;
1202 
1203 MethodTerm
1204     : PARSEOP_METHOD  '('           {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);}
1205         NameString
1206         OptionalByteConstExpr       {UtCheckIntegerRange ($5, 0, 7);}
1207         OptionalSerializeRuleKeyword
1208         OptionalByteConstExpr
1209         OptionalParameterTypePackage
1210         OptionalParameterTypesPackage
1211         ')' '{'
1212             TermList '}'            {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);}
1213     | PARSEOP_METHOD '('
1214         error ')'                   {$$ = AslDoError(); yyclearin;}
1215     ;
1216 
1217 MidTerm
1218     : PARSEOP_MID '('               {$<n>$ = TrCreateLeafNode (PARSEOP_MID);}
1219         TermArg
1220         TermArgItem
1221         TermArgItem
1222         Target
1223         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);}
1224     | PARSEOP_MID '('
1225         error ')'                   {$$ = AslDoError(); yyclearin;}
1226     ;
1227 
1228 ModTerm
1229     : PARSEOP_MOD '('               {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);}
1230         TermArg
1231         TermArgItem
1232         Target
1233         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1234     | PARSEOP_MOD '('
1235         error ')'                   {$$ = AslDoError(); yyclearin;}
1236     ;
1237 
1238 MultiplyTerm
1239     : PARSEOP_MULTIPLY '('          {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);}
1240         TermArg
1241         TermArgItem
1242         Target
1243         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1244     | PARSEOP_MULTIPLY '('
1245         error ')'                   {$$ = AslDoError(); yyclearin;}
1246     ;
1247 
1248 MutexTerm
1249     : PARSEOP_MUTEX '('             {$<n>$ = TrCreateLeafNode (PARSEOP_MUTEX);}
1250         NameString
1251         ',' ByteConstExpr
1252         ')'                         {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);}
1253     | PARSEOP_MUTEX '('
1254         error ')'                   {$$ = AslDoError(); yyclearin;}
1255     ;
1256 
1257 NameTerm
1258     : PARSEOP_NAME '('              {$<n>$ = TrCreateLeafNode (PARSEOP_NAME);}
1259         NameString
1260         ',' DataObject
1261         ')'                         {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);}
1262     | PARSEOP_NAME '('
1263         error ')'                   {$$ = AslDoError(); yyclearin;}
1264     ;
1265 
1266 NAndTerm
1267     : PARSEOP_NAND '('              {$<n>$ = TrCreateLeafNode (PARSEOP_NAND);}
1268         TermArg
1269         TermArgItem
1270         Target
1271         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1272     | PARSEOP_NAND '('
1273         error ')'                   {$$ = AslDoError(); yyclearin;}
1274     ;
1275 
1276 NoOpTerm
1277     : PARSEOP_NOOP                  {$$ = TrCreateNode (PARSEOP_NOOP, 0);}
1278     ;
1279 
1280 NOrTerm
1281     : PARSEOP_NOR '('               {$<n>$ = TrCreateLeafNode (PARSEOP_NOR);}
1282         TermArg
1283         TermArgItem
1284         Target
1285         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1286     | PARSEOP_NOR '('
1287         error ')'                   {$$ = AslDoError(); yyclearin;}
1288     ;
1289 
1290 NotifyTerm
1291     : PARSEOP_NOTIFY '('            {$<n>$ = TrCreateLeafNode (PARSEOP_NOTIFY);}
1292         SuperName
1293         TermArgItem
1294         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1295     | PARSEOP_NOTIFY '('
1296         error ')'                   {$$ = AslDoError(); yyclearin;}
1297     ;
1298 
1299 NotTerm
1300     : PARSEOP_NOT '('               {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);}
1301         TermArg
1302         Target
1303         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1304     | PARSEOP_NOT '('
1305         error ')'                   {$$ = AslDoError(); yyclearin;}
1306     ;
1307 
1308 ObjectTypeTerm
1309     : PARSEOP_OBJECTTYPE '('        {$<n>$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);}
1310         ObjectTypeName
1311         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1312     | PARSEOP_OBJECTTYPE '('
1313         error ')'                   {$$ = AslDoError(); yyclearin;}
1314     ;
1315 
1316 OffsetTerm
1317     : PARSEOP_OFFSET '('
1318         AmlPackageLengthTerm
1319         ')'                         {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);}
1320     | PARSEOP_OFFSET '('
1321         error ')'                   {$$ = AslDoError(); yyclearin;}
1322     ;
1323 
1324 OpRegionTerm
1325     : PARSEOP_OPERATIONREGION '('   {$<n>$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);}
1326         NameString
1327         ',' OpRegionSpaceIdTerm
1328         TermArgItem
1329         TermArgItem
1330         ')'                         {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);}
1331     | PARSEOP_OPERATIONREGION '('
1332         error ')'                   {$$ = AslDoError(); yyclearin;}
1333     ;
1334 
1335 OpRegionSpaceIdTerm
1336     : RegionSpaceKeyword            {}
1337     | ByteConst                     {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);}
1338     ;
1339 
1340 OrTerm
1341     : PARSEOP_OR '('                {$<n>$ = TrCreateLeafNode (PARSEOP_OR);}
1342         TermArg
1343         TermArgItem
1344         Target
1345         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1346     | PARSEOP_OR '('
1347         error ')'                   {$$ = AslDoError(); yyclearin;}
1348     ;
1349 
1350 PackageTerm
1351     : PARSEOP_PACKAGE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);}
1352         VarPackageLengthTerm
1353         ')' '{'
1354             PackageList '}'         {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1355     | PARSEOP_PACKAGE '('
1356         error ')'                   {$$ = AslDoError(); yyclearin;}
1357     ;
1358 
1359 PowerResTerm
1360     : PARSEOP_POWERRESOURCE '('     {$<n>$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);}
1361         NameString
1362         ',' ByteConstExpr
1363         ',' WordConstExpr
1364         ')' '{'
1365             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);}
1366     | PARSEOP_POWERRESOURCE '('
1367         error ')'                   {$$ = AslDoError(); yyclearin;}
1368     ;
1369 
1370 PrintfTerm
1371     : PARSEOP_PRINTF '('            {$<n>$ = TrCreateLeafNode (PARSEOP_PRINTF);}
1372         StringData
1373         PrintfArgList
1374         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1375     | PARSEOP_PRINTF '('
1376         error ')'                   {$$ = AslDoError(); yyclearin;}
1377     ;
1378 
1379 PrintfArgList
1380     :                               {$$ = NULL;}
1381     | TermArg                       {$$ = $1;}
1382     | PrintfArgList ','
1383        TermArg                      {$$ = TrLinkPeerNode ($1, $3);}
1384     ;
1385 
1386 ProcessorTerm
1387     : PARSEOP_PROCESSOR '('         {$<n>$ = TrCreateLeafNode (PARSEOP_PROCESSOR);}
1388         NameString
1389         ',' ByteConstExpr
1390         OptionalDWordConstExpr
1391         OptionalByteConstExpr
1392         ')' '{'
1393             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);}
1394     | PARSEOP_PROCESSOR '('
1395         error ')'                   {$$ = AslDoError(); yyclearin;}
1396     ;
1397 
1398 RawDataBufferTerm
1399     : PARSEOP_DATABUFFER  '('       {$<n>$ = TrCreateLeafNode (PARSEOP_DATABUFFER);}
1400         OptionalWordConst
1401         ')' '{'
1402             ByteList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1403     | PARSEOP_DATABUFFER '('
1404         error ')'                   {$$ = AslDoError(); yyclearin;}
1405     ;
1406 
1407 /*
1408  * In RefOf, the node isn't really a target, but we can't keep track of it after
1409  * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.)
1410  */
1411 RefOfTerm
1412     : PARSEOP_REFOF '('             {$<n>$ = TrCreateLeafNode (PARSEOP_REFOF);}
1413         SuperName
1414         ')'                         {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_TARGET));}
1415     | PARSEOP_REFOF '('
1416         error ')'                   {$$ = AslDoError(); yyclearin;}
1417     ;
1418 
1419 ReleaseTerm
1420     : PARSEOP_RELEASE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_RELEASE);}
1421         SuperName
1422         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1423     | PARSEOP_RELEASE '('
1424         error ')'                   {$$ = AslDoError(); yyclearin;}
1425     ;
1426 
1427 ResetTerm
1428     : PARSEOP_RESET '('             {$<n>$ = TrCreateLeafNode (PARSEOP_RESET);}
1429         SuperName
1430         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1431     | PARSEOP_RESET '('
1432         error ')'                   {$$ = AslDoError(); yyclearin;}
1433     ;
1434 
1435 ReturnTerm
1436     : PARSEOP_RETURN '('            {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);}
1437         OptionalReturnArg
1438         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1439     | PARSEOP_RETURN                {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));}
1440     | PARSEOP_RETURN '('
1441         error ')'                   {$$ = AslDoError(); yyclearin;}
1442     ;
1443 
1444 ScopeTerm
1445     : PARSEOP_SCOPE '('             {$<n>$ = TrCreateLeafNode (PARSEOP_SCOPE);}
1446         NameString
1447         ')' '{'
1448             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
1449     | PARSEOP_SCOPE '('
1450         error ')'                   {$$ = AslDoError(); yyclearin;}
1451     ;
1452 
1453 ShiftLeftTerm
1454     : PARSEOP_SHIFTLEFT '('         {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);}
1455         TermArg
1456         TermArgItem
1457         Target
1458         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1459     | PARSEOP_SHIFTLEFT '('
1460         error ')'                   {$$ = AslDoError(); yyclearin;}
1461     ;
1462 
1463 ShiftRightTerm
1464     : PARSEOP_SHIFTRIGHT '('        {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);}
1465         TermArg
1466         TermArgItem
1467         Target
1468         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1469     | PARSEOP_SHIFTRIGHT '('
1470         error ')'                   {$$ = AslDoError(); yyclearin;}
1471     ;
1472 
1473 SignalTerm
1474     : PARSEOP_SIGNAL '('            {$<n>$ = TrCreateLeafNode (PARSEOP_SIGNAL);}
1475         SuperName
1476         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1477     | PARSEOP_SIGNAL '('
1478         error ')'                   {$$ = AslDoError(); yyclearin;}
1479     ;
1480 
1481 SizeOfTerm
1482     : PARSEOP_SIZEOF '('            {$<n>$ = TrCreateLeafNode (PARSEOP_SIZEOF);}
1483         SuperName
1484         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1485     | PARSEOP_SIZEOF '('
1486         error ')'                   {$$ = AslDoError(); yyclearin;}
1487     ;
1488 
1489 SleepTerm
1490     : PARSEOP_SLEEP '('             {$<n>$ = TrCreateLeafNode (PARSEOP_SLEEP);}
1491         TermArg
1492         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1493     | PARSEOP_SLEEP '('
1494         error ')'                   {$$ = AslDoError(); yyclearin;}
1495     ;
1496 
1497 StallTerm
1498     : PARSEOP_STALL '('             {$<n>$ = TrCreateLeafNode (PARSEOP_STALL);}
1499         TermArg
1500         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1501     | PARSEOP_STALL '('
1502         error ')'                   {$$ = AslDoError(); yyclearin;}
1503     ;
1504 
1505 StoreTerm
1506     : PARSEOP_STORE '('             {$<n>$ = TrCreateLeafNode (PARSEOP_STORE);}
1507         TermArg
1508         ',' SuperName
1509         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));}
1510     | PARSEOP_STORE '('
1511         error ')'                   {$$ = AslDoError(); yyclearin;}
1512     ;
1513 
1514 SubtractTerm
1515     : PARSEOP_SUBTRACT '('          {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);}
1516         TermArg
1517         TermArgItem
1518         Target
1519         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1520     | PARSEOP_SUBTRACT '('
1521         error ')'                   {$$ = AslDoError(); yyclearin;}
1522     ;
1523 SwitchTerm
1524     : PARSEOP_SWITCH '('            {$<n>$ = TrCreateLeafNode (PARSEOP_SWITCH);}
1525         TermArg
1526         ')' '{'
1527             CaseDefaultTermList '}'
1528                                     {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1529     | PARSEOP_SWITCH '('
1530         error ')'                   {$$ = AslDoError(); yyclearin;}
1531     ;
1532 
1533 ThermalZoneTerm
1534     : PARSEOP_THERMALZONE '('       {$<n>$ = TrCreateLeafNode (PARSEOP_THERMALZONE);}
1535         NameString
1536         ')' '{'
1537             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
1538     | PARSEOP_THERMALZONE '('
1539         error ')'                   {$$ = AslDoError(); yyclearin;}
1540     ;
1541 
1542 TimerTerm
1543     : PARSEOP_TIMER '('             {$<n>$ = TrCreateLeafNode (PARSEOP_TIMER);}
1544         ')'                         {$$ = TrLinkChildren ($<n>3,0);}
1545     | PARSEOP_TIMER                 {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_TIMER),0);}
1546     | PARSEOP_TIMER '('
1547         error ')'                   {$$ = AslDoError(); yyclearin;}
1548     ;
1549 
1550 ToBCDTerm
1551     : PARSEOP_TOBCD '('             {$<n>$ = TrCreateLeafNode (PARSEOP_TOBCD);}
1552         TermArg
1553         Target
1554         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1555     | PARSEOP_TOBCD '('
1556         error ')'                   {$$ = AslDoError(); yyclearin;}
1557     ;
1558 
1559 ToBufferTerm
1560     : PARSEOP_TOBUFFER '('          {$<n>$ = TrCreateLeafNode (PARSEOP_TOBUFFER);}
1561         TermArg
1562         Target
1563         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1564     | PARSEOP_TOBUFFER '('
1565         error ')'                   {$$ = AslDoError(); yyclearin;}
1566     ;
1567 
1568 ToDecimalStringTerm
1569     : PARSEOP_TODECIMALSTRING '('   {$<n>$ = TrCreateLeafNode (PARSEOP_TODECIMALSTRING);}
1570         TermArg
1571         Target
1572         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1573     | PARSEOP_TODECIMALSTRING '('
1574         error ')'                   {$$ = AslDoError(); yyclearin;}
1575     ;
1576 
1577 ToHexStringTerm
1578     : PARSEOP_TOHEXSTRING '('       {$<n>$ = TrCreateLeafNode (PARSEOP_TOHEXSTRING);}
1579         TermArg
1580         Target
1581         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1582     | PARSEOP_TOHEXSTRING '('
1583         error ')'                   {$$ = AslDoError(); yyclearin;}
1584     ;
1585 
1586 ToIntegerTerm
1587     : PARSEOP_TOINTEGER '('         {$<n>$ = TrCreateLeafNode (PARSEOP_TOINTEGER);}
1588         TermArg
1589         Target
1590         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1591     | PARSEOP_TOINTEGER '('
1592         error ')'                   {$$ = AslDoError(); yyclearin;}
1593     ;
1594 
1595 ToPLDTerm
1596     : PARSEOP_TOPLD '('             {$<n>$ = TrCreateLeafNode (PARSEOP_TOPLD);}
1597         PldKeywordList
1598         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1599     | PARSEOP_TOPLD '('
1600         error ')'                   {$$ = AslDoError(); yyclearin;}
1601     ;
1602 
1603 PldKeywordList
1604     :                               {$$ = NULL;}
1605     | PldKeyword
1606         PARSEOP_EXP_EQUALS Integer  {$$ = TrLinkChildren ($1,1,$3);}
1607     | PldKeyword
1608         PARSEOP_EXP_EQUALS String   {$$ = TrLinkChildren ($1,1,$3);}
1609     | PldKeywordList ','            /* Allows a trailing comma at list end */
1610     | PldKeywordList ','
1611         PldKeyword
1612         PARSEOP_EXP_EQUALS Integer  {$$ = TrLinkPeerNode ($1,TrLinkChildren ($3,1,$5));}
1613     | PldKeywordList ','
1614         PldKeyword
1615         PARSEOP_EXP_EQUALS String   {$$ = TrLinkPeerNode ($1,TrLinkChildren ($3,1,$5));}
1616     ;
1617 
1618 
1619 ToStringTerm
1620     : PARSEOP_TOSTRING '('          {$<n>$ = TrCreateLeafNode (PARSEOP_TOSTRING);}
1621         TermArg
1622         OptionalCount
1623         Target
1624         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1625     | PARSEOP_TOSTRING '('
1626         error ')'                   {$$ = AslDoError(); yyclearin;}
1627     ;
1628 
1629 ToUUIDTerm
1630     : PARSEOP_TOUUID '('
1631         StringData ')'              {$$ = TrUpdateNode (PARSEOP_TOUUID, $3);}
1632     | PARSEOP_TOUUID '('
1633         error ')'                   {$$ = AslDoError(); yyclearin;}
1634     ;
1635 
1636 UnicodeTerm
1637     : PARSEOP_UNICODE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_UNICODE);}
1638         StringData
1639         ')'                         {$$ = TrLinkChildren ($<n>3,2,0,$4);}
1640     | PARSEOP_UNICODE '('
1641         error ')'                   {$$ = AslDoError(); yyclearin;}
1642     ;
1643 
1644 UnloadTerm
1645     : PARSEOP_UNLOAD '('            {$<n>$ = TrCreateLeafNode (PARSEOP_UNLOAD);}
1646         SuperName
1647         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1648     | PARSEOP_UNLOAD '('
1649         error ')'                   {$$ = AslDoError(); yyclearin;}
1650     ;
1651 
1652 WaitTerm
1653     : PARSEOP_WAIT '('              {$<n>$ = TrCreateLeafNode (PARSEOP_WAIT);}
1654         SuperName
1655         TermArgItem
1656         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1657     | PARSEOP_WAIT '('
1658         error ')'                   {$$ = AslDoError(); yyclearin;}
1659     ;
1660 
1661 XOrTerm
1662     : PARSEOP_XOR '('               {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);}
1663         TermArg
1664         TermArgItem
1665         Target
1666         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1667     | PARSEOP_XOR '('
1668         error ')'                   {$$ = AslDoError(); yyclearin;}
1669     ;
1670 
1671 WhileTerm
1672     : PARSEOP_WHILE '('             {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);}
1673         TermArg
1674         ')' '{' TermList '}'
1675                                     {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1676     | PARSEOP_WHILE '('
1677         error ')'                   {$$ = AslDoError(); yyclearin;}
1678     ;
1679 
1680 
1681 /*******************************************************************************
1682  *
1683  * ASL Helper Terms
1684  *
1685  ******************************************************************************/
1686 
1687 AmlPackageLengthTerm
1688     : Integer                       {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);}
1689     ;
1690 
1691 NameStringItem
1692     : ',' NameString                {$$ = $2;}
1693     | ',' error                     {$$ = AslDoError (); yyclearin;}
1694     ;
1695 
1696 TermArgItem
1697     : ',' TermArg                   {$$ = $2;}
1698     | ',' error                     {$$ = AslDoError (); yyclearin;}
1699     ;
1700 
1701 OptionalReference
1702     :                               {$$ = TrCreateLeafNode (PARSEOP_ZERO);}       /* Placeholder is a ZeroOp object */
1703     | ','                           {$$ = TrCreateLeafNode (PARSEOP_ZERO);}       /* Placeholder is a ZeroOp object */
1704     | ',' TermArg                   {$$ = $2;}
1705     ;
1706 
1707 OptionalReturnArg
1708     :                               {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);}       /* Placeholder is a ZeroOp object */
1709     | TermArg                       {$$ = $1;}
1710     ;
1711 
1712 OptionalSerializeRuleKeyword
1713     :                               {$$ = NULL;}
1714     | ','                           {$$ = NULL;}
1715     | ',' SerializeRuleKeyword      {$$ = $2;}
1716     ;
1717 
1718 OptionalTermArg
1719     :                               {$$ = NULL;}
1720     | TermArg                       {$$ = $1;}
1721     ;
1722 
1723 OptionalWordConst
1724     :                               {$$ = NULL;}
1725     | WordConst                     {$$ = $1;}
1726     ;
1727