Subversion Repositories Kolibri OS

Rev

Rev 1498 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1498 serge 1
 
2
/******************************************************************************
3
 *
4
 * Module Name: aslcompiler.l - Flex input file
5
 *
6
 *****************************************************************************/
7
8
 
9
 *
10
 * 1. Copyright Notice
11
 *
12
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
2216 Serge 13
 * All rights reserved.
1498 serge 14
 *
15
 * 2. License
16
 *
17
 * 2.1. This is your license from Intel Corp. under its intellectual property
18
 * rights.  You may have additional license terms from the party that provided
19
 * you this software, covering your right to use that party's intellectual
20
 * property rights.
21
 *
22
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23
 * copy of the source code appearing in this file ("Covered Code") an
24
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25
 * base code distributed originally by Intel ("Original Intel Code") to copy,
26
 * make derivatives, distribute, use and display any portion of the Covered
27
 * Code in any form, with the right to sublicense such rights; and
28
 *
29
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30
 * license (with the right to sublicense), under only those claims of Intel
31
 * patents that are infringed by the Original Intel Code, to make, use, sell,
32
 * offer to sell, and import the Covered Code and derivative works thereof
33
 * solely to the minimum extent necessary to exercise the above copyright
34
 * license, and in no event shall the patent license extend to any additions
35
 * to or modifications of the Original Intel Code.  No other license or right
36
 * is granted directly or by implication, estoppel or otherwise;
37
 *
38
 * The above copyright and patent license is granted only if the following
39
 * conditions are met:
40
 *
41
 * 3. Conditions
42
 *
43
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44
 * Redistribution of source code of any substantial portion of the Covered
45
 * Code or modification with rights to further distribute source must include
46
 * the above Copyright Notice, the above License, this list of Conditions,
47
 * and the following Disclaimer and Export Compliance provision.  In addition,
48
 * Licensee must cause all Covered Code to which Licensee contributes to
49
 * contain a file documenting the changes Licensee made to create that Covered
50
 * Code and the date of any change.  Licensee must include in that file the
51
 * documentation of any changes made by any predecessor Licensee.  Licensee
52
 * must include a prominent statement that the modification is derived,
53
 * directly or indirectly, from Original Intel Code.
54
 *
55
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56
 * Redistribution of source code of any substantial portion of the Covered
57
 * Code or modification without rights to further distribute source must
58
 * include the following Disclaimer and Export Compliance provision in the
59
 * documentation and/or other materials provided with distribution.  In
60
 * addition, Licensee may not authorize further sublicense of source of any
61
 * portion of the Covered Code, and must include terms to the effect that the
62
 * license from Licensee to its licensee is limited to the intellectual
63
 * property embodied in the software Licensee provides to its licensee, and
64
 * not to intellectual property embodied in modifications its licensee may
65
 * make.
66
 *
67
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68
 * substantial portion of the Covered Code or modification must reproduce the
69
 * above Copyright Notice, and the following Disclaimer and Export Compliance
70
 * provision in the documentation and/or other materials provided with the
71
 * distribution.
72
 *
73
 * 3.4. Intel retains all right, title, and interest in and to the Original
74
 * Intel Code.
75
 *
76
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77
 * Intel shall be used in advertising or otherwise to promote the sale, use or
78
 * other dealings in products derived from or relating to the Covered Code
79
 * without prior written authorization from Intel.
80
 *
81
 * 4. Disclaimer and Export Compliance
82
 *
83
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84
 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89
 * PARTICULAR PURPOSE.
90
 *
91
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92
 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93
 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94
 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95
 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98
 * LIMITED REMEDY.
99
 *
100
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101
 * software or system incorporating such software without first obtaining any
102
 * required license or other approval from the U. S. Department of Commerce or
103
 * any other agency or department of the United States Government.  In the
104
 * event Licensee exports any such software from the United States or
105
 * re-exports any such software from a foreign destination, Licensee shall
106
 * ensure that the distribution and export/re-export of the software is in
107
 * compliance with all laws, regulations, orders, or other restrictions of the
108
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109
 * any of its subsidiaries will export/re-export any technical data, process,
110
 * software, or service, directly or indirectly, to any country for which the
111
 * United States government or any agency thereof requires an export license,
112
 * other governmental approval, or letter of assurance, without first obtaining
113
 * such license, approval or letter.
114
 *
115
 *****************************************************************************/
116
117
 
2216 Serge 118
#include "aslcompiler.y.h"
119
1498 serge 120
 
121
#include 
122
YYSTYPE AslCompilerlval;
123
124
 
125
 * Generation:  Use the following command line:
126
 *
127
 * flex.exe -PAslCompiler -i -o$(InputPath).c $(InputPath)
128
 *
129
 * -i: Scanner must be case-insensitive
130
 */
131
132
 
133
        ACPI_MODULE_NAME    ("aslscan")
134
char
135
comment (void);
136
char
137
comment2 (void);
138
void
139
count (int type);
140
char
141
literal (void);
142
void
143
copy (void);
144
145
 
146
147
 
148
149
 
150
 
