aslrules.y revision 1.1.1.10
1NoEcho('
2/******************************************************************************
3 *
4 * Module Name: aslrules.y - Main Bison/Yacc production rules
5 *                         - Keep this file synched with the
6 *                           CvParseOpBlockType function in cvcompiler.c
7 *
8 *****************************************************************************/
9
10/*
11 * Copyright (C) 2000 - 2019, Intel Corp.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 *    notice, this list of conditions, and the following disclaimer,
19 *    without modification.
20 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
21 *    substantially similar to the "NO WARRANTY" disclaimer below
22 *    ("Disclaimer") and any redistribution must be conditioned upon
23 *    including a substantially similar Disclaimer requirement for further
24 *    binary redistribution.
25 * 3. Neither the names of the above-listed copyright holders nor the names
26 *    of any contributors may be used to endorse or promote products derived
27 *    from this software without specific prior written permission.
28 *
29 * Alternatively, this software may be distributed under the terms of the
30 * GNU General Public License ("GPL") version 2 as published by the Free
31 * Software Foundation.
32 *
33 * NO WARRANTY
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
37 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
42 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
43 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44 * POSSIBILITY OF SUCH DAMAGES.
45 */
46
47')
48
49/*******************************************************************************
50 *
51 * ASL Root and Secondary Terms
52 *
53 ******************************************************************************/
54
55/*
56 * Root term. Allow multiple #line directives before the definition block
57 * to handle output from preprocessors
58 */
59AslCode
60    : DefinitionBlockList           {$<n>$ = TrLinkOpChildren (
61                                        TrCreateLeafOp (PARSEOP_ASL_CODE),1, $1);}
62    | error                         {YYABORT; $$ = NULL;}
63    ;
64
65
66/*
67 * Note concerning support for "module-level code".
68 *
69 * ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control
70 * methods (the so-called module-level code.) This support was explicitly
71 * removed in ACPI 2.0, but this type of code continues to be created by
72 * BIOS vendors. In order to support the disassembly and recompilation of
73 * such code (and the porting of ASL code to iASL), iASL supports this
74 * code in violation of the current ACPI specification.
75 *
76 * The grammar change to support module-level code is to revert the
77 * {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the
78 * original use of {TermList} instead (see below.) This allows the use
79 * of Type1 and Type2 opcodes at module level.
80 *
81 * 04/2016: The module-level code is now allowed in the following terms:
82 * DeviceTerm, PowerResTerm, ProcessorTerm, ScopeTerm, ThermalZoneTerm.
83 * The ObjectList term is obsolete and has been removed.
84 */
85DefinitionBlockTerm
86    : PARSEOP_DEFINITION_BLOCK
87        PARSEOP_OPEN_PAREN          {$<n>$ = TrCreateLeafOp (PARSEOP_DEFINITION_BLOCK); COMMENT_CAPTURE_OFF;}
88        String ','
89        String ','
90        ByteConst ','
91        String ','
92        String ','
93        DWordConst
94        PARSEOP_CLOSE_PAREN         {TrSetOpIntegerWidth ($6,$8);
95                                        TrSetOpEndLineNumber ($<n>3); COMMENT_CAPTURE_ON;}
96            '{' TermList '}'        {$$ = TrLinkOpChildren ($<n>3,7,
97                                        $4,$6,$8,$10,$12,$14,$18);}
98    ;
99
100DefinitionBlockList
101    : DefinitionBlockTerm
102    | DefinitionBlockTerm
103        DefinitionBlockList         {$$ = TrLinkPeerOps (2, $1,$2);}
104    ;
105
106
107/******* Basic ASCII identifiers **************************************************/
108
109/* Allow IO, DMA, IRQ Resource macro and FOR macro names to also be used as identifiers */
110
111NameString
112    : NameSeg                       {}
113    | PARSEOP_NAMESTRING            {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) $1);}
114    | PARSEOP_IO                    {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");}
115    | PARSEOP_DMA                   {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");}
116    | PARSEOP_IRQ                   {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");}
117    | PARSEOP_FOR                   {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "FOR");}
118    ;
119/*
120NameSeg
121    : PARSEOP_NAMESEG               {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG, (ACPI_NATIVE_INT)
122                                        TrNormalizeNameSeg ($1));}
123    ;
124*/
125
126NameSeg
127    : PARSEOP_NAMESEG               {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG,
128                                        (ACPI_NATIVE_INT) AslCompilerlval.s);}
129    ;
130
131
132/******* Fundamental argument/statement types ***********************************/
133
134Term
135    : Object                        {}
136    | Type1Opcode                   {}
137    | Type2Opcode                   {}
138    | Type2IntegerOpcode            {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
139    | Type2StringOpcode             {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
140    | Type2BufferOpcode             {}
141    | Type2BufferOrStringOpcode     {}
142    | error                         {$$ = AslDoError(); yyclearin;}
143    ;
144
145SuperName
146    : SimpleName                    {}
147    | DebugTerm                     {}
148    | Type6Opcode                   {}
149    ;
150
151Target
152    :                               {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */
153    | ','                           {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */
154    | ',' SuperName                 {$$ = TrSetOpFlags ($2, OP_IS_TARGET);}
155    ;
156
157RequiredTarget
158    : ',' SuperName                 {$$ = TrSetOpFlags ($2, OP_IS_TARGET);}
159    ;
160
161TermArg
162    : SimpleName                    {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
163    | Type2Opcode                   {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
164    | DataObject                    {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
165    | PARSEOP_OPEN_PAREN
166        TermArg
167        PARSEOP_CLOSE_PAREN         {$$ = TrSetOpFlags ($2, OP_IS_TERM_ARG);}
168    ;
169
170/*
171 NOTE: Removed from TermArg due to reduce/reduce conflicts:
172    | Type2IntegerOpcode            {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
173    | Type2StringOpcode             {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
174    | Type2BufferOpcode             {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
175    | Type2BufferOrStringOpcode     {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
176
177*/
178
179MethodInvocationTerm
180    : NameString
181        PARSEOP_OPEN_PAREN          {TrSetOpIntegerValue (PARSEOP_METHODCALL, $1); COMMENT_CAPTURE_OFF;}
182        ArgList
183        PARSEOP_CLOSE_PAREN         {$$ = TrLinkChildOp ($1,$4); COMMENT_CAPTURE_ON;}
184    ;
185
186/* OptionalCount must appear before ByteList or an incorrect reduction will result */
187
188OptionalCount
189    :                               {$$ = TrCreateLeafOp (PARSEOP_ONES);}       /* Placeholder is a OnesOp object */
190    | ','                           {$$ = TrCreateLeafOp (PARSEOP_ONES);}       /* Placeholder is a OnesOp object */
191    | ',' TermArg                   {$$ = $2;}
192    ;
193
194/*
195 * Data count for buffers and packages (byte count for buffers,
196 * element count for packages).
197 */
198OptionalDataCount
199
200        /* Legacy ASL */
201    :                               {$$ = NULL;}
202    | PARSEOP_OPEN_PAREN
203        TermArg
204        PARSEOP_CLOSE_PAREN         {$$ = $2;}
205    | PARSEOP_OPEN_PAREN
206        PARSEOP_CLOSE_PAREN         {$$ = NULL;}
207
208        /* C-style (ASL+) -- adds equals term */
209
210    |  PARSEOP_EXP_EQUALS           {$$ = NULL;}
211
212    | PARSEOP_OPEN_PAREN
213        TermArg
214        PARSEOP_CLOSE_PAREN
215        PARSEOP_EXP_EQUALS          {$$ = $2;}
216
217    | PARSEOP_OPEN_PAREN
218        PARSEOP_CLOSE_PAREN
219        String
220        PARSEOP_EXP_EQUALS          {$$ = NULL;}
221    ;
222
223
224/******* List Terms **************************************************/
225
226    /* ACPI 3.0 -- allow semicolons between terms */
227
228TermList
229    :                               {$$ = NULL;}
230    | TermList Term                 {$$ = TrLinkPeerOp (
231                                        TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);}
232    | TermList Term ';'             {$$ = TrLinkPeerOp (
233                                        TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);}
234    | TermList ';' Term             {$$ = TrLinkPeerOp (
235                                        TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);}
236    | TermList ';' Term ';'         {$$ = TrLinkPeerOp (
237                                        TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);}
238    ;
239
240ArgList
241    :                               {$$ = NULL;}
242    | TermArg
243    | ArgList ','                   /* Allows a trailing comma at list end */
244    | ArgList ','
245        TermArg                     {$$ = TrLinkPeerOp ($1,$3);}
246    ;
247
248ByteList
249    :                               {$$ = NULL;}
250    | ByteConstExpr
251    | ByteList ','                  /* Allows a trailing comma at list end */
252    | ByteList ','
253        ByteConstExpr               {$$ = TrLinkPeerOp ($1,$3);}
254    ;
255
256DWordList
257    :                               {$$ = NULL;}
258    | DWordConstExpr
259    | DWordList ','                 /* Allows a trailing comma at list end */
260    | DWordList ','
261        DWordConstExpr              {$$ = TrLinkPeerOp ($1,$3);}
262    ;
263
264FieldUnitList
265    :                               {$$ = NULL;}
266    | FieldUnit
267    | FieldUnitList ','             /* Allows a trailing comma at list end */
268    | FieldUnitList ','
269        FieldUnit                   {$$ = TrLinkPeerOp ($1,$3);}
270    ;
271
272FieldUnit
273    : FieldUnitEntry                {}
274    | OffsetTerm                    {}
275    | AccessAsTerm                  {}
276    | ConnectionTerm                {}
277    ;
278
279FieldUnitEntry
280    : ',' AmlPackageLengthTerm      {$$ = TrCreateOp (PARSEOP_RESERVED_BYTES,1,$2);}
281    | NameSeg ','
282        AmlPackageLengthTerm        {$$ = TrLinkChildOp ($1,$3);}
283    ;
284
285Object
286    : CompilerDirective             {}
287    | NamedObject                   {}
288    | NameSpaceModifier             {}
289/*    | StructureTerm                 {} */
290    ;
291
292PackageList
293    :                               {$$ = NULL;}
294    | PackageElement
295    | PackageList ','               /* Allows a trailing comma at list end */
296    | PackageList ','
297        PackageElement              {$$ = TrLinkPeerOp ($1,$3);}
298    ;
299
300PackageElement
301    : DataObject                    {}
302    | NameString                    {}
303    ;
304
305    /* Rules for specifying the type of one method argument or return value */
306
307ParameterTypePackage
308    :                               {$$ = NULL;}
309    | ObjectTypeKeyword             {$$ = $1;}
310    | ParameterTypePackage ','
311        ObjectTypeKeyword           {$$ = TrLinkPeerOps (2,$1,$3);}
312    ;
313
314ParameterTypePackageList
315    :                               {$$ = NULL;}
316    | ObjectTypeKeyword             {$$ = $1;}
317    | '{' ParameterTypePackage '}'  {$$ = $2;}
318    ;
319
320OptionalParameterTypePackage
321    :                               {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);}
322    | ',' ParameterTypePackageList  {$$ = TrLinkOpChildren (
323                                        TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
324    ;
325
326    /* Rules for specifying the types for method arguments */
327
328ParameterTypesPackage
329    : ParameterTypePackageList      {$$ = $1;}
330    | ParameterTypesPackage ','
331        ParameterTypePackageList    {$$ = TrLinkPeerOps (2,$1,$3);}
332    ;
333
334ParameterTypesPackageList
335    :                               {$$ = NULL;}
336    | ObjectTypeKeyword             {$$ = $1;}
337    | '{' ParameterTypesPackage '}' {$$ = $2;}
338    ;
339
340OptionalParameterTypesPackage
341    :                               {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);}
342    | ',' ParameterTypesPackageList {$$ = TrLinkOpChildren (
343                                        TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
344    ;
345
346/*
347 * Case-Default list; allow only one Default term and unlimited Case terms
348 */
349CaseDefaultTermList
350    :                               {$$ = NULL;}
351    | CaseTerm                      {}
352    | DefaultTerm                   {}
353    | CaseDefaultTermList
354        CaseTerm                    {$$ = TrLinkPeerOp ($1,$2);}
355    | CaseDefaultTermList
356        DefaultTerm                 {$$ = TrLinkPeerOp ($1,$2);}
357
358/* Original - attempts to force zero or one default term within the switch */
359
360/*
361CaseDefaultTermList
362    :                               {$$ = NULL;}
363    | CaseTermList
364        DefaultTerm
365        CaseTermList                {$$ = TrLinkPeerOp ($1,TrLinkPeerOp ($2, $3));}
366    | CaseTermList
367        CaseTerm                    {$$ = TrLinkPeerOp ($1,$2);}
368    ;
369
370CaseTermList
371    :                               {$$ = NULL;}
372    | CaseTerm                      {}
373    | CaseTermList
374        CaseTerm                    {$$ = TrLinkPeerOp ($1,$2);}
375    ;
376*/
377
378
379/*******************************************************************************
380 *
381 * ASL Data and Constant Terms
382 *
383 ******************************************************************************/
384
385DataObject
386    : BufferData                    {}
387    | PackageData                   {}
388    | IntegerData                   {}
389    | StringData                    {}
390    ;
391
392BufferData
393    : Type5Opcode                   {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
394    | Type2BufferOrStringOpcode     {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
395    | Type2BufferOpcode             {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
396    | BufferTerm                    {}
397    ;
398
399PackageData
400    : PackageTerm                   {}
401    ;
402
403IntegerData
404    : Type2IntegerOpcode            {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
405    | Type3Opcode                   {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
406    | Integer                       {}
407    | ConstTerm                     {}
408    ;
409
410StringData
411    : Type2StringOpcode             {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
412    | String                        {}
413    ;
414
415ByteConst
416    : Integer                       {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);}
417    ;
418
419WordConst
420    : Integer                       {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);}
421    ;
422
423DWordConst
424    : Integer                       {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);}
425    ;
426
427QWordConst
428    : Integer                       {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);}
429    ;
430
431/*
432 * The OP_COMPILE_TIME_CONST flag in the following constant expressions
433 * enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes
434 * to simple integers. It is an error if these types of expressions cannot be
435 * reduced, since the AML grammar for ****ConstExpr requires a simple constant.
436 * Note: The required byte length of the constant is passed through to the
437 * constant folding code in the node AmlLength field.
438 */
439ByteConstExpr
440    : Type3Opcode                   {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
441                                        TrSetOpAmlLength ($1, 1);}
442    | Type2IntegerOpcode            {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
443                                        TrSetOpAmlLength ($1, 1);}
444    | ConstExprTerm                 {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);}
445    | ByteConst                     {}
446    ;
447
448WordConstExpr
449    : Type3Opcode                   {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
450                                        TrSetOpAmlLength ($1, 2);}
451    | Type2IntegerOpcode            {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
452                                        TrSetOpAmlLength ($1, 2);}
453    | ConstExprTerm                 {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);}
454    | WordConst                     {}
455    ;
456
457DWordConstExpr
458    : Type3Opcode                   {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
459                                        TrSetOpAmlLength ($1, 4);}
460    | Type2IntegerOpcode            {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
461                                        TrSetOpAmlLength ($1, 4);}
462    | ConstExprTerm                 {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);}
463    | DWordConst                    {}
464    ;
465
466QWordConstExpr
467    : Type3Opcode                   {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
468                                        TrSetOpAmlLength ($1, 8);}
469    | Type2IntegerOpcode            {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
470                                        TrSetOpAmlLength ($1, 8);}
471    | ConstExprTerm                 {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);}
472    | QWordConst                    {}
473    ;
474
475ConstTerm
476    : ConstExprTerm                 {}
477    | PARSEOP_REVISION              {$$ = TrCreateLeafOp (PARSEOP_REVISION);}
478    ;
479
480ConstExprTerm
481    : PARSEOP_ZERO                  {$$ = TrCreateValuedLeafOp (PARSEOP_ZERO, 0);}
482    | PARSEOP_ONE                   {$$ = TrCreateValuedLeafOp (PARSEOP_ONE, 1);}
483    | PARSEOP_ONES                  {$$ = TrCreateValuedLeafOp (PARSEOP_ONES, ACPI_UINT64_MAX);}
484    | PARSEOP___DATE__              {$$ = TrCreateConstantLeafOp (PARSEOP___DATE__);}
485    | PARSEOP___FILE__              {$$ = TrCreateConstantLeafOp (PARSEOP___FILE__);}
486    | PARSEOP___LINE__              {$$ = TrCreateConstantLeafOp (PARSEOP___LINE__);}
487    | PARSEOP___PATH__              {$$ = TrCreateConstantLeafOp (PARSEOP___PATH__);}
488    | PARSEOP___METHOD__            {$$ = TrCreateConstantLeafOp (PARSEOP___METHOD__);}
489    ;
490
491Integer
492    : PARSEOP_INTEGER               {$$ = TrCreateValuedLeafOp (PARSEOP_INTEGER,
493                                        AslCompilerlval.i);}
494    ;
495
496String
497    : PARSEOP_STRING_LITERAL        {$$ = TrCreateValuedLeafOp (PARSEOP_STRING_LITERAL,
498                                        (ACPI_NATIVE_INT) AslCompilerlval.s);}
499    ;
500
501
502/*******************************************************************************
503 *
504 * ASL Opcode Terms
505 *
506 ******************************************************************************/
507
508CompilerDirective
509    : IncludeTerm                   {}
510    | IncludeEndTerm                {}
511    | ExternalTerm                  {}
512    ;
513
514NamedObject
515    : BankFieldTerm                 {}
516    | CreateBitFieldTerm            {}
517    | CreateByteFieldTerm           {}
518    | CreateDWordFieldTerm          {}
519    | CreateFieldTerm               {}
520    | CreateQWordFieldTerm          {}
521    | CreateWordFieldTerm           {}
522    | DataRegionTerm                {}
523    | DeviceTerm                    {}
524    | EventTerm                     {}
525    | FieldTerm                     {}
526    | FunctionTerm                  {}
527    | IndexFieldTerm                {}
528    | MethodTerm                    {}
529    | MutexTerm                     {}
530    | OpRegionTerm                  {}
531    | PowerResTerm                  {}
532    | ProcessorTerm                 {}
533    | ThermalZoneTerm               {}
534    ;
535
536NameSpaceModifier
537    : AliasTerm                     {}
538    | NameTerm                      {}
539/*    | NameTermAslPlus               {} */
540    | ScopeTerm                     {}
541    ;
542
543SimpleName
544    : NameString                    {}
545    | LocalTerm                     {}
546    | ArgTerm                       {}
547    ;
548
549/* For ObjectType(), SuperName except for MethodInvocationTerm */
550
551ObjectTypeSource
552    : SimpleName                    {}
553    | DebugTerm                     {}
554    | RefOfTerm                     {}
555    | DerefOfTerm                   {}
556    | IndexTerm                     {}
557    | IndexExpTerm                  {}
558    ;
559
560/* For DeRefOf(), SuperName except for DerefOf and Debug */
561
562DerefOfSource
563    : SimpleName                    {}
564    | RefOfTerm                     {}
565    | DerefOfTerm                   {}
566    | IndexTerm                     {}
567    | IndexExpTerm                  {}
568    | StoreTerm                     {}
569    | EqualsTerm                    {}
570    | MethodInvocationTerm          {}
571    ;
572
573/* For RefOf(), SuperName except for RefOf and MethodInvocationTerm */
574
575RefOfSource
576    : SimpleName                    {}
577    | DebugTerm                     {}
578    | DerefOfTerm                   {}
579    | IndexTerm                     {}
580    | IndexExpTerm                  {}
581    ;
582
583/* For CondRefOf(), SuperName except for RefOf and MethodInvocationTerm */
584
585CondRefOfSource
586    : SimpleName                    {}
587    | DebugTerm                     {}
588    | DerefOfTerm                   {}
589    | IndexTerm                     {}
590    | IndexExpTerm                  {}
591    ;
592
593/*
594 * Opcode types, as defined in the ACPI specification
595 */
596Type1Opcode
597    : BreakTerm                     {}
598    | BreakPointTerm                {}
599    | ContinueTerm                  {}
600    | FatalTerm                     {}
601    | ForTerm                       {}
602    | ElseIfTerm                    {}
603    | LoadTerm                      {}
604    | NoOpTerm                      {}
605    | NotifyTerm                    {}
606    | ReleaseTerm                   {}
607    | ResetTerm                     {}
608    | ReturnTerm                    {}
609    | SignalTerm                    {}
610    | SleepTerm                     {}
611    | StallTerm                     {}
612    | SwitchTerm                    {}
613    | UnloadTerm                    {}
614    | WhileTerm                     {}
615    ;
616
617Type2Opcode
618    : AcquireTerm                   {}
619    | CondRefOfTerm                 {}
620    | CopyObjectTerm                {}
621    | DerefOfTerm                   {}
622    | ObjectTypeTerm                {}
623    | RefOfTerm                     {}
624    | SizeOfTerm                    {}
625    | StoreTerm                     {}
626    | EqualsTerm                    {}
627    | TimerTerm                     {}
628    | WaitTerm                      {}
629    | MethodInvocationTerm          {}
630    ;
631
632/*
633 * Type 3/4/5 opcodes
634 */
635Type2IntegerOpcode                  /* "Type3" opcodes */
636    : Expression                    {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
637    | AddTerm                       {}
638    | AndTerm                       {}
639    | DecTerm                       {}
640    | DivideTerm                    {}
641    | FindSetLeftBitTerm            {}
642    | FindSetRightBitTerm           {}
643    | FromBCDTerm                   {}
644    | IncTerm                       {}
645    | IndexTerm                     {}
646/*    | StructureIndexTerm            {} */
647/*    | StructurePointerTerm          {} */
648    | LAndTerm                      {}
649    | LEqualTerm                    {}
650    | LGreaterTerm                  {}
651    | LGreaterEqualTerm             {}
652    | LLessTerm                     {}
653    | LLessEqualTerm                {}
654    | LNotTerm                      {}
655    | LNotEqualTerm                 {}
656    | LoadTableTerm                 {}
657    | LOrTerm                       {}
658    | MatchTerm                     {}
659    | ModTerm                       {}
660    | MultiplyTerm                  {}
661    | NAndTerm                      {}
662    | NOrTerm                       {}
663    | NotTerm                       {}
664    | OrTerm                        {}
665    | ShiftLeftTerm                 {}
666    | ShiftRightTerm                {}
667    | SubtractTerm                  {}
668    | ToBCDTerm                     {}
669    | ToIntegerTerm                 {}
670    | XOrTerm                       {}
671    ;
672
673Type2StringOpcode                   /* "Type4" Opcodes */
674    : ToDecimalStringTerm           {}
675    | ToHexStringTerm               {}
676    | ToStringTerm                  {}
677    ;
678
679Type2BufferOpcode                   /* "Type5" Opcodes */
680    : ToBufferTerm                  {}
681    | ConcatResTerm                 {}
682    ;
683
684Type2BufferOrStringOpcode
685    : ConcatTerm                    {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
686    | PrintfTerm                    {}
687    | FprintfTerm                   {}
688    | MidTerm                       {}
689    ;
690
691/*
692 * A type 3 opcode evaluates to an Integer and cannot have a destination operand
693 */
694Type3Opcode
695    : EISAIDTerm                    {}
696    ;
697
698/* Obsolete
699Type4Opcode
700    : ConcatTerm                    {}
701    | ToDecimalStringTerm           {}
702    | ToHexStringTerm               {}
703    | MidTerm                       {}
704    | ToStringTerm                  {}
705    ;
706*/
707
708/* Type 5 opcodes are a subset of Type2 opcodes, and return a constant */
709
710Type5Opcode
711    : ResourceTemplateTerm          {}
712    | UnicodeTerm                   {}
713    | ToPLDTerm                     {}
714    | ToUUIDTerm                    {}
715    ;
716
717Type6Opcode
718    : RefOfTerm                     {}
719    | DerefOfTerm                   {}
720    | IndexTerm                     {}
721    | IndexExpTerm                  {}
722/*    | StructureIndexTerm            {} */
723/*    | StructurePointerTerm          {} */
724    | MethodInvocationTerm          {}
725    ;
726
727
728/*******************************************************************************
729 *
730 * ASL Helper Terms
731 *
732 ******************************************************************************/
733
734AmlPackageLengthTerm
735    : Integer                       {$$ = TrSetOpIntegerValue (PARSEOP_PACKAGE_LENGTH,
736                                        (ACPI_PARSE_OBJECT *) $1);}
737    ;
738
739NameStringItem
740    : ',' NameString                {$$ = $2;}
741    | ',' error                     {$$ = AslDoError (); yyclearin;}
742    ;
743
744TermArgItem
745    : ',' TermArg                   {$$ = $2;}
746    | ',' error                     {$$ = AslDoError (); yyclearin;}
747    ;
748
749OptionalReference
750    :                               {$$ = TrCreateLeafOp (PARSEOP_ZERO);}       /* Placeholder is a ZeroOp object */
751    | ','                           {$$ = TrCreateLeafOp (PARSEOP_ZERO);}       /* Placeholder is a ZeroOp object */
752    | ',' TermArg                   {$$ = $2;}
753    ;
754
755OptionalReturnArg
756    :                               {$$ = TrSetOpFlags (TrCreateLeafOp (PARSEOP_ZERO),
757                                            OP_IS_NULL_RETURN);}       /* Placeholder is a ZeroOp object */
758    | TermArg                       {$$ = $1;}
759    ;
760
761OptionalSerializeRuleKeyword
762    :                               {$$ = NULL;}
763    | ','                           {$$ = NULL;}
764    | ',' SerializeRuleKeyword      {$$ = $2;}
765    ;
766
767OptionalTermArg
768    :                               {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);}
769    | TermArg                       {$$ = $1;}
770    ;
771
772OptionalWordConst
773    :                               {$$ = NULL;}
774    | WordConst                     {$$ = $1;}
775    ;
776