xref: /freebsd/sys/contrib/dev/acpica/compiler/aslcompiler.l (revision 907b59d76938e654f0d040a888e8dfca3de1e222)
1 %{
2 /******************************************************************************
3  *
4  * Module Name: aslcompiler.l - Flex/lex input file
5  *
6  *****************************************************************************/
7 
8 /*
9  * Copyright (C) 2000 - 2016, 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 #include <contrib/dev/acpica/compiler/aslcompiler.h>
46 #include "aslcompiler.y.h"
47 
48 #include <stdlib.h>
49 #include <string.h>
50 YYSTYPE AslCompilerlval;
51 
52 /*
53  * Generation:  Use the following command line:
54  *
55  * flex.exe -PAslCompiler -i -o$(InputPath).c $(InputPath)
56  *
57  * -i: Scanner must be case-insensitive
58  */
59 
60 #define _COMPONENT          ACPI_COMPILER
61         ACPI_MODULE_NAME    ("aslscanner")
62 
63 
64 /* Local prototypes */
65 
66 static void
67 AslDoLineDirective (void);
68 
69 static char
70 AslDoComment (void);
71 
72 static char
73 AslDoCommentType2 (void);
74 
75 static char
76 AslDoStringLiteral (void);
77 
78 static void
79 count (int type);
80 
81 
82 /*! [Begin] no source code translation */
83 
84 %}
85     /* Definitions */
86 
87 LeadNameChar                [A-Za-z_]
88 DigitChar                   [0-9]
89 HexDigitChar                [A-Fa-f0-9]
90 RootChar                    [\\]
91 Nothing                     []
92 
93 NameChar                    [A-Za-z_0-9]
94 NameSeg1                    {LeadNameChar}{NameChar}
95 NameSeg2                    {LeadNameChar}{NameChar}{NameChar}
96 NameSeg3                    {LeadNameChar}{NameChar}{NameChar}{NameChar}
97 NameSeg                     {LeadNameChar}|{NameSeg1}|{NameSeg2}|{NameSeg3}
98 
99 NameString                  {RootChar}|{RootChar}{NamePath}|[\^]+{NamePath}|{NonEmptyNamePath}
100 NamePath                    {NonEmptyNamePath}?
101 NonEmptyNamePath            {NameSeg}{NamePathTail}*
102 NamePathTail                [.]{NameSeg}
103 
104 %%
105     /* Rules */
106 
107 [ ]                         { count (0); }
108 [\n]                        { count (0); } /* Handle files with both LF and CR/LF */
109 [\r]                        { count (0); } /* termination on both Unix and Windows */
110 [ \t]                       { count (0); }
111 
112 
113 "/*"                        { if (!AslDoComment ()) {yyterminate ();} }
114 "//"                        { if (!AslDoCommentType2 ()) {yyterminate ();} }
115 
116 "\""                        { if (AslDoStringLiteral ()) {return (PARSEOP_STRING_LITERAL);}
117                               else {yyterminate ();} }
118 ";"                         { count (0); return(';'); }
119 
120     /* ASL Extension: Standard C operators */
121 
122 "~"                         { count (3); return (PARSEOP_EXP_NOT); }
123 "!"                         { count (3); return (PARSEOP_EXP_LOGICAL_NOT); }
124 "*"                         { count (3); return (PARSEOP_EXP_MULTIPLY); }
125 "/"                         { count (3); return (PARSEOP_EXP_DIVIDE); }
126 "%"                         { count (3); return (PARSEOP_EXP_MODULO); }
127 "+"                         { count (3); return (PARSEOP_EXP_ADD); }
128 "-"                         { count (3); return (PARSEOP_EXP_SUBTRACT); }
129 ">>"                        { count (3); return (PARSEOP_EXP_SHIFT_RIGHT); }
130 "<<"                        { count (3); return (PARSEOP_EXP_SHIFT_LEFT); }
131 "<"                         { count (3); return (PARSEOP_EXP_LESS); }
132 ">"                         { count (3); return (PARSEOP_EXP_GREATER); }
133 "&"                         { count (3); return (PARSEOP_EXP_AND); }
134 "<="                        { count (3); return (PARSEOP_EXP_LESS_EQUAL); }
135 ">="                        { count (3); return (PARSEOP_EXP_GREATER_EQUAL); }
136 "=="                        { count (3); return (PARSEOP_EXP_EQUAL); }
137 "!="                        { count (3); return (PARSEOP_EXP_NOT_EQUAL); }
138 "|"                         { count (3); return (PARSEOP_EXP_OR); }
139 "&&"                        { count (3); return (PARSEOP_EXP_LOGICAL_AND); }
140 "||"                        { count (3); return (PARSEOP_EXP_LOGICAL_OR); }
141 "++"                        { count (3); return (PARSEOP_EXP_INCREMENT); }
142 "--"                        { count (3); return (PARSEOP_EXP_DECREMENT); }
143 "^ "                        { count (3); return (PARSEOP_EXP_XOR); }
144 
145     /* ASL Extension: Standard C assignment operators */
146 
147 "="                         { count (3); return (PARSEOP_EXP_EQUALS); }
148 "+="                        { count (3); return (PARSEOP_EXP_ADD_EQ); }
149 "-="                        { count (3); return (PARSEOP_EXP_SUB_EQ); }
150 "*="                        { count (3); return (PARSEOP_EXP_MUL_EQ); }
151 "/="                        { count (3); return (PARSEOP_EXP_DIV_EQ); }
152 "%="                        { count (3); return (PARSEOP_EXP_MOD_EQ); }
153 "<<="                       { count (3); return (PARSEOP_EXP_SHL_EQ); }
154 ">>="                       { count (3); return (PARSEOP_EXP_SHR_EQ); }
155 "&="                        { count (3); return (PARSEOP_EXP_AND_EQ); }
156 "^="                        { count (3); return (PARSEOP_EXP_XOR_EQ); }
157 "|="                        { count (3); return (PARSEOP_EXP_OR_EQ); }
158 
159 "["                         { count (3); return(PARSEOP_EXP_INDEX_LEFT); }
160 "]"                         { count (0); return(PARSEOP_EXP_INDEX_RIGHT); }
161 
162 
163     /*
164      * Begin standard ASL grammar
165      */
166 0[xX]{HexDigitChar}+ |
167 {DigitChar}+                { AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext);
168                                 count (1); return (PARSEOP_INTEGER); }
169 
170 "Include"                   { count (1); return (PARSEOP_INCLUDE); }
171 "External"                  { count (1); return (PARSEOP_EXTERNAL); }
172 
173  /*
174   * The #line directive is emitted by the preprocessor and handled
175   * here in the main iASL lexer - simply set the line number and
176   * optionally the current filename.
177   */
178 "#line"                     { AslDoLineDirective ();}
179 
180 
181  /****************************************************************************
182   *
183   * Main ASL operators
184   *
185   ****************************************************************************/
186 
187 "AccessAs"                  { count (1); return (PARSEOP_ACCESSAS); }
188 "Acquire"                   { count (3); return (PARSEOP_ACQUIRE); }
189 "Add"                       { count (3); return (PARSEOP_ADD); }
190 "Alias"                     { count (2); return (PARSEOP_ALIAS); }
191 "And"                       { count (3); return (PARSEOP_AND); }
192 "BankField"                 { count (2); return (PARSEOP_BANKFIELD); }
193 "Break"                     { count (3); return (PARSEOP_BREAK); }
194 "BreakPoint"                { count (3); return (PARSEOP_BREAKPOINT); }
195 "Buffer"                    { count (1); return (PARSEOP_BUFFER); }
196 "Case"                      { count (3); return (PARSEOP_CASE); }
197 "Concatenate"               { count (3); return (PARSEOP_CONCATENATE); }
198 "ConcatenateResTemplate"    { count (3); return (PARSEOP_CONCATENATERESTEMPLATE); }
199 "CondRefOf"                 { count (3); return (PARSEOP_CONDREFOF); }
200 "Connection"                { count (2); return (PARSEOP_CONNECTION); }
201 "Continue"                  { count (3); return (PARSEOP_CONTINUE); }
202 "CopyObject"                { count (3); return (PARSEOP_COPYOBJECT); }
203 "CreateBitField"            { count (2); return (PARSEOP_CREATEBITFIELD); }
204 "CreateByteField"           { count (2); return (PARSEOP_CREATEBYTEFIELD); }
205 "CreateDWordField"          { count (2); return (PARSEOP_CREATEDWORDFIELD); }
206 "CreateField"               { count (2); return (PARSEOP_CREATEFIELD); }
207 "CreateQWordField"          { count (2); return (PARSEOP_CREATEQWORDFIELD); }
208 "CreateWordField"           { count (2); return (PARSEOP_CREATEWORDFIELD); }
209 "DataTableRegion"           { count (2); return (PARSEOP_DATATABLEREGION); }
210 "Debug"                     { count (1); return (PARSEOP_DEBUG); }
211 "Decrement"                 { count (3); return (PARSEOP_DECREMENT); }
212 "Default"                   { count (3); return (PARSEOP_DEFAULT); }
213 "DefinitionBlock"           { count (1); return (PARSEOP_DEFINITION_BLOCK); }
214 "DeRefOf"                   { count (3); return (PARSEOP_DEREFOF); }
215 "Device"                    { count (2); return (PARSEOP_DEVICE); }
216 "Divide"                    { count (3); return (PARSEOP_DIVIDE); }
217 "Eisaid"                    { count (1); return (PARSEOP_EISAID); }
218 "Else"                      { count (3); return (PARSEOP_ELSE); }
219 "ElseIf"                    { count (3); return (PARSEOP_ELSEIF); }
220 "Event"                     { count (2); return (PARSEOP_EVENT); }
221 "Fatal"                     { count (3); return (PARSEOP_FATAL); }
222 "Field"                     { count (2); return (PARSEOP_FIELD); }
223 "FindSetLeftBit"            { count (3); return (PARSEOP_FINDSETLEFTBIT); }
224 "FindSetRightBit"           { count (3); return (PARSEOP_FINDSETRIGHTBIT); }
225 "FromBcd"                   { count (3); return (PARSEOP_FROMBCD); }
226 "Function"                  { count (2); return (PARSEOP_FUNCTION); }
227 "If"                        { count (3); return (PARSEOP_IF); }
228 "Increment"                 { count (3); return (PARSEOP_INCREMENT); }
229 "Index"                     { count (3); return (PARSEOP_INDEX); }
230 "IndexField"                { count (2); return (PARSEOP_INDEXFIELD); }
231 "LAnd"                      { count (3); return (PARSEOP_LAND); }
232 "LEqual"                    { count (3); return (PARSEOP_LEQUAL); }
233 "LGreater"                  { count (3); return (PARSEOP_LGREATER); }
234 "LGreaterEqual"             { count (3); return (PARSEOP_LGREATEREQUAL); }
235 "LLess"                     { count (3); return (PARSEOP_LLESS); }
236 "LLessEqual"                { count (3); return (PARSEOP_LLESSEQUAL); }
237 "LNot"                      { count (3); return (PARSEOP_LNOT); }
238 "LNotEqual"                 { count (3); return (PARSEOP_LNOTEQUAL); }
239 "Load"                      { count (3); return (PARSEOP_LOAD); }
240 "LoadTable"                 { count (3); return (PARSEOP_LOADTABLE); }
241 "LOr"                       { count (3); return (PARSEOP_LOR); }
242 "Match"                     { count (3); return (PARSEOP_MATCH); }
243 "Method"                    { count (2); return (PARSEOP_METHOD); }
244 "Mid"                       { count (3); return (PARSEOP_MID); }
245 "Mod"                       { count (3); return (PARSEOP_MOD); }
246 "Multiply"                  { count (3); return (PARSEOP_MULTIPLY); }
247 "Mutex"                     { count (2); return (PARSEOP_MUTEX); }
248 "Name"                      { count (2); return (PARSEOP_NAME); }
249 "NAnd"                      { count (3); return (PARSEOP_NAND); }
250 "Noop"                      { if (!AcpiGbl_IgnoreNoopOperator) {count (3); return (PARSEOP_NOOP);} }
251 "NOr"                       { count (3); return (PARSEOP_NOR); }
252 "Not"                       { count (3); return (PARSEOP_NOT); }
253 "Notify"                    { count (3); return (PARSEOP_NOTIFY); }
254 "ObjectType"                { count (3); return (PARSEOP_OBJECTTYPE); }
255 "Offset"                    { count (1); return (PARSEOP_OFFSET); }
256 "One"                       { count (1); return (PARSEOP_ONE); }
257 "Ones"                      { count (1); return (PARSEOP_ONES); }
258 "OperationRegion"           { count (2); return (PARSEOP_OPERATIONREGION); }
259 "Or"                        { count (3); return (PARSEOP_OR); }
260 "Package"                   { count (1); return (PARSEOP_PACKAGE); }
261 "PowerResource"             { count (2); return (PARSEOP_POWERRESOURCE); }
262 "Processor"                 { count (2); return (PARSEOP_PROCESSOR); }
263 "RefOf"                     { count (3); return (PARSEOP_REFOF); }
264 "Release"                   { count (3); return (PARSEOP_RELEASE); }
265 "Reset"                     { count (3); return (PARSEOP_RESET); }
266 "Return"                    { count (3); return (PARSEOP_RETURN); }
267 "Revision"                  { count (1); return (PARSEOP_REVISION); }
268 "Scope"                     { count (2); return (PARSEOP_SCOPE); }
269 "ShiftLeft"                 { count (3); return (PARSEOP_SHIFTLEFT); }
270 "ShiftRight"                { count (3); return (PARSEOP_SHIFTRIGHT); }
271 "Signal"                    { count (3); return (PARSEOP_SIGNAL); }
272 "SizeOf"                    { count (3); return (PARSEOP_SIZEOF); }
273 "Sleep"                     { count (3); return (PARSEOP_SLEEP); }
274 "Stall"                     { count (3); return (PARSEOP_STALL); }
275 "Store"                     { count (3); return (PARSEOP_STORE); }
276 "Subtract"                  { count (3); return (PARSEOP_SUBTRACT); }
277 "Switch"                    { count (3); return (PARSEOP_SWITCH); }
278 "ThermalZone"               { count (2); return (PARSEOP_THERMALZONE); }
279 "Timer"                     { count (3); return (PARSEOP_TIMER); }
280 "ToBcd"                     { count (3); return (PARSEOP_TOBCD); }
281 "ToBuffer"                  { count (3); return (PARSEOP_TOBUFFER); }
282 "ToDecimalString"           { count (3); return (PARSEOP_TODECIMALSTRING); }
283 "ToHexString"               { count (3); return (PARSEOP_TOHEXSTRING); }
284 "ToInteger"                 { count (3); return (PARSEOP_TOINTEGER); }
285 "ToString"                  { count (3); return (PARSEOP_TOSTRING); }
286 "ToUuid"                    { count (1); return (PARSEOP_TOUUID); }
287 "Unicode"                   { count (1); return (PARSEOP_UNICODE); }
288 "Unload"                    { count (3); return (PARSEOP_UNLOAD); }
289 "Wait"                      { count (3); return (PARSEOP_WAIT); }
290 "While"                     { count (3); return (PARSEOP_WHILE); }
291 "XOr"                       { count (3); return (PARSEOP_XOR); }
292 "Zero"                      { count (1); return (PARSEOP_ZERO); }
293 
294     /* Control method arguments and locals */
295 
296 "Arg0"                      { count (1); return (PARSEOP_ARG0); }
297 "Arg1"                      { count (1); return (PARSEOP_ARG1); }
298 "Arg2"                      { count (1); return (PARSEOP_ARG2); }
299 "Arg3"                      { count (1); return (PARSEOP_ARG3); }
300 "Arg4"                      { count (1); return (PARSEOP_ARG4); }
301 "Arg5"                      { count (1); return (PARSEOP_ARG5); }
302 "Arg6"                      { count (1); return (PARSEOP_ARG6); }
303 "Local0"                    { count (1); return (PARSEOP_LOCAL0); }
304 "Local1"                    { count (1); return (PARSEOP_LOCAL1); }
305 "Local2"                    { count (1); return (PARSEOP_LOCAL2); }
306 "Local3"                    { count (1); return (PARSEOP_LOCAL3); }
307 "Local4"                    { count (1); return (PARSEOP_LOCAL4); }
308 "Local5"                    { count (1); return (PARSEOP_LOCAL5); }
309 "Local6"                    { count (1); return (PARSEOP_LOCAL6); }
310 "Local7"                    { count (1); return (PARSEOP_LOCAL7); }
311 
312 
313  /****************************************************************************
314   *
315   * Resource Descriptor macros
316   *
317   ****************************************************************************/
318 
319 "ResourceTemplate"          { count (1); return (PARSEOP_RESOURCETEMPLATE); }
320 "RawDataBuffer"             { count (1); return (PARSEOP_DATABUFFER); }
321 
322 "DMA"                       { count (1); return (PARSEOP_DMA); }
323 "DWordIO"                   { count (1); return (PARSEOP_DWORDIO); }
324 "DWordMemory"               { count (1); return (PARSEOP_DWORDMEMORY); }
325 "DWordSpace"                { count (1); return (PARSEOP_DWORDSPACE); }
326 "EndDependentFn"            { count (1); return (PARSEOP_ENDDEPENDENTFN); }
327 "ExtendedIO"                { count (1); return (PARSEOP_EXTENDEDIO); }
328 "ExtendedMemory"            { count (1); return (PARSEOP_EXTENDEDMEMORY); }
329 "ExtendedSpace"             { count (1); return (PARSEOP_EXTENDEDSPACE); }
330 "FixedDma"                  { count (1); return (PARSEOP_FIXEDDMA); }
331 "FixedIO"                   { count (1); return (PARSEOP_FIXEDIO); }
332 "GpioInt"                   { count (1); return (PARSEOP_GPIO_INT); }
333 "GpioIo"                    { count (1); return (PARSEOP_GPIO_IO); }
334 "I2cSerialBus"              { count (1); return (PARSEOP_I2C_SERIALBUS); }
335 "I2cSerialBusV2"            { count (1); return (PARSEOP_I2C_SERIALBUS_V2); }
336 "Interrupt"                 { count (1); return (PARSEOP_INTERRUPT); }
337 "IO"                        { count (1); return (PARSEOP_IO); }
338 "IRQ"                       { count (1); return (PARSEOP_IRQ); }
339 "IRQNoFlags"                { count (1); return (PARSEOP_IRQNOFLAGS); }
340 "Memory24"                  { count (1); return (PARSEOP_MEMORY24); }
341 "Memory32"                  { count (1); return (PARSEOP_MEMORY32); }
342 "Memory32Fixed"             { count (1); return (PARSEOP_MEMORY32FIXED); }
343 "QWordIO"                   { count (1); return (PARSEOP_QWORDIO); }
344 "QWordMemory"               { count (1); return (PARSEOP_QWORDMEMORY); }
345 "QWordSpace"                { count (1); return (PARSEOP_QWORDSPACE); }
346 "Register"                  { count (1); return (PARSEOP_REGISTER); }
347 "SpiSerialBus"              { count (1); return (PARSEOP_SPI_SERIALBUS); }
348 "SpiSerialBusV2"            { count (1); return (PARSEOP_SPI_SERIALBUS_V2); }
349 "StartDependentFn"          { count (1); return (PARSEOP_STARTDEPENDENTFN); }
350 "StartDependentFnNoPri"     { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); }
351 "UartSerialBus"             { count (1); return (PARSEOP_UART_SERIALBUS); }
352 "UartSerialBusV2"           { count (1); return (PARSEOP_UART_SERIALBUS_V2); }
353 "VendorLong"                { count (1); return (PARSEOP_VENDORLONG); }
354 "VendorShort"               { count (1); return (PARSEOP_VENDORSHORT); }
355 "WordBusNumber"             { count (1); return (PARSEOP_WORDBUSNUMBER); }
356 "WordIO"                    { count (1); return (PARSEOP_WORDIO); }
357 "WordSpace"                 { count (1); return (PARSEOP_WORDSPACE); }
358 
359 
360  /****************************************************************************
361   *
362   * Keywords used as arguments to ASL operators and macros
363   *
364   ****************************************************************************/
365 
366     /*  AccessAttribKeyword: Serial Bus Attributes (ACPI 5.0) */
367 
368 "AttribQuick"               { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); }
369 "AttribSendReceive"         { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); }
370 "AttribByte"                { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); }
371 "AttribWord"                { count (0); return (PARSEOP_ACCESSATTRIB_WORD); }
372 "AttribBlock"               { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); }
373 "AttribProcessCall"         { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); }
374 "AttribBlockProcessCall"    { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); }
375 
376     /* AccessAttribKeyword: Legacy synonyms for above (pre-ACPI 5.0) */
377 
378 "SMBQuick"                  { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); }
379 "SMBSendReceive"            { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); }
380 "SMBByte"                   { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); }
381 "SMBWord"                   { count (0); return (PARSEOP_ACCESSATTRIB_WORD); }
382 "SMBBlock"                  { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); }
383 "SMBProcessCall"            { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); }
384 "SMBBlockProcessCall"       { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); }
385 
386     /* AccessTypeKeyword: Field Access Types */
387 
388 "AnyAcc"                    { count (0); return (PARSEOP_ACCESSTYPE_ANY); }
389 "ByteAcc"                   { count (0); return (PARSEOP_ACCESSTYPE_BYTE); }
390 "WordAcc"                   { count (0); return (PARSEOP_ACCESSTYPE_WORD); }
391 "DWordAcc"                  { count (0); return (PARSEOP_ACCESSTYPE_DWORD); }
392 "QWordAcc"                  { count (0); return (PARSEOP_ACCESSTYPE_QWORD); }
393 "BufferAcc"                 { count (0); return (PARSEOP_ACCESSTYPE_BUF); }
394 
395     /* AddressingModeKeyword: Mode - Resource Descriptors (ACPI 5.0) */
396 
397 "AddressingMode7Bit"        { count (0); return (PARSEOP_ADDRESSINGMODE_7BIT); }
398 "AddressingMode10Bit"       { count (0); return (PARSEOP_ADDRESSINGMODE_10BIT); }
399 
400     /* AddressKeyword: ACPI memory range types */
401 
402 "AddressRangeMemory"        { count (0); return (PARSEOP_ADDRESSTYPE_MEMORY); }
403 "AddressRangeReserved"      { count (0); return (PARSEOP_ADDRESSTYPE_RESERVED); }
404 "AddressRangeNVS"           { count (0); return (PARSEOP_ADDRESSTYPE_NVS); }
405 "AddressRangeACPI"          { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); }
406 
407     /* BusMasterKeyword: DMA Bus Mastering */
408 
409 "BusMaster"                 { count (0); return (PARSEOP_BUSMASTERTYPE_MASTER); }
410 "NotBusMaster"              { count (0); return (PARSEOP_BUSMASTERTYPE_NOTMASTER); }
411 
412     /* ByteLengthKeyword: Bits per Byte - Resource Descriptors (ACPI 5.0) */
413 
414 "DataBitsFive"              { count (0); return (PARSEOP_BITSPERBYTE_FIVE); }
415 "DataBitsSix"               { count (0); return (PARSEOP_BITSPERBYTE_SIX); }
416 "DataBitsSeven"             { count (0); return (PARSEOP_BITSPERBYTE_SEVEN); }
417 "DataBitsEight"             { count (0); return (PARSEOP_BITSPERBYTE_EIGHT); }
418 "DataBitsNine"              { count (0); return (PARSEOP_BITSPERBYTE_NINE); }
419 
420     /* ClockPhaseKeyword: Resource Descriptors (ACPI 5.0) */
421 
422 "ClockPhaseFirst"           { count (0); return (PARSEOP_CLOCKPHASE_FIRST); }
423 "ClockPhaseSecond"          { count (0); return (PARSEOP_CLOCKPHASE_SECOND); }
424 
425     /* ClockPolarityKeyword: Resource Descriptors (ACPI 5.0) */
426 
427 "ClockPolarityLow"          { count (0); return (PARSEOP_CLOCKPOLARITY_LOW); }
428 "ClockPolarityHigh"         { count (0); return (PARSEOP_CLOCKPOLARITY_HIGH); }
429 
430     /* DecodeKeyword: Type of Memory Decoding - Resource Descriptors */
431 
432 "PosDecode"                 { count (0); return (PARSEOP_DECODETYPE_POS); }
433 "SubDecode"                 { count (0); return (PARSEOP_DECODETYPE_SUB); }
434 
435     /* DmaTypeKeyword: DMA Types - DMA Resource Descriptor */
436 
437 "Compatibility"             { count (0); return (PARSEOP_DMATYPE_COMPATIBILITY); }
438 "TypeA"                     { count (0); return (PARSEOP_DMATYPE_A); }
439 "TypeB"                     { count (0); return (PARSEOP_DMATYPE_B); }
440 "TypeF"                     { count (0); return (PARSEOP_DMATYPE_F); }
441 
442     /* EndianKeyword: Endian type - Resource Descriptor (ACPI 5.0) */
443 
444 "LittleEndian"              { count (0); return (PARSEOP_ENDIAN_LITTLE); }
445 "BigEndian"                 { count (0); return (PARSEOP_ENDIAN_BIG); }
446 
447     /* ExtendedAttribKeyword: Bus attributes, AccessAs operator (ACPI 5.0) */
448 
449 "AttribBytes"               { count (0); return (PARSEOP_ACCESSATTRIB_MULTIBYTE); }
450 "AttribRawBytes"            { count (0); return (PARSEOP_ACCESSATTRIB_RAW_BYTES); }
451 "AttribRawProcessBytes"     { count (0); return (PARSEOP_ACCESSATTRIB_RAW_PROCESS); }
452 
453     /* FlowControlKeyword: Resource Descriptors (ACPI 5.0) */
454 
455 "FlowControlHardware"       { count (0); return (PARSEOP_FLOWCONTROL_HW); }
456 "FlowControlNone"           { count (0); return (PARSEOP_FLOWCONTROL_NONE); }
457 "FlowControlXon"            { count (0); return (PARSEOP_FLOWCONTROL_SW); }
458 
459     /* InterruptLevelKeyword: Interrupt Active Types */
460 
461 "ActiveBoth"                { count (0); return (PARSEOP_INTLEVEL_ACTIVEBOTH); }
462 "ActiveHigh"                { count (0); return (PARSEOP_INTLEVEL_ACTIVEHIGH); }
463 "ActiveLow"                 { count (0); return (PARSEOP_INTLEVEL_ACTIVELOW); }
464 
465     /* InterruptTypeKeyword: Interrupt Types */
466 
467 "Edge"                      { count (0); return (PARSEOP_INTTYPE_EDGE); }
468 "Level"                     { count (0); return (PARSEOP_INTTYPE_LEVEL); }
469 
470     /* IoDecodeKeyword: Type of Memory Decoding - Resource Descriptors */
471 
472 "Decode10"                  { count (0); return (PARSEOP_IODECODETYPE_10); }
473 "Decode16"                  { count (0); return (PARSEOP_IODECODETYPE_16); }
474 
475     /* IoRestrictionKeyword: I/O Restriction - GPIO Resource Descriptors (ACPI 5.0) */
476 
477 "IoRestrictionNone"         { count (0); return (PARSEOP_IORESTRICT_NONE); }
478 "IoRestrictionInputOnly"    { count (0); return (PARSEOP_IORESTRICT_IN); }
479 "IoRestrictionOutputOnly"   { count (0); return (PARSEOP_IORESTRICT_OUT); }
480 "IoRestrictionNoneAndPreserve"   { count (0); return (PARSEOP_IORESTRICT_PRESERVE); }
481 
482     /* LockRuleKeyword: Global Lock use for Field Operator */
483 
484 "Lock"                      { count (0); return (PARSEOP_LOCKRULE_LOCK); }
485 "NoLock"                    { count (0); return (PARSEOP_LOCKRULE_NOLOCK); }
486 
487     /* MatchOpKeyword: Types for Match Operator */
488 
489 "MTR"                       { count (0); return (PARSEOP_MATCHTYPE_MTR); }
490 "MEQ"                       { count (0); return (PARSEOP_MATCHTYPE_MEQ); }
491 "MLE"                       { count (0); return (PARSEOP_MATCHTYPE_MLE); }
492 "MLT"                       { count (0); return (PARSEOP_MATCHTYPE_MLT); }
493 "MGE"                       { count (0); return (PARSEOP_MATCHTYPE_MGE); }
494 "MGT"                       { count (0); return (PARSEOP_MATCHTYPE_MGT); }
495 
496     /* MaxKeyword: Max Range Type - Resource Descriptors */
497 
498 "MaxFixed"                  { count (0); return (PARSEOP_MAXTYPE_FIXED); }
499 "MaxNotFixed"               { count (0); return (PARSEOP_MAXTYPE_NOTFIXED); }
500 
501     /* MemTypeKeyword: Memory Types - Resource Descriptors */
502 
503 "Cacheable"                 { count (0); return (PARSEOP_MEMTYPE_CACHEABLE); }
504 "WriteCombining"            { count (0); return (PARSEOP_MEMTYPE_WRITECOMBINING); }
505 "Prefetchable"              { count (0); return (PARSEOP_MEMTYPE_PREFETCHABLE); }
506 "NonCacheable"              { count (0); return (PARSEOP_MEMTYPE_NONCACHEABLE); }
507 
508     /* MinKeyword: Min Range Type - Resource Descriptors */
509 
510 "MinFixed"                  { count (0); return (PARSEOP_MINTYPE_FIXED); }
511 "MinNotFixed"               { count (0); return (PARSEOP_MINTYPE_NOTFIXED); }
512 
513     /* ObjectTypeKeyword: ACPI Object Types */
514 
515 "UnknownObj"                { count (0); return (PARSEOP_OBJECTTYPE_UNK); }
516 "IntObj"                    { count (0); return (PARSEOP_OBJECTTYPE_INT); }
517 "StrObj"                    { count (0); return (PARSEOP_OBJECTTYPE_STR); }
518 "BuffObj"                   { count (0); return (PARSEOP_OBJECTTYPE_BUF); }
519 "PkgObj"                    { count (0); return (PARSEOP_OBJECTTYPE_PKG); }
520 "FieldUnitObj"              { count (0); return (PARSEOP_OBJECTTYPE_FLD); }
521 "DeviceObj"                 { count (0); return (PARSEOP_OBJECTTYPE_DEV); }
522 "EventObj"                  { count (0); return (PARSEOP_OBJECTTYPE_EVT); }
523 "MethodObj"                 { count (0); return (PARSEOP_OBJECTTYPE_MTH); }
524 "MutexObj"                  { count (0); return (PARSEOP_OBJECTTYPE_MTX); }
525 "OpRegionObj"               { count (0); return (PARSEOP_OBJECTTYPE_OPR); }
526 "PowerResObj"               { count (0); return (PARSEOP_OBJECTTYPE_POW); }
527 "ProcessorObj"              { count (0); return (PARSEOP_OBJECTTYPE_PRO); }
528 "ThermalZoneObj"            { count (0); return (PARSEOP_OBJECTTYPE_THZ); }
529 "BuffFieldObj"              { count (0); return (PARSEOP_OBJECTTYPE_BFF); }
530 "DDBHandleObj"              { count (0); return (PARSEOP_OBJECTTYPE_DDB); }
531 
532     /* ParityKeyword: Resource Descriptors (ACPI 5.0) */
533 
534 "ParityTypeSpace"           { count (0); return (PARSEOP_PARITYTYPE_SPACE); }
535 "ParityTypeMark"            { count (0); return (PARSEOP_PARITYTYPE_MARK); }
536 "ParityTypeOdd"             { count (0); return (PARSEOP_PARITYTYPE_ODD); }
537 "ParityTypeEven"            { count (0); return (PARSEOP_PARITYTYPE_EVEN); }
538 "ParityTypeNone"            { count (0); return (PARSEOP_PARITYTYPE_NONE); }
539 
540     /* PinConfigKeyword: Pin Configuration - GPIO Resource Descriptors (ACPI 5.0) */
541 
542 "PullDefault"               { count (0); return (PARSEOP_PIN_PULLDEFAULT); }
543 "PullUp"                    { count (0); return (PARSEOP_PIN_PULLUP); }
544 "PullDown"                  { count (0); return (PARSEOP_PIN_PULLDOWN); }
545 "PullNone"                  { count (0); return (PARSEOP_PIN_NOPULL); }
546 
547     /* PolarityKeyword: Resource Descriptors (ACPI 5.0) */
548 
549 "PolarityLow"               { count (0); return (PARSEOP_DEVICEPOLARITY_LOW); }
550 "PolarityHigh"              { count (0); return (PARSEOP_DEVICEPOLARITY_HIGH); }
551 
552     /* RangeTypeKeyword: I/O Range Types - Resource Descriptors */
553 
554 "ISAOnlyRanges"             { count (0); return (PARSEOP_RANGETYPE_ISAONLY); }
555 "NonISAOnlyRanges"          { count (0); return (PARSEOP_RANGETYPE_NONISAONLY); }
556 "EntireRange"               { count (0); return (PARSEOP_RANGETYPE_ENTIRE); }
557 
558     /* ReadWriteKeyword: Memory Access Types - Resource Descriptors */
559 
560 "ReadWrite"                 { count (0); return (PARSEOP_READWRITETYPE_BOTH); }
561 "ReadOnly"                  { count (0); return (PARSEOP_READWRITETYPE_READONLY); }
562 
563     /* RegionSpaceKeyword: Operation Region Address Space Types */
564 
565 "SystemIO"                  { count (0); return (PARSEOP_REGIONSPACE_IO); }
566 "SystemMemory"              { count (0); return (PARSEOP_REGIONSPACE_MEM); }
567 "PCI_Config"                { count (0); return (PARSEOP_REGIONSPACE_PCI); }
568 "EmbeddedControl"           { count (0); return (PARSEOP_REGIONSPACE_EC); }
569 "SMBus"                     { count (0); return (PARSEOP_REGIONSPACE_SMBUS); }
570 "SystemCMOS"                { count (0); return (PARSEOP_REGIONSPACE_CMOS); }
571 "PciBarTarget"              { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); }
572 "IPMI"                      { count (0); return (PARSEOP_REGIONSPACE_IPMI); }
573 "GeneralPurposeIo"          { count (0); return (PARSEOP_REGIONSPACE_GPIO); }       /* ACPI 5.0 */
574 "GenericSerialBus"          { count (0); return (PARSEOP_REGIONSPACE_GSBUS); }      /* ACPI 5.0 */
575 "PCC"                       { count (0); return (PARSEOP_REGIONSPACE_PCC); }        /* ACPI 5.0 */
576 "FFixedHW"                  { count (0); return (PARSEOP_REGIONSPACE_FFIXEDHW); }
577 
578     /* ResourceTypeKeyword: Resource Usage - Resource Descriptors */
579 
580 "ResourceConsumer"          { count (0); return (PARSEOP_RESOURCETYPE_CONSUMER); }
581 "ResourceProducer"          { count (0); return (PARSEOP_RESOURCETYPE_PRODUCER); }
582 
583     /* SerializeRuleKeyword: Control Method Serialization */
584 
585 "Serialized"                { count (0); return (PARSEOP_SERIALIZERULE_SERIAL); }
586 "NotSerialized"             { count (0); return (PARSEOP_SERIALIZERULE_NOTSERIAL); }
587 
588     /* ShareTypeKeyword: Interrupt Sharing - Resource Descriptors */
589 
590 "Shared"                    { count (0); return (PARSEOP_SHARETYPE_SHARED); }
591 "Exclusive"                 { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVE); }
592 "SharedAndWake"             { count (0); return (PARSEOP_SHARETYPE_SHAREDWAKE); }       /* ACPI 5.0 */
593 "ExclusiveAndWake"          { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVEWAKE); }    /* ACPI 5.0 */
594 
595     /* SlaveModeKeyword: Resource Descriptors (ACPI 5.0) */
596 
597 "ControllerInitiated"       { count (0); return (PARSEOP_SLAVEMODE_CONTROLLERINIT); }
598 "DeviceInitiated"           { count (0); return (PARSEOP_SLAVEMODE_DEVICEINIT); }
599 
600     /* StopBitsKeyword: Resource Descriptors (ACPI 5.0) */
601 
602 "StopBitsOne"               { count (0); return (PARSEOP_STOPBITS_ONE); }
603 "StopBitsOnePlusHalf"       { count (0); return (PARSEOP_STOPBITS_ONEPLUSHALF); }
604 "StopBitsTwo"               { count (0); return (PARSEOP_STOPBITS_TWO); }
605 "StopBitsZero"              { count (0); return (PARSEOP_STOPBITS_ZERO); }
606 
607     /* TransferWidthKeyword: DMA Widths - Fixed DMA Resource Descriptor (ACPI 5.0) */
608 
609 "Width8bit"                 { count (0); return (PARSEOP_XFERSIZE_8); }
610 "Width16bit"                { count (0); return (PARSEOP_XFERSIZE_16); }
611 "Width32bit"                { count (0); return (PARSEOP_XFERSIZE_32); }
612 "Width64bit"                { count (0); return (PARSEOP_XFERSIZE_64); }
613 "Width128bit"               { count (0); return (PARSEOP_XFERSIZE_128); }
614 "Width256bit"               { count (0); return (PARSEOP_XFERSIZE_256); }
615 
616     /* TranslationKeyword: Translation Density Types - Resource Descriptors */
617 
618 "SparseTranslation"         { count (0); return (PARSEOP_TRANSLATIONTYPE_SPARSE); }
619 "DenseTranslation"          { count (0); return (PARSEOP_TRANSLATIONTYPE_DENSE); }
620 
621     /* TypeKeyword: Translation Types - Resource Descriptors */
622 
623 "TypeTranslation"           { count (0); return (PARSEOP_TYPE_TRANSLATION); }
624 "TypeStatic"                { count (0); return (PARSEOP_TYPE_STATIC); }
625 
626     /* UpdateRuleKeyword: Field Update Rules */
627 
628 "Preserve"                  { count (0); return (PARSEOP_UPDATERULE_PRESERVE); }
629 "WriteAsOnes"               { count (0); return (PARSEOP_UPDATERULE_ONES); }
630 "WriteAsZeros"              { count (0); return (PARSEOP_UPDATERULE_ZEROS); }
631 
632     /* WireModeKeyword: SPI Wire Mode - Resource Descriptors (ACPI 5.0) */
633 
634 "FourWireMode"              { count (0); return (PARSEOP_WIREMODE_FOUR); }
635 "ThreeWireMode"             { count (0); return (PARSEOP_WIREMODE_THREE); }
636 
637     /* XferTypeKeyword: DMA Transfer Types */
638 
639 "Transfer8"                 { count (0); return (PARSEOP_XFERTYPE_8); }
640 "Transfer8_16"              { count (0); return (PARSEOP_XFERTYPE_8_16); }
641 "Transfer16"                { count (0); return (PARSEOP_XFERTYPE_16); }
642 
643     /* ToPld macro */
644 
645 "ToPLD"                     { count (0); return (PARSEOP_TOPLD); }
646 
647 "PLD_Revision"              { count (0); return (PARSEOP_PLD_REVISION); }
648 "PLD_IgnoreColor"           { count (0); return (PARSEOP_PLD_IGNORECOLOR); }
649 "PLD_Red"                   { count (0); return (PARSEOP_PLD_RED); }
650 "PLD_Green"                 { count (0); return (PARSEOP_PLD_GREEN); }
651 "PLD_Blue"                  { count (0); return (PARSEOP_PLD_BLUE); }
652 "PLD_Width"                 { count (0); return (PARSEOP_PLD_WIDTH); }
653 "PLD_Height"                { count (0); return (PARSEOP_PLD_HEIGHT); }
654 "PLD_UserVisible"           { count (0); return (PARSEOP_PLD_USERVISIBLE); }
655 "PLD_Dock"                  { count (0); return (PARSEOP_PLD_DOCK); }
656 "PLD_Lid"                   { count (0); return (PARSEOP_PLD_LID); }
657 "PLD_Panel"                 { count (0); return (PARSEOP_PLD_PANEL); }
658 "PLD_VerticalPosition"      { count (0); return (PARSEOP_PLD_VERTICALPOSITION); }
659 "PLD_HorizontalPosition"    { count (0); return (PARSEOP_PLD_HORIZONTALPOSITION); }
660 "PLD_Shape"                 { count (0); return (PARSEOP_PLD_SHAPE); }
661 "PLD_GroupOrientation"      { count (0); return (PARSEOP_PLD_GROUPORIENTATION); }
662 "PLD_GroupToken"            { count (0); return (PARSEOP_PLD_GROUPTOKEN); }
663 "PLD_GroupPosition"         { count (0); return (PARSEOP_PLD_GROUPPOSITION); }
664 "PLD_Bay"                   { count (0); return (PARSEOP_PLD_BAY); }
665 "PLD_Ejectable"             { count (0); return (PARSEOP_PLD_EJECTABLE); }
666 "PLD_EjectRequired"         { count (0); return (PARSEOP_PLD_EJECTREQUIRED); }
667 "PLD_CabinetNumber"         { count (0); return (PARSEOP_PLD_CABINETNUMBER); }
668 "PLD_CardCageNumber"        { count (0); return (PARSEOP_PLD_CARDCAGENUMBER); }
669 "PLD_Reference"             { count (0); return (PARSEOP_PLD_REFERENCE); }
670 "PLD_Rotation"              { count (0); return (PARSEOP_PLD_ROTATION); }
671 "PLD_Order"                 { count (0); return (PARSEOP_PLD_ORDER); }
672 "PLD_Reserved"              { count (0); return (PARSEOP_PLD_RESERVED); }
673 "PLD_VerticalOffset"        { count (0); return (PARSEOP_PLD_VERTICALOFFSET); }
674 "PLD_HorizontalOffset"      { count (0); return (PARSEOP_PLD_HORIZONTALOFFSET); }
675 
676 
677     /* printf debug macros */
678 
679 "printf"                    { count (0); return (PARSEOP_PRINTF); }
680 "fprintf"                   { count (0); return (PARSEOP_FPRINTF); }
681 
682     /* Other macros */
683 
684 "For"                       { count (0); return (PARSEOP_FOR); }
685 
686     /* Predefined compiler names */
687 
688 "__DATE__"                  { count (0); return (PARSEOP___DATE__); }
689 "__FILE__"                  { count (0); return (PARSEOP___FILE__); }
690 "__LINE__"                  { count (0); return (PARSEOP___LINE__); }
691 "__PATH__"                  { count (0); return (PARSEOP___PATH__); }
692 
693 
694 "{"                         { count (0); return('{'); }
695 "}"                         { count (0); return('}'); }
696 ","                         { count (0); return(','); }
697 "("                         { count (0); return('('); }
698 ")"                         { count (0); return(')'); }
699 
700 {NameSeg}                   { char *s;
701                                 count (0);
702                                 s=UtStringCacheCalloc (ACPI_NAME_SIZE + 1);
703                                 if (strcmp (AslCompilertext, "\\"))
704                                 {
705                                     strcpy (s, "____");
706                                     AcpiUtStrupr (AslCompilertext);
707                                 }
708                                 memcpy (s, AslCompilertext, strlen (AslCompilertext));
709                                 AslCompilerlval.s = s;
710                                 DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s);
711                                 return (PARSEOP_NAMESEG); }
712 
713 {NameString}                { char *s;
714                                 count (0);
715                                 s=UtStringCacheCalloc (strlen (AslCompilertext)+1);
716                                 AcpiUtStrupr (AslCompilertext);
717                                 strcpy (s, AslCompilertext);
718                                 AslCompilerlval.s = s;
719                                 DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s);
720                                 return (PARSEOP_NAMESTRING); }
721 
722 .                           { count (1);
723                                 if (isprint ((int) *AslCompilertext))
724                                 {
725                                     sprintf (MsgBuffer,
726                                         "Invalid character (%c), expecting ASL keyword or name",
727                                         *AslCompilertext);
728                                 }
729                                 else
730                                 {
731                                     sprintf (MsgBuffer,
732                                         "Invalid character (0x%2.2X), expecting ASL keyword or name",
733                                         *AslCompilertext);
734                                 }
735                                 AslCompilererror (MsgBuffer);}
736 
737 <<EOF>>                     { if (AslPopInputFileStack ())
738                                 {yyterminate();}
739                               else
740                                 {return (PARSEOP_INCLUDE_END);} };
741 
742 %%
743 
744 /*! [End] no source code translation !*/
745 
746 /*
747  * Bring in the scanner support routines
748  */
749 #include <contrib/dev/acpica/compiler/aslsupport.l>
750