151
DigitChar                   [0-9]
152
HexDigitChar                [A-Fa-f0-9]
153
RootChar                    [\\]
154
Nothing                     []
155
156
 
157
NameSeg1                    {LeadNameChar}{NameChar}
158
NameSeg2                    {LeadNameChar}{NameChar}{NameChar}
159
NameSeg3                    {LeadNameChar}{NameChar}{NameChar}{NameChar}
160
NameSeg                     {LeadNameChar}|{NameSeg1}|{NameSeg2}|{NameSeg3}
161
162
 
163
NamePath                    {NonEmptyNamePath}?
164
NonEmptyNamePath            {NameSeg}{NamePathTail}*
165
NamePathTail                [.]{NameSeg}
166
167
 
168
169
 
170
[\n]                        { count (0); } /* Handle files with both LF and CR/LF */
171
[\r]                        { count (0); } /* termination on both Unix and Windows */
172
[ \t]                       { count (0); }
173
174
 
175
 
176
"//"                        { if (!comment2 ()) yyterminate (); }
177
178
 
179
180
 
181
 
182
{DigitChar}+                { AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext);
183
                                count (1); return (PARSEOP_INTEGER); }
184
185
 
186
"#include"                  { count (1); return (PARSEOP_INCLUDE_CSTYLE); }
187
"#line"						{ count (1); return (PARSEOP_LINE_CSTYLE); }
188
"External"                  { count (1); return (PARSEOP_EXTERNAL); }
189
190
 
191
 
192
"One"                       { count (1); return (PARSEOP_ONE); }
193
"Zero"                      { count (1); return (PARSEOP_ZERO); }
194
"Revision"                  { count (1); return (PARSEOP_REVISION); }
195
196
 
197
"AccessAs"                  { count (1); return (PARSEOP_ACCESSAS); }
198
"BankField"                 { count (2); return (PARSEOP_BANKFIELD); }
199
"CreateBitField"            { count (2); return (PARSEOP_CREATEBITFIELD); }
200
"CreateByteField"           { count (2); return (PARSEOP_CREATEBYTEFIELD); }
201
"CreateDWordField"          { count (2); return (PARSEOP_CREATEDWORDFIELD); }
202
"CreateField"               { count (2); return (PARSEOP_CREATEFIELD); }
203
"CreateQWordField"          { count (2); return (PARSEOP_CREATEQWORDFIELD); }
204
"CreateWordField"           { count (2); return (PARSEOP_CREATEWORDFIELD); }
205
"DataTableRegion"           { count (2); return (PARSEOP_DATATABLEREGION); }
206
"Device"                    { count (2); return (PARSEOP_DEVICE); }
207
"Event"                     { count (2); return (PARSEOP_EVENT); }
208
"Field"                     { count (2); return (PARSEOP_FIELD); }
209
"Function"                  { count (2); return (PARSEOP_FUNCTION); }
210
"IndexField"                { count (2); return (PARSEOP_INDEXFIELD); }
211
"Method"                    { count (2); return (PARSEOP_METHOD); }
212
"Mutex"                     { count (2); return (PARSEOP_MUTEX); }
213
"OperationRegion"           { count (2); return (PARSEOP_OPERATIONREGION); }
214
"PowerResource"             { count (2); return (PARSEOP_POWERRESOURCE); }
215
"Processor"                 { count (2); return (PARSEOP_PROCESSOR); }
216
"ThermalZone"               { count (2); return (PARSEOP_THERMALZONE); }
217
"Alias"                     { count (2); return (PARSEOP_ALIAS); }
218
"Name"                      { count (2); return (PARSEOP_NAME); }
219
"Scope"                     { count (2); return (PARSEOP_SCOPE); }
220
"Break"                     { count (3); return (PARSEOP_BREAK); }
221
"BreakPoint"                { count (3); return (PARSEOP_BREAKPOINT); }
222
"Continue"                  { count (3); return (PARSEOP_CONTINUE); }
223
"Fatal"                     { count (3); return (PARSEOP_FATAL); }
224
"If"                        { count (3); return (PARSEOP_IF); }
225
"Else"                      { count (3); return (PARSEOP_ELSE); }
226
"ElseIf"                    { count (3); return (PARSEOP_ELSEIF); }
227
"Load"                      { count (3); return (PARSEOP_LOAD); }
228
"Noop"                      { count (3); return (PARSEOP_NOOP); }
229
"Notify"                    { count (3); return (PARSEOP_NOTIFY); }
230
"Release"                   { count (3); return (PARSEOP_RELEASE); }
231
"Reset"                     { count (3); return (PARSEOP_RESET); }
232
"Return"                    { count (3); return (PARSEOP_RETURN); }
233
"Signal"                    { count (3); return (PARSEOP_SIGNAL); }
234
"Sleep"                     { count (3); return (PARSEOP_SLEEP); }
235
"Stall"                     { count (3); return (PARSEOP_STALL); }
236
"Switch"                    { count (3); return (PARSEOP_SWITCH); }
237
"Case"                      { count (3); return (PARSEOP_CASE); }
238
"Default"                   { count (3); return (PARSEOP_DEFAULT); }
239
"Unload"                    { count (3); return (PARSEOP_UNLOAD); }
240
"While"                     { count (3); return (PARSEOP_WHILE); }
241
242
 
