Merge branch 'vendor/XZ'
[dragonfly.git] / sys / contrib / dev / acpica / source / compiler / aslrules.y
1 NoEcho('
2 /******************************************************************************
3  *
4  * Module Name: aslrules.y - Bison/Yacc production rules
5  *
6  *****************************************************************************/
7
8 /*
9  * Copyright (C) 2000 - 2014, 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  * Production rules start here
50  *
51  ******************************************************************************/
52
53 /*
54  * ASL Names
55  *
56  * Root rule. Allow multiple #line directives before the definition block
57  * to handle output from preprocessors
58  */
59 ASLCode
60     : DefinitionBlockTerm
61     | error                         {YYABORT; $$ = NULL;}
62     ;
63
64 /*
65  * Blocks, Data, and Opcodes
66  */
67
68 /*
69  * Note concerning support for "module-level code".
70  *
71  * ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control
72  * methods (the so-called module-level code.) This support was explicitly
73  * removed in ACPI 2.0, but this type of code continues to be created by
74  * BIOS vendors. In order to support the disassembly and recompilation of
75  * such code (and the porting of ASL code to iASL), iASL supports this
76  * code in violation of the current ACPI specification.
77  *
78  * The grammar change to support module-level code is to revert the
79  * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the
80  * original use of {TermList} instead (see below.) This allows the use
81  * of Type1 and Type2 opcodes at module level.
82  */
83 DefinitionBlockTerm
84     : PARSEOP_DEFINITIONBLOCK '('   {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);}
85         String ','
86         String ','
87         ByteConst ','
88         String ','
89         String ','
90         DWordConst
91         ')'                         {TrSetEndLineNumber ($<n>3);}
92             '{' TermList '}'        {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);}
93     ;
94
95 /* ACPI 3.0 -- allow semicolons between terms */
96
97 TermList
98     :                               {$$ = NULL;}
99     | TermList Term                 {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);}
100     | TermList Term ';'             {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);}
101     | TermList ';' Term             {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);}
102     | TermList ';' Term ';'         {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);}
103     ;
104
105 Term
106     : Object                        {}
107     | Type1Opcode                   {}
108     | Type2Opcode                   {}
109     | Type2IntegerOpcode            {}
110     | Type2StringOpcode             {}
111     | Type2BufferOpcode             {}
112     | Type2BufferOrStringOpcode     {}
113     | error                         {$$ = AslDoError(); yyclearin;}
114     ;
115
116 CompilerDirective
117     : IncludeTerm                   {}
118     | ExternalTerm                  {}
119     ;
120
121 ObjectList
122     :                               {$$ = NULL;}
123     | ObjectList Object             {$$ = TrLinkPeerNode ($1,$2);}
124     | error                         {$$ = AslDoError(); yyclearin;}
125     ;
126
127 Object
128     : CompilerDirective             {}
129     | NamedObject                   {}
130     | NameSpaceModifier             {}
131     ;
132
133 DataObject
134     : BufferData                    {}
135     | PackageData                   {}
136     | IntegerData                   {}
137     | StringData                    {}
138     ;
139
140 BufferData
141     : Type5Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
142     | Type2BufferOrStringOpcode     {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
143     | Type2BufferOpcode             {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
144     | BufferTerm                    {}
145     ;
146
147 PackageData
148     : PackageTerm                   {}
149     ;
150
151 IntegerData
152     : Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
153     | Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
154     | Integer                       {}
155     | ConstTerm                     {}
156     ;
157
158 StringData
159     : Type2StringOpcode             {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST);}
160     | String                        {}
161     ;
162
163 NamedObject
164     : BankFieldTerm                 {}
165     | CreateBitFieldTerm            {}
166     | CreateByteFieldTerm           {}
167     | CreateDWordFieldTerm          {}
168     | CreateFieldTerm               {}
169     | CreateQWordFieldTerm          {}
170     | CreateWordFieldTerm           {}
171     | DataRegionTerm                {}
172     | DeviceTerm                    {}
173     | EventTerm                     {}
174     | FieldTerm                     {}
175     | FunctionTerm                  {}
176     | IndexFieldTerm                {}
177     | MethodTerm                    {}
178     | MutexTerm                     {}
179     | OpRegionTerm                  {}
180     | PowerResTerm                  {}
181     | ProcessorTerm                 {}
182     | ThermalZoneTerm               {}
183     ;
184
185 NameSpaceModifier
186     : AliasTerm                     {}
187     | NameTerm                      {}
188     | ScopeTerm                     {}
189     ;
190
191 UserTerm
192     : NameString '('                {TrUpdateNode (PARSEOP_METHODCALL, $1);}
193         ArgList ')'                 {$$ = TrLinkChildNode ($1,$4);}
194     ;
195
196 ArgList
197     :                               {$$ = NULL;}
198     | TermArg
199     | ArgList ','                   /* Allows a trailing comma at list end */
200     | ArgList ','
201         TermArg                     {$$ = TrLinkPeerNode ($1,$3);}
202     ;
203
204 /*
205 Removed from TermArg due to reduce/reduce conflicts
206     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
207     | Type2StringOpcode             {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
208     | Type2BufferOpcode             {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
209     | Type2BufferOrStringOpcode     {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
210
211 */
212
213 TermArg
214     : Type2Opcode                   {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
215     | DataObject                    {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
216     | NameString                    {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
217     | ArgTerm                       {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
218     | LocalTerm                     {$$ = TrSetNodeFlags ($1, NODE_IS_TERM_ARG);}
219     ;
220
221 Target
222     :                               {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */
223     | ','                           {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_TARGET | NODE_COMPILE_TIME_CONST);} /* Placeholder is a ZeroOp object */
224     | ',' SuperName                 {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);}
225     ;
226
227 RequiredTarget
228     : ',' SuperName                 {$$ = TrSetNodeFlags ($2, NODE_IS_TARGET);}
229     ;
230
231 SimpleTarget
232     : NameString                    {}
233     | LocalTerm                     {}
234     | ArgTerm                       {}
235     ;
236
237 /* Rules for specifying the type of one method argument or return value */
238
239 ParameterTypePackage
240     :                               {$$ = NULL;}
241     | ObjectTypeKeyword             {$$ = $1;}
242     | ParameterTypePackage ','
243         ObjectTypeKeyword           {$$ = TrLinkPeerNodes (2,$1,$3);}
244     ;
245
246 ParameterTypePackageList
247     :                               {$$ = NULL;}
248     | ObjectTypeKeyword             {$$ = $1;}
249     | '{' ParameterTypePackage '}'  {$$ = $2;}
250     ;
251
252 OptionalParameterTypePackage
253     :                               {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);}
254     | ',' ParameterTypePackageList  {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);}
255     ;
256
257 /* Rules for specifying the types for method arguments */
258
259 ParameterTypesPackage
260     : ParameterTypePackageList      {$$ = $1;}
261     | ParameterTypesPackage ','
262         ParameterTypePackageList    {$$ = TrLinkPeerNodes (2,$1,$3);}
263     ;
264
265 ParameterTypesPackageList
266     :                               {$$ = NULL;}
267     | ObjectTypeKeyword             {$$ = $1;}
268     | '{' ParameterTypesPackage '}' {$$ = $2;}
269     ;
270
271 OptionalParameterTypesPackage
272     :                               {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);}
273     | ',' ParameterTypesPackageList {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);}
274     ;
275
276
277 /* Opcode types */
278
279 Type1Opcode
280     : BreakTerm                     {}
281     | BreakPointTerm                {}
282     | ContinueTerm                  {}
283     | FatalTerm                     {}
284     | IfElseTerm                    {}
285     | LoadTerm                      {}
286     | NoOpTerm                      {}
287     | NotifyTerm                    {}
288     | ReleaseTerm                   {}
289     | ResetTerm                     {}
290     | ReturnTerm                    {}
291     | SignalTerm                    {}
292     | SleepTerm                     {}
293     | StallTerm                     {}
294     | SwitchTerm                    {}
295     | UnloadTerm                    {}
296     | WhileTerm                     {}
297     ;
298
299 Type2Opcode
300     : AcquireTerm                   {}
301     | CondRefOfTerm                 {}
302     | CopyObjectTerm                {}
303     | DerefOfTerm                   {}
304     | ObjectTypeTerm                {}
305     | RefOfTerm                     {}
306     | SizeOfTerm                    {}
307     | StoreTerm                     {}
308     | TimerTerm                     {}
309     | WaitTerm                      {}
310     | UserTerm                      {}
311     ;
312
313 /*
314  * Type 3/4/5 opcodes
315  */
316
317 Type2IntegerOpcode                  /* "Type3" opcodes */
318     : AddTerm                       {}
319     | AndTerm                       {}
320     | DecTerm                       {}
321     | DivideTerm                    {}
322     | FindSetLeftBitTerm            {}
323     | FindSetRightBitTerm           {}
324     | FromBCDTerm                   {}
325     | IncTerm                       {}
326     | IndexTerm                     {}
327     | LAndTerm                      {}
328     | LEqualTerm                    {}
329     | LGreaterTerm                  {}
330     | LGreaterEqualTerm             {}
331     | LLessTerm                     {}
332     | LLessEqualTerm                {}
333     | LNotTerm                      {}
334     | LNotEqualTerm                 {}
335     | LoadTableTerm                 {}
336     | LOrTerm                       {}
337     | MatchTerm                     {}
338     | ModTerm                       {}
339     | MultiplyTerm                  {}
340     | NAndTerm                      {}
341     | NOrTerm                       {}
342     | NotTerm                       {}
343     | OrTerm                        {}
344     | ShiftLeftTerm                 {}
345     | ShiftRightTerm                {}
346     | SubtractTerm                  {}
347     | ToBCDTerm                     {}
348     | ToIntegerTerm                 {}
349     | XOrTerm                       {}
350     ;
351
352 Type2StringOpcode                   /* "Type4" Opcodes */
353     : ToDecimalStringTerm           {}
354     | ToHexStringTerm               {}
355     | ToStringTerm                  {}
356     ;
357
358 Type2BufferOpcode                   /* "Type5" Opcodes */
359     : ToBufferTerm                  {}
360     | ConcatResTerm                 {}
361     ;
362
363 Type2BufferOrStringOpcode
364     : ConcatTerm                    {}
365     | MidTerm                       {}
366     ;
367
368 /*
369  * A type 3 opcode evaluates to an Integer and cannot have a destination operand
370  */
371
372 Type3Opcode
373     : EISAIDTerm                    {}
374     ;
375
376 /* Obsolete
377 Type4Opcode
378     : ConcatTerm                    {}
379     | ToDecimalStringTerm           {}
380     | ToHexStringTerm               {}
381     | MidTerm                       {}
382     | ToStringTerm                  {}
383     ;
384 */
385
386
387 Type5Opcode
388     : ResourceTemplateTerm          {}
389     | UnicodeTerm                   {}
390     | ToUUIDTerm                    {}
391     ;
392
393 Type6Opcode
394     : RefOfTerm                     {}
395     | DerefOfTerm                   {}
396     | IndexTerm                     {}
397     | UserTerm                      {}
398     ;
399
400 IncludeTerm
401     : PARSEOP_INCLUDE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE);}
402         String  ')'                 {TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);}
403         TermList
404         IncludeEndTerm              {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);}
405     ;
406
407 IncludeEndTerm
408     : PARSEOP_INCLUDE_END           {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);}
409     ;
410
411 ExternalTerm
412     : PARSEOP_EXTERNAL '('
413         NameString
414         OptionalObjectTypeKeyword
415         OptionalParameterTypePackage
416         OptionalParameterTypesPackage
417         ')'                         {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);}
418     | PARSEOP_EXTERNAL '('
419         error ')'                   {$$ = AslDoError(); yyclearin;}
420     ;
421
422
423 /******* Named Objects *******************************************************/
424
425
426 BankFieldTerm
427     : PARSEOP_BANKFIELD '('         {$<n>$ = TrCreateLeafNode (PARSEOP_BANKFIELD);}
428         NameString
429         NameStringItem
430         TermArgItem
431         ',' AccessTypeKeyword
432         ',' LockRuleKeyword
433         ',' UpdateRuleKeyword
434         ')' '{'
435             FieldUnitList '}'       {$$ = TrLinkChildren ($<n>3,7,$4,$5,$6,$8,$10,$12,$15);}
436     | PARSEOP_BANKFIELD '('
437         error ')' '{' error '}'     {$$ = AslDoError(); yyclearin;}
438     ;
439
440 FieldUnitList
441     :                               {$$ = NULL;}
442     | FieldUnit
443     | FieldUnitList ','             /* Allows a trailing comma at list end */
444     | FieldUnitList ','
445         FieldUnit                   {$$ = TrLinkPeerNode ($1,$3);}
446     ;
447
448 FieldUnit
449     : FieldUnitEntry                {}
450     | OffsetTerm                    {}
451     | AccessAsTerm                  {}
452     | ConnectionTerm                {}
453     ;
454
455 FieldUnitEntry
456     : ',' AmlPackageLengthTerm      {$$ = TrCreateNode (PARSEOP_RESERVED_BYTES,1,$2);}
457     | NameSeg ','
458         AmlPackageLengthTerm        {$$ = TrLinkChildNode ($1,$3);}
459     ;
460
461 OffsetTerm
462     : PARSEOP_OFFSET '('
463         AmlPackageLengthTerm
464         ')'                         {$$ = TrCreateNode (PARSEOP_OFFSET,1,$3);}
465     | PARSEOP_OFFSET '('
466         error ')'                   {$$ = AslDoError(); yyclearin;}
467     ;
468
469 AccessAsTerm
470     : PARSEOP_ACCESSAS '('
471         AccessTypeKeyword
472         OptionalAccessAttribTerm
473         ')'                         {$$ = TrCreateNode (PARSEOP_ACCESSAS,2,$3,$4);}
474     | PARSEOP_ACCESSAS '('
475         error ')'                   {$$ = AslDoError(); yyclearin;}
476     ;
477
478 ConnectionTerm
479     : PARSEOP_CONNECTION '('
480         NameString
481         ')'                         {$$ = TrCreateNode (PARSEOP_CONNECTION,1,$3);}
482     | PARSEOP_CONNECTION '('        {$<n>$ = TrCreateLeafNode (PARSEOP_CONNECTION);}
483         ResourceMacroTerm
484         ')'                         {$$ = TrLinkChildren ($<n>3, 1,
485                                             TrLinkChildren (TrCreateLeafNode (PARSEOP_RESOURCETEMPLATE), 3,
486                                                 TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
487                                                 TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
488                                                 $4));}
489     | PARSEOP_CONNECTION '('
490         error ')'                   {$$ = AslDoError(); yyclearin;}
491     ;
492
493 CreateBitFieldTerm
494     : PARSEOP_CREATEBITFIELD '('    {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEBITFIELD);}
495         TermArg
496         TermArgItem
497         NameStringItem
498         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
499     | PARSEOP_CREATEBITFIELD '('
500         error ')'                   {$$ = AslDoError(); yyclearin;}
501     ;
502
503 CreateByteFieldTerm
504     : PARSEOP_CREATEBYTEFIELD '('   {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEBYTEFIELD);}
505         TermArg
506         TermArgItem
507         NameStringItem
508         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
509     | PARSEOP_CREATEBYTEFIELD '('
510         error ')'                   {$$ = AslDoError(); yyclearin;}
511     ;
512
513 CreateDWordFieldTerm
514     : PARSEOP_CREATEDWORDFIELD '('  {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEDWORDFIELD);}
515         TermArg
516         TermArgItem
517         NameStringItem
518         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
519     | PARSEOP_CREATEDWORDFIELD '('
520         error ')'                   {$$ = AslDoError(); yyclearin;}
521     ;
522
523 CreateFieldTerm
524     : PARSEOP_CREATEFIELD '('       {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEFIELD);}
525         TermArg
526         TermArgItem
527         TermArgItem
528         NameStringItem
529         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,TrSetNodeFlags ($7, NODE_IS_NAME_DECLARATION));}
530     | PARSEOP_CREATEFIELD '('
531         error ')'                   {$$ = AslDoError(); yyclearin;}
532     ;
533
534 CreateQWordFieldTerm
535     : PARSEOP_CREATEQWORDFIELD '('  {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEQWORDFIELD);}
536         TermArg
537         TermArgItem
538         NameStringItem
539         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
540     | PARSEOP_CREATEQWORDFIELD '('
541         error ')'                   {$$ = AslDoError(); yyclearin;}
542     ;
543
544 CreateWordFieldTerm
545     : PARSEOP_CREATEWORDFIELD '('   {$<n>$ = TrCreateLeafNode (PARSEOP_CREATEWORDFIELD);}
546         TermArg
547         TermArgItem
548         NameStringItem
549         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,TrSetNodeFlags ($6, NODE_IS_NAME_DECLARATION));}
550     | PARSEOP_CREATEWORDFIELD '('
551         error ')'                   {$$ = AslDoError(); yyclearin;}
552     ;
553
554 DataRegionTerm
555     : PARSEOP_DATATABLEREGION '('   {$<n>$ = TrCreateLeafNode (PARSEOP_DATATABLEREGION);}
556         NameString
557         TermArgItem
558         TermArgItem
559         TermArgItem
560         ')'                         {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$6,$7);}
561     | PARSEOP_DATATABLEREGION '('
562         error ')'                   {$$ = AslDoError(); yyclearin;}
563     ;
564
565 DeviceTerm
566     : PARSEOP_DEVICE '('            {$<n>$ = TrCreateLeafNode (PARSEOP_DEVICE);}
567         NameString
568         ')' '{'
569             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
570     | PARSEOP_DEVICE '('
571         error ')'                   {$$ = AslDoError(); yyclearin;}
572     ;
573
574 EventTerm
575     : PARSEOP_EVENT '('             {$<n>$ = TrCreateLeafNode (PARSEOP_EVENT);}
576         NameString
577         ')'                         {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION));}
578     | PARSEOP_EVENT '('
579         error ')'                   {$$ = AslDoError(); yyclearin;}
580     ;
581
582 FieldTerm
583     : PARSEOP_FIELD '('             {$<n>$ = TrCreateLeafNode (PARSEOP_FIELD);}
584         NameString
585         ',' AccessTypeKeyword
586         ',' LockRuleKeyword
587         ',' UpdateRuleKeyword
588         ')' '{'
589             FieldUnitList '}'       {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);}
590     | PARSEOP_FIELD '('
591         error ')' '{' error '}'     {$$ = AslDoError(); yyclearin;}
592     ;
593
594 FunctionTerm
595     : PARSEOP_FUNCTION '('          {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);}
596         NameString
597         OptionalParameterTypePackage
598         OptionalParameterTypesPackage
599         ')' '{'
600             TermList '}'            {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),
601                                         TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),
602                                         TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL),
603                                         TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);}
604     | PARSEOP_FUNCTION '('
605         error ')'                   {$$ = AslDoError(); yyclearin;}
606     ;
607
608 IndexFieldTerm
609     : PARSEOP_INDEXFIELD '('        {$<n>$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);}
610         NameString
611         NameStringItem
612         ',' AccessTypeKeyword
613         ',' LockRuleKeyword
614         ',' UpdateRuleKeyword
615         ')' '{'
616             FieldUnitList '}'       {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);}
617     | PARSEOP_INDEXFIELD '('
618         error ')' '{' error '}'     {$$ = AslDoError(); yyclearin;}
619     ;
620
621 MethodTerm
622     : PARSEOP_METHOD  '('           {$<n>$ = TrCreateLeafNode (PARSEOP_METHOD);}
623         NameString
624         OptionalByteConstExpr       {UtCheckIntegerRange ($5, 0, 7);}
625         OptionalSerializeRuleKeyword
626         OptionalByteConstExpr
627         OptionalParameterTypePackage
628         OptionalParameterTypesPackage
629         ')' '{'
630             TermList '}'            {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);}
631     | PARSEOP_METHOD '('
632         error ')'                   {$$ = AslDoError(); yyclearin;}
633     ;
634
635 MutexTerm
636     : PARSEOP_MUTEX '('             {$<n>$ = TrCreateLeafNode (PARSEOP_MUTEX);}
637         NameString
638         ',' ByteConstExpr
639         ')'                         {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);}
640     | PARSEOP_MUTEX '('
641         error ')'                   {$$ = AslDoError(); yyclearin;}
642     ;
643
644 OpRegionTerm
645     : PARSEOP_OPERATIONREGION '('   {$<n>$ = TrCreateLeafNode (PARSEOP_OPERATIONREGION);}
646         NameString
647         ',' OpRegionSpaceIdTerm
648         TermArgItem
649         TermArgItem
650         ')'                         {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8);}
651     | PARSEOP_OPERATIONREGION '('
652         error ')'                   {$$ = AslDoError(); yyclearin;}
653     ;
654
655 OpRegionSpaceIdTerm
656     : RegionSpaceKeyword            {}
657     | ByteConst                     {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);}
658     ;
659
660 PowerResTerm
661     : PARSEOP_POWERRESOURCE '('     {$<n>$ = TrCreateLeafNode (PARSEOP_POWERRESOURCE);}
662         NameString
663         ',' ByteConstExpr
664         ',' WordConstExpr
665         ')' '{'
666             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,4,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$8,$11);}
667     | PARSEOP_POWERRESOURCE '('
668         error ')'                   {$$ = AslDoError(); yyclearin;}
669     ;
670
671 ProcessorTerm
672     : PARSEOP_PROCESSOR '('         {$<n>$ = TrCreateLeafNode (PARSEOP_PROCESSOR);}
673         NameString
674         ',' ByteConstExpr
675         OptionalDWordConstExpr
676         OptionalByteConstExpr
677         ')' '{'
678             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6,$7,$8,$11);}
679     | PARSEOP_PROCESSOR '('
680         error ')'                   {$$ = AslDoError(); yyclearin;}
681     ;
682
683 ThermalZoneTerm
684     : PARSEOP_THERMALZONE '('       {$<n>$ = TrCreateLeafNode (PARSEOP_THERMALZONE);}
685         NameString
686         ')' '{'
687             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
688     | PARSEOP_THERMALZONE '('
689         error ')'                   {$$ = AslDoError(); yyclearin;}
690     ;
691
692
693 /******* Namespace modifiers *************************************************/
694
695
696 AliasTerm
697     : PARSEOP_ALIAS '('             {$<n>$ = TrCreateLeafNode (PARSEOP_ALIAS);}
698         NameString
699         NameStringItem
700         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($5, NODE_IS_NAME_DECLARATION));}
701     | PARSEOP_ALIAS '('
702         error ')'                   {$$ = AslDoError(); yyclearin;}
703     ;
704
705 NameTerm
706     : PARSEOP_NAME '('              {$<n>$ = TrCreateLeafNode (PARSEOP_NAME);}
707         NameString
708         ',' DataObject
709         ')'                         {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$6);}
710     | PARSEOP_NAME '('
711         error ')'                   {$$ = AslDoError(); yyclearin;}
712     ;
713
714 ScopeTerm
715     : PARSEOP_SCOPE '('             {$<n>$ = TrCreateLeafNode (PARSEOP_SCOPE);}
716         NameString
717         ')' '{'
718             ObjectList '}'          {$$ = TrLinkChildren ($<n>3,2,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$7);}
719     | PARSEOP_SCOPE '('
720         error ')'                   {$$ = AslDoError(); yyclearin;}
721     ;
722
723
724 /******* Type 1 opcodes *******************************************************/
725
726
727 BreakTerm
728     : PARSEOP_BREAK                 {$$ = TrCreateNode (PARSEOP_BREAK, 0);}
729     ;
730
731 BreakPointTerm
732     : PARSEOP_BREAKPOINT            {$$ = TrCreateNode (PARSEOP_BREAKPOINT, 0);}
733     ;
734
735 ContinueTerm
736     : PARSEOP_CONTINUE              {$$ = TrCreateNode (PARSEOP_CONTINUE, 0);}
737     ;
738
739 FatalTerm
740     : PARSEOP_FATAL '('             {$<n>$ = TrCreateLeafNode (PARSEOP_FATAL);}
741         ByteConstExpr
742         ',' DWordConstExpr
743         TermArgItem
744         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);}
745     | PARSEOP_FATAL '('
746         error ')'                   {$$ = AslDoError(); yyclearin;}
747     ;
748
749 IfElseTerm
750     : IfTerm ElseTerm               {$$ = TrLinkPeerNode ($1,$2);}
751     ;
752
753 IfTerm
754     : PARSEOP_IF '('                {$<n>$ = TrCreateLeafNode (PARSEOP_IF);}
755         TermArg
756         ')' '{'
757             TermList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
758
759     | PARSEOP_IF '('
760         error ')'                   {$$ = AslDoError(); yyclearin;}
761     ;
762
763 ElseTerm
764     :                               {$$ = NULL;}
765     | PARSEOP_ELSE '{'              {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);}
766         TermList '}'                {$$ = TrLinkChildren ($<n>3,1,$4);}
767
768     | PARSEOP_ELSE '{'
769         error '}'                   {$$ = AslDoError(); yyclearin;}
770
771     | PARSEOP_ELSE
772         error                       {$$ = AslDoError(); yyclearin;}
773
774     | PARSEOP_ELSEIF '('            {$<n>$ = TrCreateLeafNode (PARSEOP_ELSE);}
775         TermArg                     {$<n>$ = TrCreateLeafNode (PARSEOP_IF);}
776         ')' '{'
777             TermList '}'            {TrLinkChildren ($<n>5,2,$4,$8);}
778         ElseTerm                    {TrLinkPeerNode ($<n>5,$11);}
779                                     {$$ = TrLinkChildren ($<n>3,1,$<n>5);}
780
781     | PARSEOP_ELSEIF '('
782         error ')'                   {$$ = AslDoError(); yyclearin;}
783
784     | PARSEOP_ELSEIF
785         error                       {$$ = AslDoError(); yyclearin;}
786     ;
787
788 LoadTerm
789     : PARSEOP_LOAD '('              {$<n>$ = TrCreateLeafNode (PARSEOP_LOAD);}
790         NameString
791         RequiredTarget
792         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
793     | PARSEOP_LOAD '('
794         error ')'                   {$$ = AslDoError(); yyclearin;}
795     ;
796
797 NoOpTerm
798     : PARSEOP_NOOP                  {$$ = TrCreateNode (PARSEOP_NOOP, 0);}
799     ;
800
801 NotifyTerm
802     : PARSEOP_NOTIFY '('            {$<n>$ = TrCreateLeafNode (PARSEOP_NOTIFY);}
803         SuperName
804         TermArgItem
805         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
806     | PARSEOP_NOTIFY '('
807         error ')'                   {$$ = AslDoError(); yyclearin;}
808     ;
809
810 ReleaseTerm
811     : PARSEOP_RELEASE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_RELEASE);}
812         SuperName
813         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
814     | PARSEOP_RELEASE '('
815         error ')'                   {$$ = AslDoError(); yyclearin;}
816     ;
817
818 ResetTerm
819     : PARSEOP_RESET '('             {$<n>$ = TrCreateLeafNode (PARSEOP_RESET);}
820         SuperName
821         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
822     | PARSEOP_RESET '('
823         error ')'                   {$$ = AslDoError(); yyclearin;}
824     ;
825
826 ReturnTerm
827     : PARSEOP_RETURN '('            {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);}
828         OptionalReturnArg
829         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
830     | PARSEOP_RETURN                {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));}
831     | PARSEOP_RETURN '('
832         error ')'                   {$$ = AslDoError(); yyclearin;}
833     ;
834
835 SignalTerm
836     : PARSEOP_SIGNAL '('            {$<n>$ = TrCreateLeafNode (PARSEOP_SIGNAL);}
837         SuperName
838         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
839     | PARSEOP_SIGNAL '('
840         error ')'                   {$$ = AslDoError(); yyclearin;}
841     ;
842
843 SleepTerm
844     : PARSEOP_SLEEP '('             {$<n>$ = TrCreateLeafNode (PARSEOP_SLEEP);}
845         TermArg
846         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
847     | PARSEOP_SLEEP '('
848         error ')'                   {$$ = AslDoError(); yyclearin;}
849     ;
850
851 StallTerm
852     : PARSEOP_STALL '('             {$<n>$ = TrCreateLeafNode (PARSEOP_STALL);}
853         TermArg
854         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
855     | PARSEOP_STALL '('
856         error ')'                   {$$ = AslDoError(); yyclearin;}
857     ;
858
859 SwitchTerm
860     : PARSEOP_SWITCH '('            {$<n>$ = TrCreateLeafNode (PARSEOP_SWITCH);}
861         TermArg
862         ')' '{'
863             CaseDefaultTermList '}'
864                                     {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
865     | PARSEOP_SWITCH '('
866         error ')'                   {$$ = AslDoError(); yyclearin;}
867     ;
868
869 /*
870  * Case-Default list; allow only one Default term and unlimited Case terms
871  */
872
873 CaseDefaultTermList
874     :                               {$$ = NULL;}
875     | CaseTerm  {}
876     | DefaultTerm   {}
877     | CaseDefaultTermList
878         CaseTerm                    {$$ = TrLinkPeerNode ($1,$2);}
879     | CaseDefaultTermList
880         DefaultTerm                 {$$ = TrLinkPeerNode ($1,$2);}
881
882 /* Original - attempts to force zero or one default term within the switch */
883
884 /*
885 CaseDefaultTermList
886     :                               {$$ = NULL;}
887     | CaseTermList
888         DefaultTerm
889         CaseTermList                {$$ = TrLinkPeerNode ($1,TrLinkPeerNode ($2, $3));}
890     | CaseTermList
891         CaseTerm                    {$$ = TrLinkPeerNode ($1,$2);}
892     ;
893
894 CaseTermList
895     :                               {$$ = NULL;}
896     | CaseTerm                      {}
897     | CaseTermList
898         CaseTerm                    {$$ = TrLinkPeerNode ($1,$2);}
899     ;
900 */
901
902 CaseTerm
903     : PARSEOP_CASE '('              {$<n>$ = TrCreateLeafNode (PARSEOP_CASE);}
904         DataObject
905         ')' '{'
906             TermList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
907     | PARSEOP_CASE '('
908         error ')'                   {$$ = AslDoError(); yyclearin;}
909     ;
910
911 DefaultTerm
912     : PARSEOP_DEFAULT '{'           {$<n>$ = TrCreateLeafNode (PARSEOP_DEFAULT);}
913         TermList '}'                {$$ = TrLinkChildren ($<n>3,1,$4);}
914     | PARSEOP_DEFAULT '{'
915         error '}'                   {$$ = AslDoError(); yyclearin;}
916     ;
917
918 UnloadTerm
919     : PARSEOP_UNLOAD '('            {$<n>$ = TrCreateLeafNode (PARSEOP_UNLOAD);}
920         SuperName
921         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
922     | PARSEOP_UNLOAD '('
923         error ')'                   {$$ = AslDoError(); yyclearin;}
924     ;
925
926 WhileTerm
927     : PARSEOP_WHILE '('             {$<n>$ = TrCreateLeafNode (PARSEOP_WHILE);}
928         TermArg
929         ')' '{' TermList '}'
930                                     {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
931     | PARSEOP_WHILE '('
932         error ')'                   {$$ = AslDoError(); yyclearin;}
933     ;
934
935
936 /******* Type 2 opcodes *******************************************************/
937
938 AcquireTerm
939     : PARSEOP_ACQUIRE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_ACQUIRE);}
940         SuperName
941         ',' WordConstExpr
942         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$6);}
943     | PARSEOP_ACQUIRE '('
944         error ')'                   {$$ = AslDoError(); yyclearin;}
945     ;
946
947 AddTerm
948     : PARSEOP_ADD '('               {$<n>$ = TrCreateLeafNode (PARSEOP_ADD);}
949         TermArg
950         TermArgItem
951         Target
952         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
953     | PARSEOP_ADD '('
954         error ')'                   {$$ = AslDoError(); yyclearin;}
955     ;
956
957 AndTerm
958     : PARSEOP_AND '('               {$<n>$ = TrCreateLeafNode (PARSEOP_AND);}
959         TermArg
960         TermArgItem
961         Target
962         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
963     | PARSEOP_AND '('
964         error ')'                   {$$ = AslDoError(); yyclearin;}
965     ;
966
967 ConcatTerm
968     : PARSEOP_CONCATENATE '('       {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATE);}
969         TermArg
970         TermArgItem
971         Target
972         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
973     | PARSEOP_CONCATENATE '('
974         error ')'                   {$$ = AslDoError(); yyclearin;}
975     ;
976
977 ConcatResTerm
978     : PARSEOP_CONCATENATERESTEMPLATE '('    {$<n>$ = TrCreateLeafNode (PARSEOP_CONCATENATERESTEMPLATE);}
979         TermArg
980         TermArgItem
981         Target
982         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
983     | PARSEOP_CONCATENATERESTEMPLATE '('
984         error ')'                   {$$ = AslDoError(); yyclearin;}
985     ;
986
987 CondRefOfTerm
988     : PARSEOP_CONDREFOF '('         {$<n>$ = TrCreateLeafNode (PARSEOP_CONDREFOF);}
989         SuperName
990         Target
991         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
992     | PARSEOP_CONDREFOF '('
993         error ')'                   {$$ = AslDoError(); yyclearin;}
994     ;
995
996 CopyObjectTerm
997     : PARSEOP_COPYOBJECT '('        {$<n>$ = TrCreateLeafNode (PARSEOP_COPYOBJECT);}
998         TermArg
999         ',' SimpleTarget
1000         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));}
1001     | PARSEOP_COPYOBJECT '('
1002         error ')'                   {$$ = AslDoError(); yyclearin;}
1003     ;
1004
1005 DecTerm
1006     : PARSEOP_DECREMENT '('         {$<n>$ = TrCreateLeafNode (PARSEOP_DECREMENT);}
1007         SuperName
1008         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1009     | PARSEOP_DECREMENT '('
1010         error ')'                   {$$ = AslDoError(); yyclearin;}
1011     ;
1012
1013 DerefOfTerm
1014     : PARSEOP_DEREFOF '('           {$<n>$ = TrCreateLeafNode (PARSEOP_DEREFOF);}
1015         TermArg
1016         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1017     | PARSEOP_DEREFOF '('
1018         error ')'                   {$$ = AslDoError(); yyclearin;}
1019     ;
1020
1021 DivideTerm
1022     : PARSEOP_DIVIDE '('            {$<n>$ = TrCreateLeafNode (PARSEOP_DIVIDE);}
1023         TermArg
1024         TermArgItem
1025         Target
1026         Target
1027         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);}
1028     | PARSEOP_DIVIDE '('
1029         error ')'                   {$$ = AslDoError(); yyclearin;}
1030     ;
1031
1032 FindSetLeftBitTerm
1033     : PARSEOP_FINDSETLEFTBIT '('    {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETLEFTBIT);}
1034         TermArg
1035         Target
1036         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1037     | PARSEOP_FINDSETLEFTBIT '('
1038         error ')'                   {$$ = AslDoError(); yyclearin;}
1039     ;
1040
1041 FindSetRightBitTerm
1042     : PARSEOP_FINDSETRIGHTBIT '('   {$<n>$ = TrCreateLeafNode (PARSEOP_FINDSETRIGHTBIT);}
1043         TermArg
1044         Target
1045         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1046     | PARSEOP_FINDSETRIGHTBIT '('
1047         error ')'                   {$$ = AslDoError(); yyclearin;}
1048     ;
1049
1050 FromBCDTerm
1051     : PARSEOP_FROMBCD '('           {$<n>$ = TrCreateLeafNode (PARSEOP_FROMBCD);}
1052         TermArg
1053         Target
1054         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1055     | PARSEOP_FROMBCD '('
1056         error ')'                   {$$ = AslDoError(); yyclearin;}
1057     ;
1058
1059 IncTerm
1060     : PARSEOP_INCREMENT '('         {$<n>$ = TrCreateLeafNode (PARSEOP_INCREMENT);}
1061         SuperName
1062         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1063     | PARSEOP_INCREMENT '('
1064         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 LGreaterTerm
1096     : PARSEOP_LGREATER '('          {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);}
1097         TermArg
1098         TermArgItem
1099         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1100     | PARSEOP_LGREATER '('
1101         error ')'                   {$$ = AslDoError(); yyclearin;}
1102     ;
1103
1104 LGreaterEqualTerm
1105     : PARSEOP_LGREATEREQUAL '('     {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);}
1106         TermArg
1107         TermArgItem
1108         ')'                         {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
1109     | PARSEOP_LGREATEREQUAL '('
1110         error ')'                   {$$ = AslDoError(); yyclearin;}
1111     ;
1112
1113 LLessTerm
1114     : PARSEOP_LLESS '('             {$<n>$ = TrCreateLeafNode (PARSEOP_LLESS);}
1115         TermArg
1116         TermArgItem
1117         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1118     | PARSEOP_LLESS '('
1119         error ')'                   {$$ = AslDoError(); yyclearin;}
1120     ;
1121
1122 LLessEqualTerm
1123     : PARSEOP_LLESSEQUAL '('        {$<n>$ = TrCreateLeafNode (PARSEOP_LGREATER);}
1124         TermArg
1125         TermArgItem
1126         ')'                         {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
1127     | PARSEOP_LLESSEQUAL '('
1128         error ')'                   {$$ = AslDoError(); yyclearin;}
1129     ;
1130
1131 LNotTerm
1132     : PARSEOP_LNOT '('              {$<n>$ = TrCreateLeafNode (PARSEOP_LNOT);}
1133         TermArg
1134         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1135     | PARSEOP_LNOT '('
1136         error ')'                   {$$ = AslDoError(); yyclearin;}
1137     ;
1138
1139 LNotEqualTerm
1140     : PARSEOP_LNOTEQUAL '('         {$<n>$ = TrCreateLeafNode (PARSEOP_LEQUAL);}
1141         TermArg
1142         TermArgItem
1143         ')'                         {$$ = TrCreateNode (PARSEOP_LNOT, 1, TrLinkChildren ($<n>3,2,$4,$5));}
1144     | PARSEOP_LNOTEQUAL '('
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 LOrTerm
1162     : PARSEOP_LOR '('               {$<n>$ = TrCreateLeafNode (PARSEOP_LOR);}
1163         TermArg
1164         TermArgItem
1165         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1166     | PARSEOP_LOR '('
1167         error ')'                   {$$ = AslDoError(); yyclearin;}
1168     ;
1169
1170 MatchTerm
1171     : PARSEOP_MATCH '('             {$<n>$ = TrCreateLeafNode (PARSEOP_MATCH);}
1172         TermArg
1173         ',' MatchOpKeyword
1174         TermArgItem
1175         ',' MatchOpKeyword
1176         TermArgItem
1177         TermArgItem
1178         ')'                         {$$ = TrLinkChildren ($<n>3,6,$4,$6,$7,$9,$10,$11);}
1179     | PARSEOP_MATCH '('
1180         error ')'                   {$$ = AslDoError(); yyclearin;}
1181     ;
1182
1183 MidTerm
1184     : PARSEOP_MID '('               {$<n>$ = TrCreateLeafNode (PARSEOP_MID);}
1185         TermArg
1186         TermArgItem
1187         TermArgItem
1188         Target
1189         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$5,$6,$7);}
1190     | PARSEOP_MID '('
1191         error ')'                   {$$ = AslDoError(); yyclearin;}
1192     ;
1193
1194 ModTerm
1195     : PARSEOP_MOD '('               {$<n>$ = TrCreateLeafNode (PARSEOP_MOD);}
1196         TermArg
1197         TermArgItem
1198         Target
1199         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1200     | PARSEOP_MOD '('
1201         error ')'                   {$$ = AslDoError(); yyclearin;}
1202     ;
1203
1204 MultiplyTerm
1205     : PARSEOP_MULTIPLY '('          {$<n>$ = TrCreateLeafNode (PARSEOP_MULTIPLY);}
1206         TermArg
1207         TermArgItem
1208         Target
1209         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1210     | PARSEOP_MULTIPLY '('
1211         error ')'                   {$$ = AslDoError(); yyclearin;}
1212     ;
1213
1214 NAndTerm
1215     : PARSEOP_NAND '('              {$<n>$ = TrCreateLeafNode (PARSEOP_NAND);}
1216         TermArg
1217         TermArgItem
1218         Target
1219         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1220     | PARSEOP_NAND '('
1221         error ')'                   {$$ = AslDoError(); yyclearin;}
1222     ;
1223
1224 NOrTerm
1225     : PARSEOP_NOR '('               {$<n>$ = TrCreateLeafNode (PARSEOP_NOR);}
1226         TermArg
1227         TermArgItem
1228         Target
1229         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1230     | PARSEOP_NOR '('
1231         error ')'                   {$$ = AslDoError(); yyclearin;}
1232     ;
1233
1234 NotTerm
1235     : PARSEOP_NOT '('               {$<n>$ = TrCreateLeafNode (PARSEOP_NOT);}
1236         TermArg
1237         Target
1238         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1239     | PARSEOP_NOT '('
1240         error ')'                   {$$ = AslDoError(); yyclearin;}
1241     ;
1242
1243 ObjectTypeTerm
1244     : PARSEOP_OBJECTTYPE '('        {$<n>$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE);}
1245         ObjectTypeName
1246         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1247     | PARSEOP_OBJECTTYPE '('
1248         error ')'                   {$$ = AslDoError(); yyclearin;}
1249     ;
1250
1251 OrTerm
1252     : PARSEOP_OR '('                {$<n>$ = TrCreateLeafNode (PARSEOP_OR);}
1253         TermArg
1254         TermArgItem
1255         Target
1256         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1257     | PARSEOP_OR '('
1258         error ')'                   {$$ = AslDoError(); yyclearin;}
1259     ;
1260
1261 /*
1262  * In RefOf, the node isn't really a target, but we can't keep track of it after
1263  * we've taken a pointer to it. (hard to tell if a local becomes initialized this way.)
1264  */
1265 RefOfTerm
1266     : PARSEOP_REFOF '('             {$<n>$ = TrCreateLeafNode (PARSEOP_REFOF);}
1267         SuperName
1268         ')'                         {$$ = TrLinkChildren ($<n>3,1,TrSetNodeFlags ($4, NODE_IS_TARGET));}
1269     | PARSEOP_REFOF '('
1270         error ')'                   {$$ = AslDoError(); yyclearin;}
1271     ;
1272
1273 ShiftLeftTerm
1274     : PARSEOP_SHIFTLEFT '('         {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTLEFT);}
1275         TermArg
1276         TermArgItem
1277         Target
1278         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1279     | PARSEOP_SHIFTLEFT '('
1280         error ')'                   {$$ = AslDoError(); yyclearin;}
1281     ;
1282
1283 ShiftRightTerm
1284     : PARSEOP_SHIFTRIGHT '('        {$<n>$ = TrCreateLeafNode (PARSEOP_SHIFTRIGHT);}
1285         TermArg
1286         TermArgItem
1287         Target
1288         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1289     | PARSEOP_SHIFTRIGHT '('
1290         error ')'                   {$$ = AslDoError(); yyclearin;}
1291     ;
1292
1293 SizeOfTerm
1294     : PARSEOP_SIZEOF '('            {$<n>$ = TrCreateLeafNode (PARSEOP_SIZEOF);}
1295         SuperName
1296         ')'                         {$$ = TrLinkChildren ($<n>3,1,$4);}
1297     | PARSEOP_SIZEOF '('
1298         error ')'                   {$$ = AslDoError(); yyclearin;}
1299     ;
1300
1301 StoreTerm
1302     : PARSEOP_STORE '('             {$<n>$ = TrCreateLeafNode (PARSEOP_STORE);}
1303         TermArg
1304         ',' SuperName
1305         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,TrSetNodeFlags ($6, NODE_IS_TARGET));}
1306     | PARSEOP_STORE '('
1307         error ')'                   {$$ = AslDoError(); yyclearin;}
1308     ;
1309
1310 SubtractTerm
1311     : PARSEOP_SUBTRACT '('          {$<n>$ = TrCreateLeafNode (PARSEOP_SUBTRACT);}
1312         TermArg
1313         TermArgItem
1314         Target
1315         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1316     | PARSEOP_SUBTRACT '('
1317         error ')'                   {$$ = AslDoError(); yyclearin;}
1318     ;
1319
1320 TimerTerm
1321     : PARSEOP_TIMER '('             {$<n>$ = TrCreateLeafNode (PARSEOP_TIMER);}
1322         ')'                         {$$ = TrLinkChildren ($<n>3,0);}
1323     | PARSEOP_TIMER                 {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_TIMER),0);}
1324     | PARSEOP_TIMER '('
1325         error ')'                   {$$ = AslDoError(); yyclearin;}
1326     ;
1327
1328 ToBCDTerm
1329     : PARSEOP_TOBCD '('             {$<n>$ = TrCreateLeafNode (PARSEOP_TOBCD);}
1330         TermArg
1331         Target
1332         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1333     | PARSEOP_TOBCD '('
1334         error ')'                   {$$ = AslDoError(); yyclearin;}
1335     ;
1336
1337 ToBufferTerm
1338     : PARSEOP_TOBUFFER '('          {$<n>$ = TrCreateLeafNode (PARSEOP_TOBUFFER);}
1339         TermArg
1340         Target
1341         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1342     | PARSEOP_TOBUFFER '('
1343         error ')'                   {$$ = AslDoError(); yyclearin;}
1344     ;
1345
1346 ToDecimalStringTerm
1347     : PARSEOP_TODECIMALSTRING '('   {$<n>$ = TrCreateLeafNode (PARSEOP_TODECIMALSTRING);}
1348         TermArg
1349         Target
1350         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1351     | PARSEOP_TODECIMALSTRING '('
1352         error ')'                   {$$ = AslDoError(); yyclearin;}
1353     ;
1354
1355 ToHexStringTerm
1356     : PARSEOP_TOHEXSTRING '('       {$<n>$ = TrCreateLeafNode (PARSEOP_TOHEXSTRING);}
1357         TermArg
1358         Target
1359         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1360     | PARSEOP_TOHEXSTRING '('
1361         error ')'                   {$$ = AslDoError(); yyclearin;}
1362     ;
1363
1364 ToIntegerTerm
1365     : PARSEOP_TOINTEGER '('         {$<n>$ = TrCreateLeafNode (PARSEOP_TOINTEGER);}
1366         TermArg
1367         Target
1368         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1369     | PARSEOP_TOINTEGER '('
1370         error ')'                   {$$ = AslDoError(); yyclearin;}
1371     ;
1372
1373 ToStringTerm
1374     : PARSEOP_TOSTRING '('          {$<n>$ = TrCreateLeafNode (PARSEOP_TOSTRING);}
1375         TermArg
1376         OptionalCount
1377         Target
1378         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1379     | PARSEOP_TOSTRING '('
1380         error ')'                   {$$ = AslDoError(); yyclearin;}
1381     ;
1382
1383 ToUUIDTerm
1384     : PARSEOP_TOUUID '('
1385         StringData ')'              {$$ = TrUpdateNode (PARSEOP_TOUUID, $3);}
1386     | PARSEOP_TOUUID '('
1387         error ')'                   {$$ = AslDoError(); yyclearin;}
1388     ;
1389
1390 WaitTerm
1391     : PARSEOP_WAIT '('              {$<n>$ = TrCreateLeafNode (PARSEOP_WAIT);}
1392         SuperName
1393         TermArgItem
1394         ')'                         {$$ = TrLinkChildren ($<n>3,2,$4,$5);}
1395     | PARSEOP_WAIT '('
1396         error ')'                   {$$ = AslDoError(); yyclearin;}
1397     ;
1398
1399 XOrTerm
1400     : PARSEOP_XOR '('               {$<n>$ = TrCreateLeafNode (PARSEOP_XOR);}
1401         TermArg
1402         TermArgItem
1403         Target
1404         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$5,$6);}
1405     | PARSEOP_XOR '('
1406         error ')'                   {$$ = AslDoError(); yyclearin;}
1407     ;
1408
1409
1410 /******* Keywords *************************************************************/
1411
1412
1413 AccessAttribKeyword
1414     : PARSEOP_ACCESSATTRIB_BLOCK            {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK);}
1415     | PARSEOP_ACCESSATTRIB_BLOCK_CALL       {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BLOCK_CALL);}
1416     | PARSEOP_ACCESSATTRIB_BYTE             {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_BYTE);}
1417     | PARSEOP_ACCESSATTRIB_QUICK            {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_QUICK );}
1418     | PARSEOP_ACCESSATTRIB_SND_RCV          {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_SND_RCV);}
1419     | PARSEOP_ACCESSATTRIB_WORD             {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD);}
1420     | PARSEOP_ACCESSATTRIB_WORD_CALL        {$$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_WORD_CALL);}
1421     | PARSEOP_ACCESSATTRIB_MULTIBYTE '('    {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_MULTIBYTE);}
1422         ByteConst
1423         ')'                                 {$$ = TrLinkChildren ($<n>3,1,$4);}
1424     | PARSEOP_ACCESSATTRIB_RAW_BYTES '('    {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_BYTES);}
1425         ByteConst
1426         ')'                                 {$$ = TrLinkChildren ($<n>3,1,$4);}
1427     | PARSEOP_ACCESSATTRIB_RAW_PROCESS '('  {$<n>$ = TrCreateLeafNode (PARSEOP_ACCESSATTRIB_RAW_PROCESS);}
1428         ByteConst
1429         ')'                                 {$$ = TrLinkChildren ($<n>3,1,$4);}
1430     ;
1431
1432 AccessTypeKeyword
1433     : PARSEOP_ACCESSTYPE_ANY                {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_ANY);}
1434     | PARSEOP_ACCESSTYPE_BYTE               {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BYTE);}
1435     | PARSEOP_ACCESSTYPE_WORD               {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_WORD);}
1436     | PARSEOP_ACCESSTYPE_DWORD              {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_DWORD);}
1437     | PARSEOP_ACCESSTYPE_QWORD              {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_QWORD);}
1438     | PARSEOP_ACCESSTYPE_BUF                {$$ = TrCreateLeafNode (PARSEOP_ACCESSTYPE_BUF);}
1439     ;
1440
1441 AddressingModeKeyword
1442     : PARSEOP_ADDRESSINGMODE_7BIT           {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_7BIT);}
1443     | PARSEOP_ADDRESSINGMODE_10BIT          {$$ = TrCreateLeafNode (PARSEOP_ADDRESSINGMODE_10BIT);}
1444     ;
1445
1446 AddressKeyword
1447     : PARSEOP_ADDRESSTYPE_MEMORY            {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_MEMORY);}
1448     | PARSEOP_ADDRESSTYPE_RESERVED          {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_RESERVED);}
1449     | PARSEOP_ADDRESSTYPE_NVS               {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_NVS);}
1450     | PARSEOP_ADDRESSTYPE_ACPI              {$$ = TrCreateLeafNode (PARSEOP_ADDRESSTYPE_ACPI);}
1451     ;
1452
1453 AddressSpaceKeyword
1454     : ByteConst                             {$$ = UtCheckIntegerRange ($1, 0x0A, 0xFF);}
1455     | RegionSpaceKeyword                    {}
1456     ;
1457
1458 BitsPerByteKeyword
1459     : PARSEOP_BITSPERBYTE_FIVE              {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_FIVE);}
1460     | PARSEOP_BITSPERBYTE_SIX               {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SIX);}
1461     | PARSEOP_BITSPERBYTE_SEVEN             {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_SEVEN);}
1462     | PARSEOP_BITSPERBYTE_EIGHT             {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_EIGHT);}
1463     | PARSEOP_BITSPERBYTE_NINE              {$$ = TrCreateLeafNode (PARSEOP_BITSPERBYTE_NINE);}
1464     ;
1465
1466 ClockPhaseKeyword
1467     : PARSEOP_CLOCKPHASE_FIRST              {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_FIRST);}
1468     | PARSEOP_CLOCKPHASE_SECOND             {$$ = TrCreateLeafNode (PARSEOP_CLOCKPHASE_SECOND);}
1469     ;
1470
1471 ClockPolarityKeyword
1472     : PARSEOP_CLOCKPOLARITY_LOW             {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_LOW);}
1473     | PARSEOP_CLOCKPOLARITY_HIGH            {$$ = TrCreateLeafNode (PARSEOP_CLOCKPOLARITY_HIGH);}
1474     ;
1475
1476 DecodeKeyword
1477     : PARSEOP_DECODETYPE_POS                {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_POS);}
1478     | PARSEOP_DECODETYPE_SUB                {$$ = TrCreateLeafNode (PARSEOP_DECODETYPE_SUB);}
1479     ;
1480
1481 DevicePolarityKeyword
1482     : PARSEOP_DEVICEPOLARITY_LOW            {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_LOW);}
1483     | PARSEOP_DEVICEPOLARITY_HIGH           {$$ = TrCreateLeafNode (PARSEOP_DEVICEPOLARITY_HIGH);}
1484     ;
1485
1486 DMATypeKeyword
1487     : PARSEOP_DMATYPE_A                     {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_A);}
1488     | PARSEOP_DMATYPE_COMPATIBILITY         {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_COMPATIBILITY);}
1489     | PARSEOP_DMATYPE_B                     {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_B);}
1490     | PARSEOP_DMATYPE_F                     {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);}
1491     ;
1492
1493 EndianKeyword
1494     : PARSEOP_ENDIAN_LITTLE                 {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_LITTLE);}
1495     | PARSEOP_ENDIAN_BIG                    {$$ = TrCreateLeafNode (PARSEOP_ENDIAN_BIG);}
1496     ;
1497
1498 FlowControlKeyword
1499     : PARSEOP_FLOWCONTROL_HW                {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_HW);}
1500     | PARSEOP_FLOWCONTROL_NONE              {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_NONE);}
1501     | PARSEOP_FLOWCONTROL_SW                {$$ = TrCreateLeafNode (PARSEOP_FLOWCONTROL_SW);}
1502     ;
1503
1504 InterruptLevel
1505     : PARSEOP_INTLEVEL_ACTIVEBOTH           {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEBOTH);}
1506     | PARSEOP_INTLEVEL_ACTIVEHIGH           {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVEHIGH);}
1507     | PARSEOP_INTLEVEL_ACTIVELOW            {$$ = TrCreateLeafNode (PARSEOP_INTLEVEL_ACTIVELOW);}
1508     ;
1509
1510 InterruptTypeKeyword
1511     : PARSEOP_INTTYPE_EDGE                  {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_EDGE);}
1512     | PARSEOP_INTTYPE_LEVEL                 {$$ = TrCreateLeafNode (PARSEOP_INTTYPE_LEVEL);}
1513     ;
1514
1515 IODecodeKeyword
1516     : PARSEOP_IODECODETYPE_16               {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_16);}
1517     | PARSEOP_IODECODETYPE_10               {$$ = TrCreateLeafNode (PARSEOP_IODECODETYPE_10);}
1518     ;
1519
1520 IoRestrictionKeyword
1521     : PARSEOP_IORESTRICT_IN                 {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_IN);}
1522     | PARSEOP_IORESTRICT_OUT                {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_OUT);}
1523     | PARSEOP_IORESTRICT_NONE               {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_NONE);}
1524     | PARSEOP_IORESTRICT_PRESERVE           {$$ = TrCreateLeafNode (PARSEOP_IORESTRICT_PRESERVE);}
1525     ;
1526
1527 LockRuleKeyword
1528     : PARSEOP_LOCKRULE_LOCK                 {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_LOCK);}
1529     | PARSEOP_LOCKRULE_NOLOCK               {$$ = TrCreateLeafNode (PARSEOP_LOCKRULE_NOLOCK);}
1530     ;
1531
1532 MatchOpKeyword
1533     : PARSEOP_MATCHTYPE_MTR                 {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR);}
1534     | PARSEOP_MATCHTYPE_MEQ                 {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ);}
1535     | PARSEOP_MATCHTYPE_MLE                 {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLE);}
1536     | PARSEOP_MATCHTYPE_MLT                 {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MLT);}
1537     | PARSEOP_MATCHTYPE_MGE                 {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGE);}
1538     | PARSEOP_MATCHTYPE_MGT                 {$$ = TrCreateLeafNode (PARSEOP_MATCHTYPE_MGT);}
1539     ;
1540
1541 MaxKeyword
1542     : PARSEOP_MAXTYPE_FIXED                 {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_FIXED);}
1543     | PARSEOP_MAXTYPE_NOTFIXED              {$$ = TrCreateLeafNode (PARSEOP_MAXTYPE_NOTFIXED);}
1544     ;
1545
1546 MemTypeKeyword
1547     : PARSEOP_MEMTYPE_CACHEABLE             {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_CACHEABLE);}
1548     | PARSEOP_MEMTYPE_WRITECOMBINING        {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_WRITECOMBINING);}
1549     | PARSEOP_MEMTYPE_PREFETCHABLE          {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_PREFETCHABLE);}
1550     | PARSEOP_MEMTYPE_NONCACHEABLE          {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);}
1551     ;
1552
1553 MinKeyword
1554     : PARSEOP_MINTYPE_FIXED                 {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_FIXED);}
1555     | PARSEOP_MINTYPE_NOTFIXED              {$$ = TrCreateLeafNode (PARSEOP_MINTYPE_NOTFIXED);}
1556     ;
1557
1558 ObjectTypeKeyword
1559     : PARSEOP_OBJECTTYPE_UNK                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);}
1560     | PARSEOP_OBJECTTYPE_INT                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_INT);}
1561     | PARSEOP_OBJECTTYPE_STR                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_STR);}
1562     | PARSEOP_OBJECTTYPE_BUF                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BUF);}
1563     | PARSEOP_OBJECTTYPE_PKG                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PKG);}
1564     | PARSEOP_OBJECTTYPE_FLD                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_FLD);}
1565     | PARSEOP_OBJECTTYPE_DEV                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DEV);}
1566     | PARSEOP_OBJECTTYPE_EVT                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_EVT);}
1567     | PARSEOP_OBJECTTYPE_MTH                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTH);}
1568     | PARSEOP_OBJECTTYPE_MTX                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);}
1569     | PARSEOP_OBJECTTYPE_OPR                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);}
1570     | PARSEOP_OBJECTTYPE_POW                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);}
1571     | PARSEOP_OBJECTTYPE_PRO                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);}
1572     | PARSEOP_OBJECTTYPE_THZ                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);}
1573     | PARSEOP_OBJECTTYPE_BFF                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);}
1574     | PARSEOP_OBJECTTYPE_DDB                {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);}
1575     ;
1576
1577 ParityTypeKeyword
1578     : PARSEOP_PARITYTYPE_SPACE              {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_SPACE);}
1579     | PARSEOP_PARITYTYPE_MARK               {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_MARK);}
1580     | PARSEOP_PARITYTYPE_ODD                {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_ODD);}
1581     | PARSEOP_PARITYTYPE_EVEN               {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_EVEN);}
1582     | PARSEOP_PARITYTYPE_NONE               {$$ = TrCreateLeafNode (PARSEOP_PARITYTYPE_NONE);}
1583     ;
1584
1585 PinConfigByte
1586     : PinConfigKeyword                      {$$ = $1;}
1587     | ByteConstExpr                         {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);}
1588     ;
1589
1590 PinConfigKeyword
1591     : PARSEOP_PIN_NOPULL                    {$$ = TrCreateLeafNode (PARSEOP_PIN_NOPULL);}
1592     | PARSEOP_PIN_PULLDOWN                  {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDOWN);}
1593     | PARSEOP_PIN_PULLUP                    {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLUP);}
1594     | PARSEOP_PIN_PULLDEFAULT               {$$ = TrCreateLeafNode (PARSEOP_PIN_PULLDEFAULT);}
1595     ;
1596
1597 RangeTypeKeyword
1598     : PARSEOP_RANGETYPE_ISAONLY             {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ISAONLY);}
1599     | PARSEOP_RANGETYPE_NONISAONLY          {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_NONISAONLY);}
1600     | PARSEOP_RANGETYPE_ENTIRE              {$$ = TrCreateLeafNode (PARSEOP_RANGETYPE_ENTIRE);}
1601     ;
1602
1603 RegionSpaceKeyword
1604     : PARSEOP_REGIONSPACE_IO                {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IO);}
1605     | PARSEOP_REGIONSPACE_MEM               {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_MEM);}
1606     | PARSEOP_REGIONSPACE_PCI               {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCI);}
1607     | PARSEOP_REGIONSPACE_EC                {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_EC);}
1608     | PARSEOP_REGIONSPACE_SMBUS             {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_SMBUS);}
1609     | PARSEOP_REGIONSPACE_CMOS              {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_CMOS);}
1610     | PARSEOP_REGIONSPACE_PCIBAR            {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCIBAR);}
1611     | PARSEOP_REGIONSPACE_IPMI              {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_IPMI);}
1612     | PARSEOP_REGIONSPACE_GPIO              {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GPIO);}
1613     | PARSEOP_REGIONSPACE_GSBUS             {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_GSBUS);}
1614     | PARSEOP_REGIONSPACE_PCC               {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_PCC);}
1615     | PARSEOP_REGIONSPACE_FFIXEDHW          {$$ = TrCreateLeafNode (PARSEOP_REGIONSPACE_FFIXEDHW);}
1616     ;
1617
1618 ResourceTypeKeyword
1619     : PARSEOP_RESOURCETYPE_CONSUMER         {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);}
1620     | PARSEOP_RESOURCETYPE_PRODUCER         {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_PRODUCER);}
1621     ;
1622
1623 SerializeRuleKeyword
1624     : PARSEOP_SERIALIZERULE_SERIAL          {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_SERIAL);}
1625     | PARSEOP_SERIALIZERULE_NOTSERIAL       {$$ = TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL);}
1626     ;
1627
1628 ShareTypeKeyword
1629     : PARSEOP_SHARETYPE_SHARED              {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHARED);}
1630     | PARSEOP_SHARETYPE_EXCLUSIVE           {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVE);}
1631     | PARSEOP_SHARETYPE_SHAREDWAKE          {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_SHAREDWAKE);}
1632     | PARSEOP_SHARETYPE_EXCLUSIVEWAKE       {$$ = TrCreateLeafNode (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);}
1633    ;
1634
1635 SlaveModeKeyword
1636     : PARSEOP_SLAVEMODE_CONTROLLERINIT      {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_CONTROLLERINIT);}
1637     | PARSEOP_SLAVEMODE_DEVICEINIT          {$$ = TrCreateLeafNode (PARSEOP_SLAVEMODE_DEVICEINIT);}
1638     ;
1639
1640 StopBitsKeyword
1641     : PARSEOP_STOPBITS_TWO                  {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_TWO);}
1642     | PARSEOP_STOPBITS_ONEPLUSHALF          {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONEPLUSHALF);}
1643     | PARSEOP_STOPBITS_ONE                  {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ONE);}
1644     | PARSEOP_STOPBITS_ZERO                 {$$ = TrCreateLeafNode (PARSEOP_STOPBITS_ZERO);}
1645     ;
1646
1647 TranslationKeyword
1648     : PARSEOP_TRANSLATIONTYPE_SPARSE        {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_SPARSE);}
1649     | PARSEOP_TRANSLATIONTYPE_DENSE         {$$ = TrCreateLeafNode (PARSEOP_TRANSLATIONTYPE_DENSE);}
1650     ;
1651
1652 TypeKeyword
1653     : PARSEOP_TYPE_TRANSLATION              {$$ = TrCreateLeafNode (PARSEOP_TYPE_TRANSLATION);}
1654     | PARSEOP_TYPE_STATIC                   {$$ = TrCreateLeafNode (PARSEOP_TYPE_STATIC);}
1655     ;
1656
1657 UpdateRuleKeyword
1658     : PARSEOP_UPDATERULE_PRESERVE           {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_PRESERVE);}
1659     | PARSEOP_UPDATERULE_ONES               {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ONES);}
1660     | PARSEOP_UPDATERULE_ZEROS              {$$ = TrCreateLeafNode (PARSEOP_UPDATERULE_ZEROS);}
1661     ;
1662
1663 WireModeKeyword
1664     : PARSEOP_WIREMODE_FOUR                 {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_FOUR);}
1665     | PARSEOP_WIREMODE_THREE                {$$ = TrCreateLeafNode (PARSEOP_WIREMODE_THREE);}
1666     ;
1667
1668 XferSizeKeyword
1669     : PARSEOP_XFERSIZE_8                    {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_8,   0);}
1670     | PARSEOP_XFERSIZE_16                   {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_16,  1);}
1671     | PARSEOP_XFERSIZE_32                   {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32,  2);}
1672     | PARSEOP_XFERSIZE_64                   {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_64,  3);}
1673     | PARSEOP_XFERSIZE_128                  {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_128, 4);}
1674     | PARSEOP_XFERSIZE_256                  {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_256, 5);}
1675     ;
1676
1677 XferTypeKeyword
1678     : PARSEOP_XFERTYPE_8                    {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);}
1679     | PARSEOP_XFERTYPE_8_16                 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);}
1680     | PARSEOP_XFERTYPE_16                   {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_16);}
1681     ;
1682
1683
1684 /******* Miscellaneous Types **************************************************/
1685
1686
1687 SuperName
1688     : NameString                    {}
1689     | ArgTerm                       {}
1690     | LocalTerm                     {}
1691     | DebugTerm                     {}
1692     | Type6Opcode                   {}
1693
1694 /* For ObjectType: SuperName except for UserTerm (method invocation) */
1695
1696 ObjectTypeName
1697     : NameString                    {}
1698     | ArgTerm                       {}
1699     | LocalTerm                     {}
1700     | DebugTerm                     {}
1701     | RefOfTerm                     {}
1702     | DerefOfTerm                   {}
1703     | IndexTerm                     {}
1704
1705 /*    | UserTerm                      {} */  /* Caused reduce/reduce with Type6Opcode->UserTerm */
1706     ;
1707
1708 ArgTerm
1709     : PARSEOP_ARG0                  {$$ = TrCreateLeafNode (PARSEOP_ARG0);}
1710     | PARSEOP_ARG1                  {$$ = TrCreateLeafNode (PARSEOP_ARG1);}
1711     | PARSEOP_ARG2                  {$$ = TrCreateLeafNode (PARSEOP_ARG2);}
1712     | PARSEOP_ARG3                  {$$ = TrCreateLeafNode (PARSEOP_ARG3);}
1713     | PARSEOP_ARG4                  {$$ = TrCreateLeafNode (PARSEOP_ARG4);}
1714     | PARSEOP_ARG5                  {$$ = TrCreateLeafNode (PARSEOP_ARG5);}
1715     | PARSEOP_ARG6                  {$$ = TrCreateLeafNode (PARSEOP_ARG6);}
1716     ;
1717
1718 LocalTerm
1719     : PARSEOP_LOCAL0                {$$ = TrCreateLeafNode (PARSEOP_LOCAL0);}
1720     | PARSEOP_LOCAL1                {$$ = TrCreateLeafNode (PARSEOP_LOCAL1);}
1721     | PARSEOP_LOCAL2                {$$ = TrCreateLeafNode (PARSEOP_LOCAL2);}
1722     | PARSEOP_LOCAL3                {$$ = TrCreateLeafNode (PARSEOP_LOCAL3);}
1723     | PARSEOP_LOCAL4                {$$ = TrCreateLeafNode (PARSEOP_LOCAL4);}
1724     | PARSEOP_LOCAL5                {$$ = TrCreateLeafNode (PARSEOP_LOCAL5);}
1725     | PARSEOP_LOCAL6                {$$ = TrCreateLeafNode (PARSEOP_LOCAL6);}
1726     | PARSEOP_LOCAL7                {$$ = TrCreateLeafNode (PARSEOP_LOCAL7);}
1727     ;
1728
1729 DebugTerm
1730     : PARSEOP_DEBUG                 {$$ = TrCreateLeafNode (PARSEOP_DEBUG);}
1731     ;
1732
1733
1734 ByteConst
1735     : Integer                       {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
1736     ;
1737
1738 WordConst
1739     : Integer                       {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
1740     ;
1741
1742 DWordConst
1743     : Integer                       {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
1744     ;
1745
1746 QWordConst
1747     : Integer                       {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
1748     ;
1749
1750 Integer
1751     : PARSEOP_INTEGER               {$$ = TrCreateValuedLeafNode (PARSEOP_INTEGER, AslCompilerlval.i);}
1752     ;
1753
1754 String
1755     : PARSEOP_STRING_LITERAL        {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, (ACPI_NATIVE_INT) AslCompilerlval.s);}
1756     ;
1757
1758 ConstTerm
1759     : ConstExprTerm                 {}
1760     | PARSEOP_REVISION              {$$ = TrCreateLeafNode (PARSEOP_REVISION);}
1761     ;
1762
1763 ConstExprTerm
1764     : PARSEOP_ZERO                  {$$ = TrCreateValuedLeafNode (PARSEOP_ZERO, 0);}
1765     | PARSEOP_ONE                   {$$ = TrCreateValuedLeafNode (PARSEOP_ONE, 1);}
1766     | PARSEOP_ONES                  {$$ = TrCreateValuedLeafNode (PARSEOP_ONES, ACPI_UINT64_MAX);}
1767     | PARSEOP___DATE__              {$$ = TrCreateConstantLeafNode (PARSEOP___DATE__);}
1768     | PARSEOP___FILE__              {$$ = TrCreateConstantLeafNode (PARSEOP___FILE__);}
1769     | PARSEOP___LINE__              {$$ = TrCreateConstantLeafNode (PARSEOP___LINE__);}
1770     | PARSEOP___PATH__              {$$ = TrCreateConstantLeafNode (PARSEOP___PATH__);}
1771     ;
1772
1773 /*
1774  * The NODE_COMPILE_TIME_CONST flag in the following constant expressions
1775  * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes
1776  * to simple integers. It is an error if these types of expressions cannot be
1777  * reduced, since the AML grammar for ****ConstExpr requires a simple constant.
1778  * Note: The required byte length of the constant is passed through to the
1779  * constant folding code in the node AmlLength field.
1780  */
1781 ByteConstExpr
1782     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);}
1783     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 1);}
1784     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_BYTECONST, $1);}
1785     | ByteConst                     {}
1786     ;
1787
1788 WordConstExpr
1789     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);}
1790     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 2);}
1791     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_WORDCONST, $1);}
1792     | WordConst                     {}
1793     ;
1794
1795 DWordConstExpr
1796     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);}
1797     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 4);}
1798     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_DWORDCONST, $1);}
1799     | DWordConst                    {}
1800     ;
1801
1802 QWordConstExpr
1803     : Type3Opcode                   {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);}
1804     | Type2IntegerOpcode            {$$ = TrSetNodeFlags ($1, NODE_COMPILE_TIME_CONST); TrSetNodeAmlLength ($1, 8);}
1805     | ConstExprTerm                 {$$ = TrUpdateNode (PARSEOP_QWORDCONST, $1);}
1806     | QWordConst                    {}
1807     ;
1808
1809 /* OptionalCount must appear before ByteList or an incorrect reduction will result */
1810
1811 OptionalCount
1812     :                               {$$ = TrCreateLeafNode (PARSEOP_ONES);}       /* Placeholder is a OnesOp object */
1813     | ','                           {$$ = TrCreateLeafNode (PARSEOP_ONES);}       /* Placeholder is a OnesOp object */
1814     | ',' TermArg                   {$$ = $2;}
1815     ;
1816
1817 BufferTerm
1818     : PARSEOP_BUFFER '('            {$<n>$ = TrCreateLeafNode (PARSEOP_BUFFER);}
1819         OptionalTermArg
1820         ')' '{'
1821             BufferTermData '}'      {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1822     | PARSEOP_BUFFER '('
1823         error ')'                   {$$ = AslDoError(); yyclearin;}
1824     ;
1825
1826 BufferTermData
1827     : ByteList                      {}
1828     | StringData                    {}
1829     ;
1830
1831 ByteList
1832     :                               {$$ = NULL;}
1833     | ByteConstExpr
1834     | ByteList ','                  /* Allows a trailing comma at list end */
1835     | ByteList ','
1836         ByteConstExpr               {$$ = TrLinkPeerNode ($1,$3);}
1837     ;
1838
1839 DataBufferTerm
1840     : PARSEOP_DATABUFFER  '('       {$<n>$ = TrCreateLeafNode (PARSEOP_DATABUFFER);}
1841         OptionalWordConst
1842         ')' '{'
1843             ByteList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1844     | PARSEOP_DATABUFFER '('
1845         error ')'                   {$$ = AslDoError(); yyclearin;}
1846     ;
1847
1848 DWordList
1849     :                               {$$ = NULL;}
1850     | DWordConstExpr
1851     | DWordList ','                 /* Allows a trailing comma at list end */
1852     | DWordList ','
1853         DWordConstExpr              {$$ = TrLinkPeerNode ($1,$3);}
1854     ;
1855
1856 PackageTerm
1857     : PARSEOP_PACKAGE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);}
1858         VarPackageLengthTerm
1859         ')' '{'
1860             PackageList '}'         {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
1861     | PARSEOP_PACKAGE '('
1862         error ')'                   {$$ = AslDoError(); yyclearin;}
1863     ;
1864
1865 PackageList
1866     :                               {$$ = NULL;}
1867     | PackageElement
1868     | PackageList ','               /* Allows a trailing comma at list end */
1869     | PackageList ','
1870         PackageElement              {$$ = TrLinkPeerNode ($1,$3);}
1871     ;
1872
1873 PackageElement
1874     : DataObject                    {}
1875     | NameString                    {}
1876     ;
1877
1878 VarPackageLengthTerm
1879     :                               {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);}
1880     | TermArg                       {$$ = $1;}
1881     ;
1882
1883
1884 /******* Macros ***********************************************/
1885
1886
1887 EISAIDTerm
1888     : PARSEOP_EISAID '('
1889         StringData ')'              {$$ = TrUpdateNode (PARSEOP_EISAID, $3);}
1890     | PARSEOP_EISAID '('
1891         error ')'                   {$$ = AslDoError(); yyclearin;}
1892     ;
1893
1894 UnicodeTerm
1895     : PARSEOP_UNICODE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_UNICODE);}
1896         StringData
1897         ')'                         {$$ = TrLinkChildren ($<n>3,2,0,$4);}
1898     | PARSEOP_UNICODE '('
1899         error ')'                   {$$ = AslDoError(); yyclearin;}
1900     ;
1901
1902
1903 /******* Resources and Memory ***********************************************/
1904
1905
1906 /*
1907  * Note: Create two default nodes to allow conversion to a Buffer AML opcode
1908  * Also, insert the EndTag at the end of the template.
1909  */
1910 ResourceTemplateTerm
1911     : PARSEOP_RESOURCETEMPLATE '(' ')'
1912         '{'
1913         ResourceMacroList '}'       {$$ = TrCreateNode (PARSEOP_RESOURCETEMPLATE,4,
1914                                           TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
1915                                           TrCreateLeafNode (PARSEOP_DEFAULT_ARG),
1916                                           $5,
1917                                           TrCreateLeafNode (PARSEOP_ENDTAG));}
1918     ;
1919
1920 ResourceMacroList
1921     :                               {$$ = NULL;}
1922     | ResourceMacroList
1923         ResourceMacroTerm           {$$ = TrLinkPeerNode ($1,$2);}
1924     ;
1925
1926 ResourceMacroTerm
1927     : DMATerm                       {}
1928     | DWordIOTerm                   {}
1929     | DWordMemoryTerm               {}
1930     | DWordSpaceTerm                {}
1931     | EndDependentFnTerm            {}
1932     | ExtendedIOTerm                {}
1933     | ExtendedMemoryTerm            {}
1934     | ExtendedSpaceTerm             {}
1935     | FixedDmaTerm                  {}
1936     | FixedIOTerm                   {}
1937     | GpioIntTerm                   {}
1938     | GpioIoTerm                    {}
1939     | I2cSerialBusTerm              {}
1940     | InterruptTerm                 {}
1941     | IOTerm                        {}
1942     | IRQNoFlagsTerm                {}
1943     | IRQTerm                       {}
1944     | Memory24Term                  {}
1945     | Memory32FixedTerm             {}
1946     | Memory32Term                  {}
1947     | QWordIOTerm                   {}
1948     | QWordMemoryTerm               {}
1949     | QWordSpaceTerm                {}
1950     | RegisterTerm                  {}
1951     | SpiSerialBusTerm              {}
1952     | StartDependentFnNoPriTerm     {}
1953     | StartDependentFnTerm          {}
1954     | UartSerialBusTerm             {}
1955     | VendorLongTerm                {}
1956     | VendorShortTerm               {}
1957     | WordBusNumberTerm             {}
1958     | WordIOTerm                    {}
1959     | WordSpaceTerm                 {}
1960     ;
1961
1962 DMATerm
1963     : PARSEOP_DMA '('               {$<n>$ = TrCreateLeafNode (PARSEOP_DMA);}
1964         DMATypeKeyword
1965         OptionalBusMasterKeyword
1966         ',' XferTypeKeyword
1967         OptionalNameString_Last
1968         ')' '{'
1969             ByteList '}'            {$$ = TrLinkChildren ($<n>3,5,$4,$5,$7,$8,$11);}
1970     | PARSEOP_DMA '('
1971         error ')'                   {$$ = AslDoError(); yyclearin;}
1972     ;
1973
1974 DWordIOTerm
1975     : PARSEOP_DWORDIO '('           {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDIO);}
1976         OptionalResourceType_First
1977         OptionalMinType
1978         OptionalMaxType
1979         OptionalDecodeType
1980         OptionalRangeType
1981         ',' DWordConstExpr
1982         ',' DWordConstExpr
1983         ',' DWordConstExpr
1984         ',' DWordConstExpr
1985         ',' DWordConstExpr
1986         OptionalByteConstExpr
1987         OptionalStringData
1988         OptionalNameString
1989         OptionalType
1990         OptionalTranslationType_Last
1991         ')'                         {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);}
1992     | PARSEOP_DWORDIO '('
1993         error ')'                   {$$ = AslDoError(); yyclearin;}
1994     ;
1995
1996 DWordMemoryTerm
1997     : PARSEOP_DWORDMEMORY '('       {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDMEMORY);}
1998         OptionalResourceType_First
1999         OptionalDecodeType
2000         OptionalMinType
2001         OptionalMaxType
2002         OptionalMemType
2003         ',' OptionalReadWriteKeyword
2004         ',' DWordConstExpr
2005         ',' DWordConstExpr
2006         ',' DWordConstExpr
2007         ',' DWordConstExpr
2008         ',' DWordConstExpr
2009         OptionalByteConstExpr
2010         OptionalStringData
2011         OptionalNameString
2012         OptionalAddressRange
2013         OptionalType_Last
2014         ')'                         {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);}
2015     | PARSEOP_DWORDMEMORY '('
2016         error ')'                   {$$ = AslDoError(); yyclearin;}
2017     ;
2018
2019 DWordSpaceTerm
2020     : PARSEOP_DWORDSPACE '('        {$<n>$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);}
2021         ByteConstExpr               {UtCheckIntegerRange ($4, 0xC0, 0xFF);}
2022         OptionalResourceType
2023         OptionalDecodeType
2024         OptionalMinType
2025         OptionalMaxType
2026         ',' ByteConstExpr
2027         ',' DWordConstExpr
2028         ',' DWordConstExpr
2029         ',' DWordConstExpr
2030         ',' DWordConstExpr
2031         ',' DWordConstExpr
2032         OptionalByteConstExpr
2033         OptionalStringData
2034         OptionalNameString_Last
2035         ')'                         {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);}
2036     | PARSEOP_DWORDSPACE '('
2037         error ')'                   {$$ = AslDoError(); yyclearin;}
2038     ;
2039
2040
2041 EndDependentFnTerm
2042     : PARSEOP_ENDDEPENDENTFN '('
2043         ')'                         {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);}
2044     | PARSEOP_ENDDEPENDENTFN '('
2045         error ')'                   {$$ = AslDoError(); yyclearin;}
2046     ;
2047
2048 ExtendedIOTerm
2049     : PARSEOP_EXTENDEDIO '('        {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);}
2050         OptionalResourceType_First
2051         OptionalMinType
2052         OptionalMaxType
2053         OptionalDecodeType
2054         OptionalRangeType
2055         ',' QWordConstExpr
2056         ',' QWordConstExpr
2057         ',' QWordConstExpr
2058         ',' QWordConstExpr
2059         ',' QWordConstExpr
2060         OptionalQWordConstExpr
2061         OptionalNameString
2062         OptionalType
2063         OptionalTranslationType_Last
2064         ')'                         {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);}
2065     | PARSEOP_EXTENDEDIO '('
2066         error ')'                   {$$ = AslDoError(); yyclearin;}
2067     ;
2068
2069 ExtendedMemoryTerm
2070     : PARSEOP_EXTENDEDMEMORY '('    {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);}
2071         OptionalResourceType_First
2072         OptionalDecodeType
2073         OptionalMinType
2074         OptionalMaxType
2075         OptionalMemType
2076         ',' OptionalReadWriteKeyword
2077         ',' QWordConstExpr
2078         ',' QWordConstExpr
2079         ',' QWordConstExpr
2080         ',' QWordConstExpr
2081         ',' QWordConstExpr
2082         OptionalQWordConstExpr
2083         OptionalNameString
2084         OptionalAddressRange
2085         OptionalType_Last
2086         ')'                         {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);}
2087     | PARSEOP_EXTENDEDMEMORY '('
2088         error ')'                   {$$ = AslDoError(); yyclearin;}
2089     ;
2090
2091 ExtendedSpaceTerm
2092     : PARSEOP_EXTENDEDSPACE '('     {$<n>$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);}
2093         ByteConstExpr               {UtCheckIntegerRange ($4, 0xC0, 0xFF);}
2094         OptionalResourceType
2095         OptionalDecodeType
2096         OptionalMinType
2097         OptionalMaxType
2098         ',' ByteConstExpr
2099         ',' QWordConstExpr
2100         ',' QWordConstExpr
2101         ',' QWordConstExpr
2102         ',' QWordConstExpr
2103         ',' QWordConstExpr
2104         OptionalQWordConstExpr
2105         OptionalNameString_Last
2106         ')'                         {$$ = TrLinkChildren ($<n>3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);}
2107     | PARSEOP_EXTENDEDSPACE '('
2108         error ')'                   {$$ = AslDoError(); yyclearin;}
2109     ;
2110
2111 FixedDmaTerm
2112     : PARSEOP_FIXEDDMA '('          {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDDMA);}
2113         WordConstExpr               /* 04: DMA RequestLines */
2114         ',' WordConstExpr           /* 06: DMA Channels */
2115         OptionalXferSize            /* 07: DMA TransferSize */
2116         OptionalNameString          /* 08: DescriptorName */
2117         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$6,$7,$8);}
2118     | PARSEOP_FIXEDDMA '('
2119         error ')'                   {$$ = AslDoError(); yyclearin;}
2120     ;
2121
2122 FixedIOTerm
2123     : PARSEOP_FIXEDIO '('           {$<n>$ = TrCreateLeafNode (PARSEOP_FIXEDIO);}
2124         WordConstExpr
2125         ',' ByteConstExpr
2126         OptionalNameString_Last
2127         ')'                         {$$ = TrLinkChildren ($<n>3,3,$4,$6,$7);}
2128     | PARSEOP_FIXEDIO '('
2129         error ')'                   {$$ = AslDoError(); yyclearin;}
2130     ;
2131
2132 GpioIntTerm
2133     : PARSEOP_GPIO_INT '('          {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_INT);}
2134         InterruptTypeKeyword        /* 04: InterruptType */
2135         ',' InterruptLevel          /* 06: InterruptLevel */
2136         OptionalShareType           /* 07: SharedType */
2137         ',' PinConfigByte           /* 09: PinConfig */
2138         OptionalWordConstExpr       /* 10: DebounceTimeout */
2139         ',' StringData              /* 12: ResourceSource */
2140         OptionalByteConstExpr       /* 13: ResourceSourceIndex */
2141         OptionalResourceType        /* 14: ResourceType */
2142         OptionalNameString          /* 15: DescriptorName */
2143         OptionalBuffer_Last         /* 16: VendorData */
2144         ')' '{'
2145             DWordConstExpr '}'      {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$9,$10,$12,$13,$14,$15,$16,$19);}
2146     | PARSEOP_GPIO_INT '('
2147         error ')'                   {$$ = AslDoError(); yyclearin;}
2148     ;
2149
2150 GpioIoTerm
2151     : PARSEOP_GPIO_IO '('           {$<n>$ = TrCreateLeafNode (PARSEOP_GPIO_IO);}
2152         OptionalShareType_First     /* 04: SharedType */
2153         ',' PinConfigByte           /* 06: PinConfig */
2154         OptionalWordConstExpr       /* 07: DebounceTimeout */
2155         OptionalWordConstExpr       /* 08: DriveStrength */
2156         OptionalIoRestriction       /* 09: IoRestriction */
2157         ',' StringData              /* 11: ResourceSource */
2158         OptionalByteConstExpr       /* 12: ResourceSourceIndex */
2159         OptionalResourceType        /* 13: ResourceType */
2160         OptionalNameString          /* 14: DescriptorName */
2161         OptionalBuffer_Last         /* 15: VendorData */
2162         ')' '{'
2163             DWordList '}'           {$$ = TrLinkChildren ($<n>3,11,$4,$6,$7,$8,$9,$11,$12,$13,$14,$15,$18);}
2164     | PARSEOP_GPIO_IO '('
2165         error ')'                   {$$ = AslDoError(); yyclearin;}
2166     ;
2167
2168 I2cSerialBusTerm
2169     : PARSEOP_I2C_SERIALBUS '('     {$<n>$ = TrCreateLeafNode (PARSEOP_I2C_SERIALBUS);}
2170         WordConstExpr               /* 04: SlaveAddress */
2171         OptionalSlaveMode           /* 05: SlaveMode */
2172         ',' DWordConstExpr          /* 07: ConnectionSpeed */
2173         OptionalAddressingMode      /* 08: AddressingMode */
2174         ',' StringData              /* 10: ResourceSource */
2175         OptionalByteConstExpr       /* 11: ResourceSourceIndex */
2176         OptionalResourceType        /* 12: ResourceType */
2177         OptionalNameString          /* 13: DescriptorName */
2178         OptionalBuffer_Last         /* 14: VendorData */
2179         ')'                         {$$ = TrLinkChildren ($<n>3,9,$4,$5,$7,$8,$10,$11,$12,$13,$14);}
2180     | PARSEOP_I2C_SERIALBUS '('
2181         error ')'                   {$$ = AslDoError(); yyclearin;}
2182     ;
2183
2184 InterruptTerm
2185     : PARSEOP_INTERRUPT '('         {$<n>$ = TrCreateLeafNode (PARSEOP_INTERRUPT);}
2186         OptionalResourceType_First
2187         ',' InterruptTypeKeyword
2188         ',' InterruptLevel
2189         OptionalShareType
2190         OptionalByteConstExpr
2191         OptionalStringData
2192         OptionalNameString_Last
2193         ')' '{'
2194             DWordList '}'           {$$ = TrLinkChildren ($<n>3,8,$4,$6,$8,$9,$10,$11,$12,$15);}
2195     | PARSEOP_INTERRUPT '('
2196         error ')'                   {$$ = AslDoError(); yyclearin;}
2197     ;
2198
2199 IOTerm
2200     : PARSEOP_IO '('                {$<n>$ = TrCreateLeafNode (PARSEOP_IO);}
2201         IODecodeKeyword
2202         ',' WordConstExpr
2203         ',' WordConstExpr
2204         ',' ByteConstExpr
2205         ',' ByteConstExpr
2206         OptionalNameString_Last
2207         ')'                         {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);}
2208     | PARSEOP_IO '('
2209         error ')'                   {$$ = AslDoError(); yyclearin;}
2210     ;
2211
2212 IRQNoFlagsTerm
2213     : PARSEOP_IRQNOFLAGS '('        {$<n>$ = TrCreateLeafNode (PARSEOP_IRQNOFLAGS);}
2214         OptionalNameString_First
2215         ')' '{'
2216             ByteList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
2217     | PARSEOP_IRQNOFLAGS '('
2218         error ')'                   {$$ = AslDoError(); yyclearin;}
2219     ;
2220
2221 IRQTerm
2222     : PARSEOP_IRQ '('               {$<n>$ = TrCreateLeafNode (PARSEOP_IRQ);}
2223         InterruptTypeKeyword
2224         ',' InterruptLevel
2225         OptionalShareType
2226         OptionalNameString_Last
2227         ')' '{'
2228             ByteList '}'            {$$ = TrLinkChildren ($<n>3,5,$4,$6,$7,$8,$11);}
2229     | PARSEOP_IRQ '('
2230         error ')'                   {$$ = AslDoError(); yyclearin;}
2231     ;
2232
2233 Memory24Term
2234     : PARSEOP_MEMORY24 '('          {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY24);}
2235         OptionalReadWriteKeyword
2236         ',' WordConstExpr
2237         ',' WordConstExpr
2238         ',' WordConstExpr
2239         ',' WordConstExpr
2240         OptionalNameString_Last
2241         ')'                         {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);}
2242     | PARSEOP_MEMORY24 '('
2243         error ')'                   {$$ = AslDoError(); yyclearin;}
2244     ;
2245
2246 Memory32FixedTerm
2247     : PARSEOP_MEMORY32FIXED '('     {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);}
2248         OptionalReadWriteKeyword
2249         ',' DWordConstExpr
2250         ',' DWordConstExpr
2251         OptionalNameString_Last
2252         ')'                         {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$9);}
2253     | PARSEOP_MEMORY32FIXED '('
2254         error ')'                   {$$ = AslDoError(); yyclearin;}
2255     ;
2256
2257 Memory32Term
2258     : PARSEOP_MEMORY32 '('          {$<n>$ = TrCreateLeafNode (PARSEOP_MEMORY32);}
2259         OptionalReadWriteKeyword
2260         ',' DWordConstExpr
2261         ',' DWordConstExpr
2262         ',' DWordConstExpr
2263         ',' DWordConstExpr
2264         OptionalNameString_Last
2265         ')'                         {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$12,$13);}
2266     | PARSEOP_MEMORY32 '('
2267         error ')'                   {$$ = AslDoError(); yyclearin;}
2268     ;
2269
2270 QWordIOTerm
2271     : PARSEOP_QWORDIO '('           {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDIO);}
2272         OptionalResourceType_First
2273         OptionalMinType
2274         OptionalMaxType
2275         OptionalDecodeType
2276         OptionalRangeType
2277         ',' QWordConstExpr
2278         ',' QWordConstExpr
2279         ',' QWordConstExpr
2280         ',' QWordConstExpr
2281         ',' QWordConstExpr
2282         OptionalByteConstExpr
2283         OptionalStringData
2284         OptionalNameString
2285         OptionalType
2286         OptionalTranslationType_Last
2287         ')'                         {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);}
2288     | PARSEOP_QWORDIO '('
2289         error ')'                   {$$ = AslDoError(); yyclearin;}
2290     ;
2291
2292 QWordMemoryTerm
2293     : PARSEOP_QWORDMEMORY '('       {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDMEMORY);}
2294         OptionalResourceType_First
2295         OptionalDecodeType
2296         OptionalMinType
2297         OptionalMaxType
2298         OptionalMemType
2299         ',' OptionalReadWriteKeyword
2300         ',' QWordConstExpr
2301         ',' QWordConstExpr
2302         ',' QWordConstExpr
2303         ',' QWordConstExpr
2304         ',' QWordConstExpr
2305         OptionalByteConstExpr
2306         OptionalStringData
2307         OptionalNameString
2308         OptionalAddressRange
2309         OptionalType_Last
2310         ')'                         {$$ = TrLinkChildren ($<n>3,16,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24,$25);}
2311     | PARSEOP_QWORDMEMORY '('
2312         error ')'                   {$$ = AslDoError(); yyclearin;}
2313     ;
2314
2315 QWordSpaceTerm
2316     : PARSEOP_QWORDSPACE '('        {$<n>$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);}
2317         ByteConstExpr               {UtCheckIntegerRange ($4, 0xC0, 0xFF);}
2318         OptionalResourceType
2319         OptionalDecodeType
2320         OptionalMinType
2321         OptionalMaxType
2322         ',' ByteConstExpr
2323         ',' QWordConstExpr
2324         ',' QWordConstExpr
2325         ',' QWordConstExpr
2326         ',' QWordConstExpr
2327         ',' QWordConstExpr
2328         OptionalByteConstExpr
2329         OptionalStringData
2330         OptionalNameString_Last
2331         ')'                         {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);}
2332     | PARSEOP_QWORDSPACE '('
2333         error ')'                   {$$ = AslDoError(); yyclearin;}
2334     ;
2335
2336 RegisterTerm
2337     : PARSEOP_REGISTER '('          {$<n>$ = TrCreateLeafNode (PARSEOP_REGISTER);}
2338         AddressSpaceKeyword
2339         ',' ByteConstExpr
2340         ',' ByteConstExpr
2341         ',' QWordConstExpr
2342         OptionalAccessSize
2343         OptionalNameString_Last
2344         ')'                         {$$ = TrLinkChildren ($<n>3,6,$4,$6,$8,$10,$11,$12);}
2345     | PARSEOP_REGISTER '('
2346         error ')'                   {$$ = AslDoError(); yyclearin;}
2347     ;
2348
2349 SpiSerialBusTerm
2350     : PARSEOP_SPI_SERIALBUS '('     {$<n>$ = TrCreateLeafNode (PARSEOP_SPI_SERIALBUS);}
2351         WordConstExpr               /* 04: DeviceSelection */
2352         OptionalDevicePolarity      /* 05: DevicePolarity */
2353         OptionalWireMode            /* 06: WireMode */
2354         ',' ByteConstExpr           /* 08: DataBitLength */
2355         OptionalSlaveMode           /* 09: SlaveMode */
2356         ',' DWordConstExpr          /* 11: ConnectionSpeed */
2357         ',' ClockPolarityKeyword    /* 13: ClockPolarity */
2358         ',' ClockPhaseKeyword       /* 15: ClockPhase */
2359         ',' StringData              /* 17: ResourceSource */
2360         OptionalByteConstExpr       /* 18: ResourceSourceIndex */
2361         OptionalResourceType        /* 19: ResourceType */
2362         OptionalNameString          /* 20: DescriptorName */
2363         OptionalBuffer_Last         /* 21: VendorData */
2364         ')'                         {$$ = TrLinkChildren ($<n>3,13,$4,$5,$6,$8,$9,$11,$13,$15,$17,$18,$19,$20,$21);}
2365     | PARSEOP_SPI_SERIALBUS '('
2366         error ')'                   {$$ = AslDoError(); yyclearin;}
2367     ;
2368
2369 StartDependentFnNoPriTerm
2370     : PARSEOP_STARTDEPENDENTFN_NOPRI '('    {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN_NOPRI);}
2371         ')' '{'
2372         ResourceMacroList '}'       {$$ = TrLinkChildren ($<n>3,1,$6);}
2373     | PARSEOP_STARTDEPENDENTFN_NOPRI '('
2374         error ')'                   {$$ = AslDoError(); yyclearin;}
2375     ;
2376
2377 StartDependentFnTerm
2378     : PARSEOP_STARTDEPENDENTFN '('  {$<n>$ = TrCreateLeafNode (PARSEOP_STARTDEPENDENTFN);}
2379         ByteConstExpr
2380         ',' ByteConstExpr
2381         ')' '{'
2382         ResourceMacroList '}'       {$$ = TrLinkChildren ($<n>3,3,$4,$6,$9);}
2383     | PARSEOP_STARTDEPENDENTFN '('
2384         error ')'                   {$$ = AslDoError(); yyclearin;}
2385     ;
2386
2387 UartSerialBusTerm
2388     : PARSEOP_UART_SERIALBUS '('    {$<n>$ = TrCreateLeafNode (PARSEOP_UART_SERIALBUS);}
2389         DWordConstExpr              /* 04: ConnectionSpeed */
2390         OptionalBitsPerByte         /* 05: BitsPerByte */
2391         OptionalStopBits            /* 06: StopBits */
2392         ',' ByteConstExpr           /* 08: LinesInUse */
2393         OptionalEndian              /* 09: Endianess */
2394         OptionalParityType          /* 10: Parity */
2395         OptionalFlowControl         /* 11: FlowControl */
2396         ',' WordConstExpr           /* 13: Rx BufferSize */
2397         ',' WordConstExpr           /* 15: Tx BufferSize */
2398         ',' StringData              /* 17: ResourceSource */
2399         OptionalByteConstExpr       /* 18: ResourceSourceIndex */
2400         OptionalResourceType        /* 19: ResourceType */
2401         OptionalNameString          /* 20: DescriptorName */
2402         OptionalBuffer_Last         /* 21: VendorData */
2403         ')'                         {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$8,$9,$10,$11,$13,$15,$17,$18,$19,$20,$21);}
2404     | PARSEOP_UART_SERIALBUS '('
2405         error ')'                   {$$ = AslDoError(); yyclearin;}
2406     ;
2407
2408 VendorLongTerm
2409     : PARSEOP_VENDORLONG '('        {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORLONG);}
2410         OptionalNameString_First
2411         ')' '{'
2412             ByteList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
2413     | PARSEOP_VENDORLONG '('
2414         error ')'                   {$$ = AslDoError(); yyclearin;}
2415     ;
2416
2417 VendorShortTerm
2418     : PARSEOP_VENDORSHORT '('       {$<n>$ = TrCreateLeafNode (PARSEOP_VENDORSHORT);}
2419         OptionalNameString_First
2420         ')' '{'
2421             ByteList '}'            {$$ = TrLinkChildren ($<n>3,2,$4,$7);}
2422     | PARSEOP_VENDORSHORT '('
2423         error ')'                   {$$ = AslDoError(); yyclearin;}
2424     ;
2425
2426 WordBusNumberTerm
2427     : PARSEOP_WORDBUSNUMBER '('     {$<n>$ = TrCreateLeafNode (PARSEOP_WORDBUSNUMBER);}
2428         OptionalResourceType_First
2429         OptionalMinType
2430         OptionalMaxType
2431         OptionalDecodeType
2432         ',' WordConstExpr
2433         ',' WordConstExpr
2434         ',' WordConstExpr
2435         ',' WordConstExpr
2436         ',' WordConstExpr
2437         OptionalByteConstExpr
2438         OptionalStringData
2439         OptionalNameString_Last
2440         ')'                         {$$ = TrLinkChildren ($<n>3,12,$4,$5,$6,$7,$9,$11,$13,$15,$17,$18,$19,$20);}
2441     | PARSEOP_WORDBUSNUMBER '('
2442         error ')'                   {$$ = AslDoError(); yyclearin;}
2443     ;
2444
2445 WordIOTerm
2446     : PARSEOP_WORDIO '('            {$<n>$ = TrCreateLeafNode (PARSEOP_WORDIO);}
2447         OptionalResourceType_First
2448         OptionalMinType
2449         OptionalMaxType
2450         OptionalDecodeType
2451         OptionalRangeType
2452         ',' WordConstExpr
2453         ',' WordConstExpr
2454         ',' WordConstExpr
2455         ',' WordConstExpr
2456         ',' WordConstExpr
2457         OptionalByteConstExpr
2458         OptionalStringData
2459         OptionalNameString
2460         OptionalType
2461         OptionalTranslationType_Last
2462         ')'                         {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22,$23);}
2463     | PARSEOP_WORDIO '('
2464         error ')'                   {$$ = AslDoError(); yyclearin;}
2465     ;
2466
2467 WordSpaceTerm
2468     : PARSEOP_WORDSPACE '('         {$<n>$ = TrCreateLeafNode (PARSEOP_WORDSPACE);}
2469         ByteConstExpr               {UtCheckIntegerRange ($4, 0xC0, 0xFF);}
2470         OptionalResourceType
2471         OptionalDecodeType
2472         OptionalMinType
2473         OptionalMaxType
2474         ',' ByteConstExpr
2475         ',' WordConstExpr
2476         ',' WordConstExpr
2477         ',' WordConstExpr
2478         ',' WordConstExpr
2479         ',' WordConstExpr
2480         OptionalByteConstExpr
2481         OptionalStringData
2482         OptionalNameString_Last
2483         ')'                         {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);}
2484     | PARSEOP_WORDSPACE '('
2485         error ')'                   {$$ = AslDoError(); yyclearin;}
2486     ;
2487
2488
2489 /******* Object References ***********************************************/
2490
2491 /* Allow IO, DMA, IRQ Resource macro names to also be used as identifiers */
2492
2493 NameString
2494     : NameSeg                       {}
2495     | PARSEOP_NAMESTRING            {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) AslCompilerlval.s);}
2496     | PARSEOP_IO                    {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");}
2497     | PARSEOP_DMA                   {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");}
2498     | PARSEOP_IRQ                   {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");}
2499     ;
2500
2501 NameSeg
2502     : PARSEOP_NAMESEG               {$$ = TrCreateValuedLeafNode (PARSEOP_NAMESEG, (ACPI_NATIVE_INT) AslCompilerlval.s);}
2503     ;
2504
2505
2506 /******* Helper rules ****************************************************/
2507
2508
2509 AmlPackageLengthTerm
2510     : Integer                       {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);}
2511     ;
2512
2513 NameStringItem
2514     : ',' NameString                {$$ = $2;}
2515     | ',' error                     {$$ = AslDoError (); yyclearin;}
2516     ;
2517
2518 TermArgItem
2519     : ',' TermArg                   {$$ = $2;}
2520     | ',' error                     {$$ = AslDoError (); yyclearin;}
2521     ;
2522
2523 OptionalBusMasterKeyword
2524     : ','                                       {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);}
2525     | ',' PARSEOP_BUSMASTERTYPE_MASTER          {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);}
2526     | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER       {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);}
2527     ;
2528
2529 OptionalAccessAttribTerm
2530     :                               {$$ = NULL;}
2531     | ','                           {$$ = NULL;}
2532     | ',' ByteConstExpr             {$$ = $2;}
2533     | ',' AccessAttribKeyword       {$$ = $2;}
2534     ;
2535
2536 OptionalAccessSize
2537     :                               {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);}
2538     | ','                           {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);}
2539     | ',' ByteConstExpr             {$$ = $2;}
2540     ;
2541
2542 OptionalAddressingMode
2543     : ','                           {$$ = NULL;}
2544     | ',' AddressingModeKeyword     {$$ = $2;}
2545     ;
2546
2547 OptionalAddressRange
2548     :                               {$$ = NULL;}
2549     | ','                           {$$ = NULL;}
2550     | ',' AddressKeyword            {$$ = $2;}
2551     ;
2552
2553 OptionalBitsPerByte
2554     : ','                           {$$ = NULL;}
2555     | ',' BitsPerByteKeyword        {$$ = $2;}
2556     ;
2557
2558 OptionalBuffer_Last
2559     :                               {$$ = NULL;}
2560     | ','                           {$$ = NULL;}
2561     | ',' DataBufferTerm            {$$ = $2;}
2562     ;
2563
2564 OptionalByteConstExpr
2565     :                               {$$ = NULL;}
2566     | ','                           {$$ = NULL;}
2567     | ',' ByteConstExpr             {$$ = $2;}
2568     ;
2569
2570 OptionalDecodeType
2571     : ','                           {$$ = NULL;}
2572     | ',' DecodeKeyword             {$$ = $2;}
2573     ;
2574
2575 OptionalDevicePolarity
2576     : ','                           {$$ = NULL;}
2577     | ',' DevicePolarityKeyword     {$$ = $2;}
2578     ;
2579
2580 OptionalDWordConstExpr
2581     :                               {$$ = NULL;}
2582     | ','                           {$$ = NULL;}
2583     | ',' DWordConstExpr            {$$ = $2;}
2584     ;
2585
2586 OptionalEndian
2587     : ','                           {$$ = NULL;}
2588     | ',' EndianKeyword             {$$ = $2;}
2589     ;
2590
2591 OptionalFlowControl
2592     : ','                           {$$ = NULL;}
2593     | ',' FlowControlKeyword        {$$ = $2;}
2594     ;
2595
2596 OptionalIoRestriction
2597     : ','                           {$$ = NULL;}
2598     | ',' IoRestrictionKeyword      {$$ = $2;}
2599     ;
2600
2601 OptionalListString
2602     :                               {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));}   /* Placeholder is a NULL string */
2603     | ','                           {$$ = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, ACPI_TO_INTEGER (""));}   /* Placeholder is a NULL string */
2604     | ',' TermArg                   {$$ = $2;}
2605     ;
2606
2607 OptionalMaxType
2608     : ','                           {$$ = NULL;}
2609     | ',' MaxKeyword                {$$ = $2;}
2610     ;
2611
2612 OptionalMemType
2613     : ','                           {$$ = NULL;}
2614     | ',' MemTypeKeyword            {$$ = $2;}
2615     ;
2616
2617 OptionalMinType
2618     : ','                           {$$ = NULL;}
2619     | ',' MinKeyword                {$$ = $2;}
2620     ;
2621
2622 OptionalNameString
2623     :                               {$$ = NULL;}
2624     | ','                           {$$ = NULL;}
2625     | ',' NameString                {$$ = $2;}
2626     ;
2627
2628 OptionalNameString_Last
2629     :                               {$$ = NULL;}
2630     | ','                           {$$ = NULL;}
2631     | ',' NameString                {$$ = $2;}
2632     ;
2633
2634 OptionalNameString_First
2635     :                               {$$ = TrCreateLeafNode (PARSEOP_ZERO);}
2636     | NameString                    {$$ = $1;}
2637     ;
2638
2639 OptionalObjectTypeKeyword
2640     :                               {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_UNK);}
2641     | ',' ObjectTypeKeyword         {$$ = $2;}
2642     ;
2643
2644 OptionalParityType
2645     : ','                           {$$ = NULL;}
2646     | ',' ParityTypeKeyword         {$$ = $2;}
2647     ;
2648
2649 OptionalQWordConstExpr
2650     :                               {$$ = NULL;}
2651     | ','                           {$$ = NULL;}
2652     | ',' QWordConstExpr            {$$ = $2;}
2653     ;
2654
2655 OptionalRangeType
2656     : ','                           {$$ = NULL;}
2657     | ',' RangeTypeKeyword          {$$ = $2;}
2658     ;
2659
2660 OptionalReadWriteKeyword
2661     :                                   {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);}
2662     | PARSEOP_READWRITETYPE_BOTH        {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);}
2663     | PARSEOP_READWRITETYPE_READONLY    {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);}
2664     ;
2665
2666 OptionalReference
2667     :                               {$$ = TrCreateLeafNode (PARSEOP_ZERO);}       /* Placeholder is a ZeroOp object */
2668     | ','                           {$$ = TrCreateLeafNode (PARSEOP_ZERO);}       /* Placeholder is a ZeroOp object */
2669     | ',' TermArg                   {$$ = $2;}
2670     ;
2671
2672 OptionalResourceType_First
2673     :                               {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);}
2674     | ResourceTypeKeyword           {$$ = $1;}
2675     ;
2676
2677 OptionalResourceType
2678     :                               {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);}
2679     | ','                           {$$ = TrCreateLeafNode (PARSEOP_RESOURCETYPE_CONSUMER);}
2680     | ',' ResourceTypeKeyword       {$$ = $2;}
2681     ;
2682
2683 OptionalReturnArg
2684     :                               {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);}       /* Placeholder is a ZeroOp object */
2685     | TermArg                       {$$ = $1;}
2686     ;
2687
2688 OptionalSerializeRuleKeyword
2689     :                               {$$ = NULL;}
2690     | ','                           {$$ = NULL;}
2691     | ',' SerializeRuleKeyword      {$$ = $2;}
2692     ;
2693
2694 OptionalSlaveMode
2695     : ','                           {$$ = NULL;}
2696     | ',' SlaveModeKeyword          {$$ = $2;}
2697     ;
2698
2699 OptionalShareType
2700     :                               {$$ = NULL;}
2701     | ','                           {$$ = NULL;}
2702     | ',' ShareTypeKeyword          {$$ = $2;}
2703     ;
2704
2705 OptionalShareType_First
2706     :                               {$$ = NULL;}
2707     | ShareTypeKeyword              {$$ = $1;}
2708     ;
2709
2710 OptionalStopBits
2711     : ','                           {$$ = NULL;}
2712     | ',' StopBitsKeyword           {$$ = $2;}
2713     ;
2714
2715 OptionalStringData
2716     :                               {$$ = NULL;}
2717     | ','                           {$$ = NULL;}
2718     | ',' StringData                {$$ = $2;}
2719     ;
2720
2721 OptionalTermArg
2722     :                               {$$ = NULL;}
2723     | TermArg                       {$$ = $1;}
2724     ;
2725
2726 OptionalType
2727     :                               {$$ = NULL;}
2728     | ','                           {$$ = NULL;}
2729     | ',' TypeKeyword               {$$ = $2;}
2730     ;
2731
2732 OptionalType_Last
2733     :                               {$$ = NULL;}
2734     | ','                           {$$ = NULL;}
2735     | ',' TypeKeyword               {$$ = $2;}
2736     ;
2737
2738 OptionalTranslationType_Last
2739     :                               {$$ = NULL;}
2740     | ','                           {$$ = NULL;}
2741     | ',' TranslationKeyword        {$$ = $2;}
2742     ;
2743
2744 OptionalWireMode
2745     : ','                           {$$ = NULL;}
2746     | ',' WireModeKeyword           {$$ = $2;}
2747     ;
2748
2749 OptionalWordConst
2750     :                               {$$ = NULL;}
2751     | WordConst                     {$$ = $1;}
2752     ;
2753
2754 OptionalWordConstExpr
2755     : ','                           {$$ = NULL;}
2756     | ',' WordConstExpr             {$$ = $2;}
2757     ;
2758
2759 OptionalXferSize
2760     :                               {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);}
2761     | ','                           {$$ = TrCreateValuedLeafNode (PARSEOP_XFERSIZE_32, 2);}
2762     | ',' XferSizeKeyword           {$$ = $2;}
2763     ;