243
"Add"                       { count (3); return (PARSEOP_ADD); }
244
"And"                       { count (3); return (PARSEOP_AND); }
245
"Concatenate"               { count (3); return (PARSEOP_CONCATENATE); }
246
"ConcatenateResTemplate"    { count (3); return (PARSEOP_CONCATENATERESTEMPLATE); }
247
"CondRefOf"                 { count (3); return (PARSEOP_CONDREFOF); }
248
"CopyObject"                { count (3); return (PARSEOP_COPYOBJECT); }
249
"Decrement"                 { count (3); return (PARSEOP_DECREMENT); }
250
"DeRefOf"                   { count (3); return (PARSEOP_DEREFOF); }
251
"Divide"                    { count (3); return (PARSEOP_DIVIDE); }
252
"FindSetLeftBit"            { count (3); return (PARSEOP_FINDSETLEFTBIT); }
253
"FindSetRightBit"           { count (3); return (PARSEOP_FINDSETRIGHTBIT); }
254
"FromBCD"                   { count (3); return (PARSEOP_FROMBCD); }
255
"Increment"                 { count (3); return (PARSEOP_INCREMENT); }
256
"Index"                     { count (3); return (PARSEOP_INDEX); }
257
"LAnd"                      { count (3); return (PARSEOP_LAND); }
258
"LEqual"                    { count (3); return (PARSEOP_LEQUAL); }
259
"LGreater"                  { count (3); return (PARSEOP_LGREATER); }
260
"LGreaterEqual"             { count (3); return (PARSEOP_LGREATEREQUAL); }
261
"LLess"                     { count (3); return (PARSEOP_LLESS); }
262
"LLessEqual"                { count (3); return (PARSEOP_LLESSEQUAL); }
263
"LNot"                      { count (3); return (PARSEOP_LNOT); }
264
"LNotEqual"                 { count (3); return (PARSEOP_LNOTEQUAL); }
265
"LoadTable"                 { count (3); return (PARSEOP_LOADTABLE); }
266
"LOr"                       { count (3); return (PARSEOP_LOR); }
267
"Match"                     { count (3); return (PARSEOP_MATCH); }
268
"Mid"                       { count (3); return (PARSEOP_MID); }
269
"Mod"                       { count (3); return (PARSEOP_MOD); }
270
"Multiply"                  { count (3); return (PARSEOP_MULTIPLY); }
271
"NAnd"                      { count (3); return (PARSEOP_NAND); }
272
"NOr"                       { count (3); return (PARSEOP_NOR); }
273
"Not"                       { count (3); return (PARSEOP_NOT); }
274
"ObjectType"                { count (3); return (PARSEOP_OBJECTTYPE); }
275
"Or"                        { count (3); return (PARSEOP_OR); }
276
"RefOf"                     { count (3); return (PARSEOP_REFOF); }
277
"ShiftLeft"                 { count (3); return (PARSEOP_SHIFTLEFT); }
278
"ShiftRight"                { count (3); return (PARSEOP_SHIFTRIGHT); }
279
"SizeOf"                    { count (3); return (PARSEOP_SIZEOF); }
280
"Store"                     { count (3); return (PARSEOP_STORE); }
281
"Subtract"                  { count (3); return (PARSEOP_SUBTRACT); }
282
"Timer"                     { count (3); return (PARSEOP_TIMER); }
283
"ToBCD"                     { count (3); return (PARSEOP_TOBCD); }
284
"ToBuffer"                  { count (3); return (PARSEOP_TOBUFFER); }
285
"ToDecimalString"           { count (3); return (PARSEOP_TODECIMALSTRING); }
286
"ToHexString"               { count (3); return (PARSEOP_TOHEXSTRING); }
287
"ToInteger"                 { count (3); return (PARSEOP_TOINTEGER); }
288
"ToString"                  { count (3); return (PARSEOP_TOSTRING); }
289
"Wait"                      { count (3); return (PARSEOP_WAIT); }
290
"XOr"                       { count (3); return (PARSEOP_XOR); }
291
292
 
293
"Arg1"                      { count (1); return (PARSEOP_ARG1); }
294
"Arg2"                      { count (1); return (PARSEOP_ARG2); }
295
"Arg3"                      { count (1); return (PARSEOP_ARG3); }
296
"Arg4"                      { count (1); return (PARSEOP_ARG4); }
297
"Arg5"                      { count (1); return (PARSEOP_ARG5); }
298
"Arg6"                      { count (1); return (PARSEOP_ARG6); }
299
300
 
301
"Local1"                    { count (1); return (PARSEOP_LOCAL1); }
302
"Local2"                    { count (1); return (PARSEOP_LOCAL2); }
303
"Local3"                    { count (1); return (PARSEOP_LOCAL3); }
304
"Local4"                    { count (1); return (PARSEOP_LOCAL4); }
305
"Local5"                    { count (1); return (PARSEOP_LOCAL5); }
306
"Local6"                    { count (1); return (PARSEOP_LOCAL6); }
307
"Local7"                    { count (1); return (PARSEOP_LOCAL7); }
308
309
 
310
311
 
312
"Buffer"                    { count (1); return (PARSEOP_BUFFER); }
313
"Package"                   { count (1); return (PARSEOP_PACKAGE); }
314
315
 
316
"ResourceTemplate"          { count (1); return (PARSEOP_RESOURCETEMPLATE); }
317
"ToUUID"                    { count (1); return (PARSEOP_TOUUID); }
318
"Unicode"                   { count (1); return (PARSEOP_UNICODE); }
319
"DMA"                       { count (1); return (PARSEOP_DMA); }
320
"DWordIO"                   { count (1); return (PARSEOP_DWORDIO); }
321
"DWordMemory"               { count (1); return (PARSEOP_DWORDMEMORY); }
322
"DWordSpace"                { count (1); return (PARSEOP_DWORDSPACE); }
323
"EndDependentFn"            { count (1); return (PARSEOP_ENDDEPENDENTFN); }
324
"ExtendedIO"                { count (1); return (PARSEOP_EXTENDEDIO); }
325
"ExtendedMemory"            { count (1); return (PARSEOP_EXTENDEDMEMORY); }
326
"ExtendedSpace"             { count (1); return (PARSEOP_EXTENDEDSPACE); }
327
"FixedIO"                   { count (1); return (PARSEOP_FIXEDIO); }
328
"Interrupt"                 { count (1); return (PARSEOP_INTERRUPT); }
329
"IO"                        { count (1); return (PARSEOP_IO); }
330
"IRQNoFlags"                { count (1); return (PARSEOP_IRQNOFLAGS); }
331
"IRQ"                       { count (1); return (PARSEOP_IRQ); }
332
"Memory24"                  { count (1); return (PARSEOP_MEMORY24); }
333
"Memory32Fixed"             { count (1); return (PARSEOP_MEMORY32FIXED); }
334
"Memory32"                  { count (1); return (PARSEOP_MEMORY32); }
335
"QWordIO"                   { count (1); return (PARSEOP_QWORDIO); }
336
"QWordMemory"               { count (1); return (PARSEOP_QWORDMEMORY); }
337
"QWordSpace"                { count (1); return (PARSEOP_QWORDSPACE); }
338
"Register"                  { count (1); return (PARSEOP_REGISTER); }
339
"StartDependentFn"          { count (1); return (PARSEOP_STARTDEPENDENTFN); }
340
"StartDependentFnNoPri"     { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); }
341
"VendorLong"                { count (1); return (PARSEOP_VENDORLONG); }
342
"VendorShort"               { count (1); return (PARSEOP_VENDORSHORT); }
343
"WordBusNumber"             { count (1); return (PARSEOP_WORDBUSNUMBER); }
344
"WordIO"                    { count (1); return (PARSEOP_WORDIO); }
345
"WordSpace"                 { count (1); return (PARSEOP_WORDSPACE); }
346
347
 
348
"IntObj"                    { count (0); return (PARSEOP_OBJECTTYPE_INT); }
349
"StrObj"                    { count (0); return (PARSEOP_OBJECTTYPE_STR); }
350
"BuffObj"                   { count (0); return (PARSEOP_OBJECTTYPE_BUF); }
351
"PkgObj"                    { count (0); return (PARSEOP_OBJECTTYPE_PKG); }
352
"FieldUnitObj"              { count (0); return (PARSEOP_OBJECTTYPE_FLD); }
353
"DeviceObj"                 { count (0); return (PARSEOP_OBJECTTYPE_DEV); }
354
"EventObj"                  { count (0); return (PARSEOP_OBJECTTYPE_EVT); }
355
"MethodObj"                 { count (0); return (PARSEOP_OBJECTTYPE_MTH); }
356
"MutexObj"                  { count (0); return (PARSEOP_OBJECTTYPE_MTX); }
357
"OpRegionObj"               { count (0); return (PARSEOP_OBJECTTYPE_OPR); }
358
"PowerResObj"               { count (0); return (PARSEOP_OBJECTTYPE_POW); }
359
"ProcessorObj"              { count (0); return (PARSEOP_OBJECTTYPE_PRO); }
360
"ThermalZoneObj"            { count (0); return (PARSEOP_OBJECTTYPE_THZ); }
361
"BuffFieldObj"              { count (0); return (PARSEOP_OBJECTTYPE_BFF); }
362
"DDBHandleObj"              { count (0); return (PARSEOP_OBJECTTYPE_DDB); }
363
364
 
365
"ByteAcc"                   { count (0); return (PARSEOP_ACCESSTYPE_BYTE); }
366
"WordAcc"                   { count (0); return (PARSEOP_ACCESSTYPE_WORD); }
367
"DWordAcc"                  { count (0); return (PARSEOP_ACCESSTYPE_DWORD); }
368
"QWordAcc"                  { count (0); return (PARSEOP_ACCESSTYPE_QWORD); }
369
"BufferAcc"                 { count (0); return (PARSEOP_ACCESSTYPE_BUF); }
370
371
 
372
"NoLock"                    { count (0); return (PARSEOP_LOCKRULE_NOLOCK); }
373
374
 
375
"WriteAsOnes"               { count (0); return (PARSEOP_UPDATERULE_ONES); }
376
"WriteAsZeros"              { count (0); return (PARSEOP_UPDATERULE_ZEROS); }
377
378
 
379
"NotSerialized"             { count (0); return (PARSEOP_SERIALIZERULE_NOTSERIAL); }
380
381
 
382
"SystemMemory"              { count (0); return (PARSEOP_REGIONSPACE_MEM); }
383
"PCI_Config"                { count (0); return (PARSEOP_REGIONSPACE_PCI); }
384
"EmbeddedControl"           { count (0); return (PARSEOP_REGIONSPACE_EC); }
385
"SMBus"                     { count (0); return (PARSEOP_REGIONSPACE_SMBUS); }
386
"SystemCMOS"                { count (0); return (PARSEOP_REGIONSPACE_CMOS); }
387
"PciBarTarget"              { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); }
388
"IPMI"                      { count (0); return (PARSEOP_REGIONSPACE_IPMI); }
389
390
 
391
392
 
393
"SMBSendReceive"            { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); }
394
"SMBByte"                   { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); }
395
"SMBWord"                   { count (0); return (PARSEOP_ACCESSATTRIB_WORD); }
396
"SMBBlock"                  { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); }
397
"SMBProcessCall"            { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); }
398
"SMBBlockProcessCall"       { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); }
399
400
 
401
"MEQ"                       { count (0); return (PARSEOP_MATCHTYPE_MEQ); }
402
"MLE"                       { count (0); return (PARSEOP_MATCHTYPE_MLE); }
403
"MLT"                       { count (0); return (PARSEOP_MATCHTYPE_MLT); }
404
"MGE"                       { count (0); return (PARSEOP_MATCHTYPE_MGE); }
405
"MGT"                       { count (0); return (PARSEOP_MATCHTYPE_MGT); }
406
407
 
408
"TypeA"                     { count (0); return (PARSEOP_DMATYPE_A); }
409
"TypeB"                     { count (0); return (PARSEOP_DMATYPE_B); }
410
"TypeF"                     { count (0); return (PARSEOP_DMATYPE_F); }
411
412
 
413
"NotBusMaster"              { count (0); return (PARSEOP_BUSMASTERTYPE_NOTMASTER); }
414
415
 
416
"Transfer8_16"              { count (0); return (PARSEOP_XFERTYPE_8_16); }
417
"Transfer16"                { count (0); return (PARSEOP_XFERTYPE_16); }
418
419
 
420
"ResourceProducer"          { count (0); return (PARSEOP_RESOURCETYPE_PRODUCER); }
421
422
 
423
"MinNotFixed"               { count (0); return (PARSEOP_MINTYPE_NOTFIXED); }
424
425
 
426
"MaxNotFixed"               { count (0); return (PARSEOP_MAXTYPE_NOTFIXED); }
427
428
 
429
"SubDecode"                 { count (0); return (PARSEOP_DECODETYPE_SUB); }
430
431
 
432
"NonISAOnlyRanges"          { count (0); return (PARSEOP_RANGETYPE_NONISAONLY); }
433
"EntireRange"               { count (0); return (PARSEOP_RANGETYPE_ENTIRE); }
434
435
 
436
"WriteCombining"            { count (0); return (PARSEOP_MEMTYPE_WRITECOMBINING); }
437
"Prefetchable"              { count (0); return (PARSEOP_MEMTYPE_PREFETCHABLE); }
438
"NonCacheable"              { count (0); return (PARSEOP_MEMTYPE_NONCACHEABLE); }
439
440
 
441
"ReadOnly"                  { count (0); return (PARSEOP_READWRITETYPE_READONLY); }
442
443
 
444
"Level"                     { count (0); return (PARSEOP_INTTYPE_LEVEL); }
445
446
 
447
"ActiveLow"                 { count (0); return (PARSEOP_INTLEVEL_ACTIVELOW); }
448
449
 
450
"Exclusive"                 { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVE); }
451
452
 
453
"Decode16"                  { count (0); return (PARSEOP_IODECODETYPE_16); }
454
455
 
456
"TypeStatic"                { count (0); return (PARSEOP_TYPE_STATIC); }
457
458
 
459
"DenseTranslation"          { count (0); return (PARSEOP_TRANSLATIONTYPE_DENSE); }
460
461
 
462
"AddressRangeReserved"      { count (0); return (PARSEOP_ADDRESSTYPE_RESERVED); }
463
"AddressRangeNVS"           { count (0); return (PARSEOP_ADDRESSTYPE_NVS); }
464
"AddressRangeACPI"          { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); }
465
466
 
2216 Serge 467
"__FILE__"                  { count (0); return (PARSEOP___FILE__); }
468
"__LINE__"                  { count (0); return (PARSEOP___LINE__); }
469
1498 serge 470
 
471
"}"                         { count (0); return('}'); }
472
","                         { count (0); return(','); }
473
"("                         { count (0); return('('); }
474
")"                         { count (0); return(')'); }
475
476
 
477
 
478
                                count (0);
479
                                s=malloc (ACPI_NAME_SIZE + 1);
480
                                if (strcmp (AslCompilertext, "\\"))
481
                                {
482
                                    strcpy (s, "____");
483
                                    AcpiUtStrupr (AslCompilertext);
484
                                }
485
                                memcpy (s, AslCompilertext, strlen (AslCompilertext));
486
                                AslCompilerlval.s = s;
487
                                DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s);
488
                                return (PARSEOP_NAMESEG); }
489
490
 
491
                                count (0);
492
                                s=malloc (strlen (AslCompilertext)+1);
493
                                AcpiUtStrupr (AslCompilertext);
494
                                strcpy (s, AslCompilertext);
495
                                s[strlen (AslCompilertext)] = 0;
496
                                AslCompilerlval.s = s;
497
                                DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s);
498
                                return (PARSEOP_NAMESTRING); }
499
500
 
501
"/"                         { count (1);
502
                                AslCompilererror ("Parse error, expecting ASL keyword or name");}
503
504
 
505
                                sprintf (MsgBuffer,
506
                                    "Invalid character (0x%2.2X), expecting ASL keyword or name",
507
                                    *AslCompilertext);
508
                                AslCompilererror (MsgBuffer);}
509
510
 
511
                                yyterminate();
512
                              else
513
                                return (PARSEOP_INCLUDE_END);};
514
515
 
516
517
 
518
519
 
520
{
521
    FILE                    *File;
522
    UINT32                  CurrentLineNumber;
523
    YY_BUFFER_STATE         State;
524
    char                    *Filename;
525
    struct asl_file_node    *Next;
526
527
 
528
529
 
530
531
 
532
 
533
 *
534
 * FUNCTION:    AslPopInputFileStack
535
 *
536
 * PARAMETERS:  None
537
 *
538
 * RETURN:      0 if a node was popped, -1 otherwise
539
 *
540
 * DESCRIPTION: Pop the top of the input file stack and point the parser to
541
 *              the saved parse buffer contained in the fnode.  Also, set the
542
 *              global line counters to the saved values.  This function is
543
 *              called when an include file reaches EOF.
544
 *
545
 ******************************************************************************/
546
547
 
548
AslPopInputFileStack (
549
    void)
550
{
551
    ASL_FILE_NODE           *Fnode;
552
    FILE                    *InputFile = NULL;
553
554
 
555
 
556
    DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode);
557
558
 
559
 
560
    {
561
        return -1;
562
    }
563
564
 
565
566
 
567
568
 
569
570
 
571
    InputFile = Fnode->File;
572
573
 
574
575
 
576
    Gbl_CurrentLineNumber = Fnode->CurrentLineNumber;
577
578
 
579
580
 
581
    yy_switch_to_buffer (Fnode->State);
582
583
 
584
585
 
586
    return 0;
587
}
588
589
 
590
 
591
 *
592
 * FUNCTION:    AslPushInputFileStack
593
 *
594
 * PARAMETERS:  InputFile           - Open file pointer
595
 *              Filename            - Name of the file
596
 *
597
 * RETURN:      None
598
 *
599
 * DESCRIPTION: Push the InputFile onto the file stack, and point the parser
600
 *              to this file.  Called when an include file is successfully
601
 *              opened.
602
 *
603
 ******************************************************************************/
604
605
 
606
AslPushInputFileStack (
607
    FILE                    *InputFile,
608
    char                    *Filename)
609
{
610
    ASL_FILE_NODE           *Fnode;
611
    YY_BUFFER_STATE         State;
612
613
 
614
 
615
616
 
617
618
 
619
    Fnode->Next                 = InputStack;
620
    Fnode->State                = YY_CURRENT_BUFFER;
621
    Fnode->CurrentLineNumber    = Gbl_CurrentLineNumber;
622
    Fnode->Filename             = Gbl_Files[ASL_FILE_INPUT].Filename;
623
624
 
625
626
 
627
628
 
629
630
 
631
    yy_switch_to_buffer (State);
632
633
 
634
635
 
636
637
 
638
    Gbl_CurrentLineNumber = 1;
639
    yyin = InputFile;
640
}
641
642
 
643
 
644
 *
645
 * FUNCTION:    ResetCurrentLineBuffer
646
 *
647
 * PARAMETERS:  None
648
 *
649
 * RETURN:      None
650
 *
651
 * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers.
652
 *
653
 ******************************************************************************/
654
655
 
656
ResetCurrentLineBuffer (
657
    void)
658
{
659
660
 
661
    {
662
        FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer,
663
            Gbl_LineBufPtr - Gbl_CurrentLineBuffer);
664
    }
665
666
 
667
    Gbl_CurrentColumn = 0;
668
669
 
670
    Gbl_LogicalLineNumber++;
671
    Gbl_LineBufPtr = Gbl_CurrentLineBuffer;
672
}
673
674
 
675
 
676
 *
677
 * FUNCTION:    InsertLineBuffer
678
 *
679
 * PARAMETERS:  SourceChar      - One char from the input ASL source file
680
 *
681
 * RETURN:      None
682
 *
683
 * DESCRIPTION: Put one character of the source file into the temp line buffer
684
 *
685
 ******************************************************************************/
686
687
 
688
689
 
690
InsertLineBuffer (
691
    int                     SourceChar)
692
{
693
    UINT32                  i;
694
    UINT32                  Count = 1;
695
696
 
697
 
698
    {
699
        return;
700
    }
701
702
 
703
704
 
705
706
 
707
    {
708
        SourceChar = ' ';
709
        Count = ASL_SPACES_PER_TAB -
710
                    (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1));
711
    }
712
713
 
714
 
715
    {
716
        Gbl_CurrentColumn++;
717
718
 
719
720
 
721
        Gbl_LineBufPtr++;
722
723
 
724
        {
725
#if 0
726
            /*
727
             * Warning if we have split a long source line.
728
             * 
729
             */
730
            sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE);
731
            AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE,
732
                            Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
733
                            Gbl_CurrentLineOffset, Gbl_CurrentColumn,
734
                            Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer);
735
#endif
736
737
 
738
        }
739
        else if (SourceChar == '\n')
740
        {
741
            /* End of line */
742
743
 
744
        }
745
    }
746
}
747
748
 
749
 
750
 *
751
 * FUNCTION:    count
752
 *
753
 * PARAMETERS:  yytext      - Contains the matched keyword.
754
 *              Type        - Keyword/Character type:
755
 *                             0 = anything except a keyword
756
 *                             1 = pseudo-keywords
757
 *                             2 = non-executable ASL keywords
758
 *                             3 = executable ASL keywords
759
 *
760
 * RETURN:      None
761
 *
762
 * DESCRIPTION: Count keywords and put them into the line buffer
763
 *
764
 ******************************************************************************/
765
766
 
767
count (
768
    int                 Type)
769
{
770
    int                 i;
771
772
 
773
 
774
    {
775
    case 2:
776
        TotalKeywords++;
777
        TotalNamedObjects++;
778
        break;
779
780
 
781
        TotalKeywords++;
782
        TotalExecutableOpcodes++;
783
        break;
784
    }
785
786
 
787
    {
788
        InsertLineBuffer (yytext[i]);
789
        *Gbl_LineBufPtr = 0;
790
    }
791
}
792
793
 
794
 
795
 *
796
 * FUNCTION:    comment
797
 *
798
 * PARAMETERS:  none
799
 *
800
 * RETURN:      none
801
 *
802
 * DESCRIPTION: Process a standard comment.
803
 *
804
 ******************************************************************************/
805
806
 
807
comment (void)
808
{
809
    char                c;
810
    char                c1 = 0;
811
812
 
813
 
814
    InsertLineBuffer ('*');
815
816
 
817
818
 
819
820
 
821
    {
822
        InsertLineBuffer (c);
823
        c1 = c;
824
    }
825
826
 
827
    {
828
        goto EarlyEOF;
829
    }
830
831
 
832
     * Check for nested comment -- can help catch cases where a previous
833
     * comment was accidently left unterminated
834
     */
835
    if ((c1 == '/') && (c == '*'))
836
    {
837
        AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT,
838
                        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
839
                        Gbl_InputByteCount, Gbl_CurrentColumn,
840
                        Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
841
    }
842
843
 
844
845
 
846
847
 
848
    {
849
        unput(c1);
850
        goto loop;
851
    }
852
853
 
854
    {
855
        goto EarlyEOF;
856
    }
857
858
 
859
    return TRUE;
860
861
 
862
 
863
    /*
864
     * Premature End-Of-File
865
     */
866
    AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,
867
                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
868
                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
869
                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
870
    return (FALSE);
871
}
872
873
 
874
 
875
 *
876
 * FUNCTION:    comment
877
 *
878
 * PARAMETERS:  none
879
 *
880
 * RETURN:      none
881
 *
882
 * DESCRIPTION: Process a new "//" comment.
883
 *
884
 ******************************************************************************/
885
886
 
887
comment2 (void)
888
{
889
    char                c;
890
891
 
892
 
893
    InsertLineBuffer ('/');
894
895
 
896
    {
897
        InsertLineBuffer (c);
898
    }
899
900
 
901
    {
902
        /* End of file is OK, change to newline. Let parser detect EOF later */
903
904
 
905
    }
906
907
 
908
    return (TRUE);
909
}
910
911
 
912
 
913
 *
914
 * FUNCTION:    literal
915
 *
916
 * PARAMETERS:  none
917
 *
918
 * RETURN:      none
919
 *
920
 * DESCRIPTION: Process a string literal (surrounded by quotes)
921
 *
922
 ******************************************************************************/
923
924
 
925
#define ASL_ESCAPE_SEQUENCE     1
926
#define ASL_OCTAL_CONSTANT      2
927
#define ASL_HEX_CONSTANT        3
928
929
 
930
literal (void)
931
{
932
    char                *StringBuffer = MsgBuffer;
933
    char                *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE;
934
    char                *CleanString;
935
    char                StringChar;
936
    UINT32              State = ASL_NORMAL_CHAR;
937
    UINT32              i = 0;
938
    UINT8               Digit;
939
    char                ConvertBuffer[4];
940
941
 
942
 
943
     * Eat chars until end-of-literal.
944
     * NOTE:  Put back the original surrounding quotes into the
945
     * source line buffer.
946
     */
947
    InsertLineBuffer ('\"');
948
    while ((StringChar = (char) input()) != EOF)
949
    {
950
        InsertLineBuffer (StringChar);
951
952
 
953
954
 
955
        {
956
        case ASL_NORMAL_CHAR:
957
958
 
959
            {
960
            case '\\':
961
                /*
962
                 * Special handling for backslash-escape sequence.  We will
963
                 * toss the backslash and translate the escape char(s).
964
                 */
965
                State = ASL_ESCAPE_SEQUENCE;
966
                continue;
967
968
 
969
970
 
971
972
 
973
            }
974
            break;
975
976
 
977
 
978
979
 
980
            switch (StringChar)
981
            {
982
            case 'a':
983
                StringChar = 0x07;      /* BELL */
984
                break;
985
986
 
987
                StringChar = 0x08;      /* BACKSPACE */
988
                break;
989
990
 
991
                StringChar = 0x0C;      /* FORMFEED */
992
                break;
993
994
 
995
                StringChar = 0x0A;      /* LINEFEED */
996
                break;
997
998
 
999
                StringChar = 0x0D;      /* CARRIAGE RETURN*/
1000
                break;
1001
1002
 
1003
                StringChar = 0x09;      /* HORIZONTAL TAB */
1004
                break;
1005
1006
 
1007
                StringChar = 0x0B;      /* VERTICAL TAB */
1008
                break;
1009
1010
 
1011
                State = ASL_HEX_CONSTANT;
1012
                i = 0;
1013
                continue;
1014
1015
 
1016
            case '\"':                  /* Double Quote */
1017
            case '\\':                  /* Backslash */
1018
                break;
1019
1020
 
1021
1022
 
1023
1024
 
1025
                {
1026
                    State = ASL_OCTAL_CONSTANT;
1027
                    ConvertBuffer[0] = StringChar;
1028
                    i = 1;
1029
                    continue;
1030
                }
1031
1032
 
1033
1034
 
1035
                                Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1036
                                Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1037
                                Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1038
				break;
1039
            }
1040
            break;
1041
1042
 
1043
 
1044
1045
 
1046
1047
 
1048
                (i > 2))
1049
            {
1050
                /*
1051
                 * Reached end of the constant.  Convert the assembled ASCII
1052
                 * string and resume processing of the next character
1053
                 */
1054
                ConvertBuffer[i] = 0;
1055
                Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8);
1056
1057
 
1058
1059
 
1060
                {
1061
                    AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,
1062
                                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1063
                                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1064
                                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1065
                }
1066
                else
1067
                {
1068
                    *StringBuffer = (char) Digit;
1069
                    StringBuffer++;
1070
                    if (StringBuffer >= EndBuffer)
1071
                    {
1072
                        goto BufferOverflow;
1073
                    }
1074
                }
1075
1076
 
1077
                goto DoCharacter;
1078
                break;
1079
            }
1080
1081
 
1082
1083
 
1084
            i++;
1085
            continue;
1086
1087
 
1088
 
1089
1090
 
1091
1092
 
1093
                (i > 1))
1094
            {
1095
                /*
1096
                 * Reached end of the constant.  Convert the assembled ASCII
1097
                 * string and resume processing of the next character
1098
                 */
1099
                ConvertBuffer[i] = 0;
1100
                Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16);
1101
1102
 
1103
1104
 
1105
                {
1106
                    AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,
1107
                                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1108
                                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1109
                                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1110
                }
1111
                else
1112
                {
1113
                    *StringBuffer = (char) Digit;
1114
                    StringBuffer++;
1115
                    if (StringBuffer >= EndBuffer)
1116
                    {
1117
                        goto BufferOverflow;
1118
                    }
1119
                }
1120
1121
 
1122
                goto DoCharacter;
1123
                break;
1124
            }
1125
1126
 
1127
1128
 
1129
            i++;
1130
            continue;
1131
        }
1132
1133
 
1134
1135
 
1136
        StringBuffer++;
1137
        if (StringBuffer >= EndBuffer)
1138
        {
1139
            goto BufferOverflow;
1140
        }
1141
    }
1142
1143
 
1144
     * Premature End-Of-File
1145
     */
1146
    AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,
1147
                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1148
                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1149
                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1150
    return (FALSE);
1151
1152
 
1153
 
1154
    /*
1155
     * Null terminate the input string and copy string to a new buffer
1156
     */
1157
    *StringBuffer = 0;
1158
1159
 
1160
    if (!CleanString)
1161
    {
1162
        AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
1163
                        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1164
                        Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1165
                        Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1166
        return (FALSE);
1167
    }
1168
1169
 
1170
    AslCompilerlval.s = CleanString;
1171
    return (TRUE);
1172
1173
 
1174
 
1175
1176
 
1177
1178
 
1179
                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1180
                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1181
                    Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096");
1182
    return (FALSE);
1183
}
1184