1118611Snjl
2118611Snjl%{
3118611Snjl/******************************************************************************
4118611Snjl *
5118611Snjl * Module Name: aslcompiler.l - Flex input file
6118611Snjl *
7118611Snjl *****************************************************************************/
8118611Snjl
9217365Sjkim/*
10217365Sjkim * Copyright (C) 2000 - 2011, Intel Corp.
11118611Snjl * All rights reserved.
12118611Snjl *
13217365Sjkim * Redistribution and use in source and binary forms, with or without
14217365Sjkim * modification, are permitted provided that the following conditions
15217365Sjkim * are met:
16217365Sjkim * 1. Redistributions of source code must retain the above copyright
17217365Sjkim *    notice, this list of conditions, and the following disclaimer,
18217365Sjkim *    without modification.
19217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20217365Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
21217365Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
22217365Sjkim *    including a substantially similar Disclaimer requirement for further
23217365Sjkim *    binary redistribution.
24217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
25217365Sjkim *    of any contributors may be used to endorse or promote products derived
26217365Sjkim *    from this software without specific prior written permission.
27118611Snjl *
28217365Sjkim * Alternatively, this software may be distributed under the terms of the
29217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
30217365Sjkim * Software Foundation.
31118611Snjl *
32217365Sjkim * NO WARRANTY
33217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
36217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43217365Sjkim * POSSIBILITY OF SUCH DAMAGES.
44217365Sjkim */
45118611Snjl
46217365Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h>
47217365Sjkim#include "aslcompiler.y.h"
48118611Snjl
49118611Snjl#include <stdlib.h>
50118611Snjl#include <string.h>
51118611SnjlYYSTYPE AslCompilerlval;
52118611Snjl
53118611Snjl/*
54118611Snjl * Generation:  Use the following command line:
55118611Snjl *
56118611Snjl * flex.exe -PAslCompiler -i -o$(InputPath).c $(InputPath)
57118611Snjl *
58118611Snjl * -i: Scanner must be case-insensitive
59118611Snjl */
60118611Snjl
61118611Snjl#define _COMPONENT          ACPI_COMPILER
62118611Snjl        ACPI_MODULE_NAME    ("aslscan")
63118611Snjlchar
64118611Snjlcomment (void);
65118611Snjlchar
66118611Snjlcomment2 (void);
67118611Snjlvoid
68118611Snjlcount (int type);
69118611Snjlchar
70118611Snjlliteral (void);
71118611Snjlvoid
72118611Snjlcopy (void);
73118611Snjl
74118611Snjl/*! [Begin] no source code translation */
75118611Snjl
76118611Snjl%}
77118611Snjl
78118611Snjl
79118611SnjlLeadNameChar                [A-Za-z_]
80118611SnjlDigitChar                   [0-9]
81118611SnjlHexDigitChar                [A-Fa-f0-9]
82118611SnjlRootChar                    [\\]
83118611SnjlNothing                     []
84118611Snjl
85118611SnjlNameChar                    [A-Za-z_0-9]
86118611SnjlNameSeg1                    {LeadNameChar}{NameChar}
87118611SnjlNameSeg2                    {LeadNameChar}{NameChar}{NameChar}
88118611SnjlNameSeg3                    {LeadNameChar}{NameChar}{NameChar}{NameChar}
89118611SnjlNameSeg                     {LeadNameChar}|{NameSeg1}|{NameSeg2}|{NameSeg3}
90118611Snjl
91118611SnjlNameString                  {RootChar}|{RootChar}{NamePath}|[\^]+{NamePath}|{NonEmptyNamePath}
92118611SnjlNamePath                    {NonEmptyNamePath}?
93118611SnjlNonEmptyNamePath            {NameSeg}{NamePathTail}*
94118611SnjlNamePathTail                [.]{NameSeg}
95118611Snjl
96118611Snjl%%
97118611Snjl
98118611Snjl[ ]                         { count (0); }
99193529Sjkim[\n]                        { count (0); } /* Handle files with both LF and CR/LF */
100193529Sjkim[\r]                        { count (0); } /* termination on both Unix and Windows */
101118611Snjl[ \t]                       { count (0); }
102118611Snjl
103118611Snjl
104118611Snjl"/*"                        { if (!comment ()) yyterminate (); }
105118611Snjl"//"                        { if (!comment2 ()) yyterminate (); }
106118611Snjl
107118611Snjl"\""                        { if (literal ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); }
108118611Snjl
109118611Snjl
110118611Snjl0[xX]{HexDigitChar}+ |
111118611Snjl{DigitChar}+                { AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext);
112118611Snjl                                count (1); return (PARSEOP_INTEGER); }
113118611Snjl
114118611Snjl"Include"                   { count (1); return (PARSEOP_INCLUDE); }
115118611Snjl"#include"                  { count (1); return (PARSEOP_INCLUDE_CSTYLE); }
116118611Snjl"#line"						{ count (1); return (PARSEOP_LINE_CSTYLE); }
117118611Snjl"External"                  { count (1); return (PARSEOP_EXTERNAL); }
118118611Snjl
119118611Snjl
120118611Snjl"Ones"                      { count (1); return (PARSEOP_ONES); }
121118611Snjl"One"                       { count (1); return (PARSEOP_ONE); }
122118611Snjl"Zero"                      { count (1); return (PARSEOP_ZERO); }
123118611Snjl"Revision"                  { count (1); return (PARSEOP_REVISION); }
124118611Snjl
125118611Snjl"Offset"                    { count (1); return (PARSEOP_OFFSET); }
126118611Snjl"AccessAs"                  { count (1); return (PARSEOP_ACCESSAS); }
127118611Snjl"BankField"                 { count (2); return (PARSEOP_BANKFIELD); }
128118611Snjl"CreateBitField"            { count (2); return (PARSEOP_CREATEBITFIELD); }
129118611Snjl"CreateByteField"           { count (2); return (PARSEOP_CREATEBYTEFIELD); }
130118611Snjl"CreateDWordField"          { count (2); return (PARSEOP_CREATEDWORDFIELD); }
131118611Snjl"CreateField"               { count (2); return (PARSEOP_CREATEFIELD); }
132118611Snjl"CreateQWordField"          { count (2); return (PARSEOP_CREATEQWORDFIELD); }
133118611Snjl"CreateWordField"           { count (2); return (PARSEOP_CREATEWORDFIELD); }
134118611Snjl"DataTableRegion"           { count (2); return (PARSEOP_DATATABLEREGION); }
135118611Snjl"Device"                    { count (2); return (PARSEOP_DEVICE); }
136118611Snjl"Event"                     { count (2); return (PARSEOP_EVENT); }
137118611Snjl"Field"                     { count (2); return (PARSEOP_FIELD); }
138138287Smarks"Function"                  { count (2); return (PARSEOP_FUNCTION); }
139118611Snjl"IndexField"                { count (2); return (PARSEOP_INDEXFIELD); }
140118611Snjl"Method"                    { count (2); return (PARSEOP_METHOD); }
141118611Snjl"Mutex"                     { count (2); return (PARSEOP_MUTEX); }
142118611Snjl"OperationRegion"           { count (2); return (PARSEOP_OPERATIONREGION); }
143118611Snjl"PowerResource"             { count (2); return (PARSEOP_POWERRESOURCE); }
144118611Snjl"Processor"                 { count (2); return (PARSEOP_PROCESSOR); }
145118611Snjl"ThermalZone"               { count (2); return (PARSEOP_THERMALZONE); }
146118611Snjl"Alias"                     { count (2); return (PARSEOP_ALIAS); }
147118611Snjl"Name"                      { count (2); return (PARSEOP_NAME); }
148118611Snjl"Scope"                     { count (2); return (PARSEOP_SCOPE); }
149118611Snjl"Break"                     { count (3); return (PARSEOP_BREAK); }
150118611Snjl"BreakPoint"                { count (3); return (PARSEOP_BREAKPOINT); }
151118611Snjl"Continue"                  { count (3); return (PARSEOP_CONTINUE); }
152118611Snjl"Fatal"                     { count (3); return (PARSEOP_FATAL); }
153118611Snjl"If"                        { count (3); return (PARSEOP_IF); }
154118611Snjl"Else"                      { count (3); return (PARSEOP_ELSE); }
155118611Snjl"ElseIf"                    { count (3); return (PARSEOP_ELSEIF); }
156118611Snjl"Load"                      { count (3); return (PARSEOP_LOAD); }
157118611Snjl"Noop"                      { count (3); return (PARSEOP_NOOP); }
158118611Snjl"Notify"                    { count (3); return (PARSEOP_NOTIFY); }
159118611Snjl"Release"                   { count (3); return (PARSEOP_RELEASE); }
160118611Snjl"Reset"                     { count (3); return (PARSEOP_RESET); }
161118611Snjl"Return"                    { count (3); return (PARSEOP_RETURN); }
162118611Snjl"Signal"                    { count (3); return (PARSEOP_SIGNAL); }
163118611Snjl"Sleep"                     { count (3); return (PARSEOP_SLEEP); }
164118611Snjl"Stall"                     { count (3); return (PARSEOP_STALL); }
165118611Snjl"Switch"                    { count (3); return (PARSEOP_SWITCH); }
166118611Snjl"Case"                      { count (3); return (PARSEOP_CASE); }
167118611Snjl"Default"                   { count (3); return (PARSEOP_DEFAULT); }
168118611Snjl"Unload"                    { count (3); return (PARSEOP_UNLOAD); }
169118611Snjl"While"                     { count (3); return (PARSEOP_WHILE); }
170118611Snjl
171118611Snjl"Acquire"                   { count (3); return (PARSEOP_ACQUIRE); }
172118611Snjl"Add"                       { count (3); return (PARSEOP_ADD); }
173118611Snjl"And"                       { count (3); return (PARSEOP_AND); }
174118611Snjl"Concatenate"               { count (3); return (PARSEOP_CONCATENATE); }
175118611Snjl"ConcatenateResTemplate"    { count (3); return (PARSEOP_CONCATENATERESTEMPLATE); }
176118611Snjl"CondRefOf"                 { count (3); return (PARSEOP_CONDREFOF); }
177118611Snjl"CopyObject"                { count (3); return (PARSEOP_COPYOBJECT); }
178118611Snjl"Decrement"                 { count (3); return (PARSEOP_DECREMENT); }
179118611Snjl"DeRefOf"                   { count (3); return (PARSEOP_DEREFOF); }
180118611Snjl"Divide"                    { count (3); return (PARSEOP_DIVIDE); }
181118611Snjl"FindSetLeftBit"            { count (3); return (PARSEOP_FINDSETLEFTBIT); }
182118611Snjl"FindSetRightBit"           { count (3); return (PARSEOP_FINDSETRIGHTBIT); }
183118611Snjl"FromBCD"                   { count (3); return (PARSEOP_FROMBCD); }
184118611Snjl"Increment"                 { count (3); return (PARSEOP_INCREMENT); }
185118611Snjl"Index"                     { count (3); return (PARSEOP_INDEX); }
186118611Snjl"LAnd"                      { count (3); return (PARSEOP_LAND); }
187118611Snjl"LEqual"                    { count (3); return (PARSEOP_LEQUAL); }
188118611Snjl"LGreater"                  { count (3); return (PARSEOP_LGREATER); }
189118611Snjl"LGreaterEqual"             { count (3); return (PARSEOP_LGREATEREQUAL); }
190118611Snjl"LLess"                     { count (3); return (PARSEOP_LLESS); }
191118611Snjl"LLessEqual"                { count (3); return (PARSEOP_LLESSEQUAL); }
192118611Snjl"LNot"                      { count (3); return (PARSEOP_LNOT); }
193118611Snjl"LNotEqual"                 { count (3); return (PARSEOP_LNOTEQUAL); }
194118611Snjl"LoadTable"                 { count (3); return (PARSEOP_LOADTABLE); }
195118611Snjl"LOr"                       { count (3); return (PARSEOP_LOR); }
196118611Snjl"Match"                     { count (3); return (PARSEOP_MATCH); }
197118611Snjl"Mid"                       { count (3); return (PARSEOP_MID); }
198118611Snjl"Mod"                       { count (3); return (PARSEOP_MOD); }
199118611Snjl"Multiply"                  { count (3); return (PARSEOP_MULTIPLY); }
200118611Snjl"NAnd"                      { count (3); return (PARSEOP_NAND); }
201118611Snjl"NOr"                       { count (3); return (PARSEOP_NOR); }
202118611Snjl"Not"                       { count (3); return (PARSEOP_NOT); }
203118611Snjl"ObjectType"                { count (3); return (PARSEOP_OBJECTTYPE); }
204118611Snjl"Or"                        { count (3); return (PARSEOP_OR); }
205118611Snjl"RefOf"                     { count (3); return (PARSEOP_REFOF); }
206118611Snjl"ShiftLeft"                 { count (3); return (PARSEOP_SHIFTLEFT); }
207118611Snjl"ShiftRight"                { count (3); return (PARSEOP_SHIFTRIGHT); }
208118611Snjl"SizeOf"                    { count (3); return (PARSEOP_SIZEOF); }
209118611Snjl"Store"                     { count (3); return (PARSEOP_STORE); }
210118611Snjl"Subtract"                  { count (3); return (PARSEOP_SUBTRACT); }
211138287Smarks"Timer"                     { count (3); return (PARSEOP_TIMER); }
212118611Snjl"ToBCD"                     { count (3); return (PARSEOP_TOBCD); }
213118611Snjl"ToBuffer"                  { count (3); return (PARSEOP_TOBUFFER); }
214118611Snjl"ToDecimalString"           { count (3); return (PARSEOP_TODECIMALSTRING); }
215118611Snjl"ToHexString"               { count (3); return (PARSEOP_TOHEXSTRING); }
216118611Snjl"ToInteger"                 { count (3); return (PARSEOP_TOINTEGER); }
217118611Snjl"ToString"                  { count (3); return (PARSEOP_TOSTRING); }
218118611Snjl"Wait"                      { count (3); return (PARSEOP_WAIT); }
219118611Snjl"XOr"                       { count (3); return (PARSEOP_XOR); }
220118611Snjl
221118611Snjl"Arg0"                      { count (1); return (PARSEOP_ARG0); }
222118611Snjl"Arg1"                      { count (1); return (PARSEOP_ARG1); }
223118611Snjl"Arg2"                      { count (1); return (PARSEOP_ARG2); }
224118611Snjl"Arg3"                      { count (1); return (PARSEOP_ARG3); }
225118611Snjl"Arg4"                      { count (1); return (PARSEOP_ARG4); }
226118611Snjl"Arg5"                      { count (1); return (PARSEOP_ARG5); }
227118611Snjl"Arg6"                      { count (1); return (PARSEOP_ARG6); }
228118611Snjl
229118611Snjl"Local0"                    { count (1); return (PARSEOP_LOCAL0); }
230118611Snjl"Local1"                    { count (1); return (PARSEOP_LOCAL1); }
231118611Snjl"Local2"                    { count (1); return (PARSEOP_LOCAL2); }
232118611Snjl"Local3"                    { count (1); return (PARSEOP_LOCAL3); }
233118611Snjl"Local4"                    { count (1); return (PARSEOP_LOCAL4); }
234118611Snjl"Local5"                    { count (1); return (PARSEOP_LOCAL5); }
235118611Snjl"Local6"                    { count (1); return (PARSEOP_LOCAL6); }
236118611Snjl"Local7"                    { count (1); return (PARSEOP_LOCAL7); }
237118611Snjl
238118611Snjl"Debug"                     { count (1); return (PARSEOP_DEBUG); }
239118611Snjl
240118611Snjl"DefinitionBlock"           { count (1); return (PARSEOP_DEFINITIONBLOCK); }
241118611Snjl"Buffer"                    { count (1); return (PARSEOP_BUFFER); }
242118611Snjl"Package"                   { count (1); return (PARSEOP_PACKAGE); }
243118611Snjl
244118611Snjl"EISAID"                    { count (1); return (PARSEOP_EISAID); }
245118611Snjl"ResourceTemplate"          { count (1); return (PARSEOP_RESOURCETEMPLATE); }
246138287Smarks"ToUUID"                    { count (1); return (PARSEOP_TOUUID); }
247118611Snjl"Unicode"                   { count (1); return (PARSEOP_UNICODE); }
248118611Snjl"DMA"                       { count (1); return (PARSEOP_DMA); }
249118611Snjl"DWordIO"                   { count (1); return (PARSEOP_DWORDIO); }
250118611Snjl"DWordMemory"               { count (1); return (PARSEOP_DWORDMEMORY); }
251138287Smarks"DWordSpace"                { count (1); return (PARSEOP_DWORDSPACE); }
252118611Snjl"EndDependentFn"            { count (1); return (PARSEOP_ENDDEPENDENTFN); }
253138287Smarks"ExtendedIO"                { count (1); return (PARSEOP_EXTENDEDIO); }
254138287Smarks"ExtendedMemory"            { count (1); return (PARSEOP_EXTENDEDMEMORY); }
255138287Smarks"ExtendedSpace"             { count (1); return (PARSEOP_EXTENDEDSPACE); }
256118611Snjl"FixedIO"                   { count (1); return (PARSEOP_FIXEDIO); }
257118611Snjl"Interrupt"                 { count (1); return (PARSEOP_INTERRUPT); }
258118611Snjl"IO"                        { count (1); return (PARSEOP_IO); }
259118611Snjl"IRQNoFlags"                { count (1); return (PARSEOP_IRQNOFLAGS); }
260118611Snjl"IRQ"                       { count (1); return (PARSEOP_IRQ); }
261118611Snjl"Memory24"                  { count (1); return (PARSEOP_MEMORY24); }
262118611Snjl"Memory32Fixed"             { count (1); return (PARSEOP_MEMORY32FIXED); }
263118611Snjl"Memory32"                  { count (1); return (PARSEOP_MEMORY32); }
264118611Snjl"QWordIO"                   { count (1); return (PARSEOP_QWORDIO); }
265118611Snjl"QWordMemory"               { count (1); return (PARSEOP_QWORDMEMORY); }
266138287Smarks"QWordSpace"                { count (1); return (PARSEOP_QWORDSPACE); }
267118611Snjl"Register"                  { count (1); return (PARSEOP_REGISTER); }
268118611Snjl"StartDependentFn"          { count (1); return (PARSEOP_STARTDEPENDENTFN); }
269118611Snjl"StartDependentFnNoPri"     { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); }
270118611Snjl"VendorLong"                { count (1); return (PARSEOP_VENDORLONG); }
271118611Snjl"VendorShort"               { count (1); return (PARSEOP_VENDORSHORT); }
272118611Snjl"WordBusNumber"             { count (1); return (PARSEOP_WORDBUSNUMBER); }
273118611Snjl"WordIO"                    { count (1); return (PARSEOP_WORDIO); }
274138287Smarks"WordSpace"                 { count (1); return (PARSEOP_WORDSPACE); }
275118611Snjl
276118611Snjl"UnknownObj"                { count (0); return (PARSEOP_OBJECTTYPE_UNK); }
277118611Snjl"IntObj"                    { count (0); return (PARSEOP_OBJECTTYPE_INT); }
278118611Snjl"StrObj"                    { count (0); return (PARSEOP_OBJECTTYPE_STR); }
279118611Snjl"BuffObj"                   { count (0); return (PARSEOP_OBJECTTYPE_BUF); }
280118611Snjl"PkgObj"                    { count (0); return (PARSEOP_OBJECTTYPE_PKG); }
281118611Snjl"FieldUnitObj"              { count (0); return (PARSEOP_OBJECTTYPE_FLD); }
282118611Snjl"DeviceObj"                 { count (0); return (PARSEOP_OBJECTTYPE_DEV); }
283118611Snjl"EventObj"                  { count (0); return (PARSEOP_OBJECTTYPE_EVT); }
284118611Snjl"MethodObj"                 { count (0); return (PARSEOP_OBJECTTYPE_MTH); }
285118611Snjl"MutexObj"                  { count (0); return (PARSEOP_OBJECTTYPE_MTX); }
286118611Snjl"OpRegionObj"               { count (0); return (PARSEOP_OBJECTTYPE_OPR); }
287118611Snjl"PowerResObj"               { count (0); return (PARSEOP_OBJECTTYPE_POW); }
288151937Sjkim"ProcessorObj"              { count (0); return (PARSEOP_OBJECTTYPE_PRO); }
289118611Snjl"ThermalZoneObj"            { count (0); return (PARSEOP_OBJECTTYPE_THZ); }
290118611Snjl"BuffFieldObj"              { count (0); return (PARSEOP_OBJECTTYPE_BFF); }
291118611Snjl"DDBHandleObj"              { count (0); return (PARSEOP_OBJECTTYPE_DDB); }
292118611Snjl
293118611Snjl"AnyAcc"                    { count (0); return (PARSEOP_ACCESSTYPE_ANY); }
294118611Snjl"ByteAcc"                   { count (0); return (PARSEOP_ACCESSTYPE_BYTE); }
295118611Snjl"WordAcc"                   { count (0); return (PARSEOP_ACCESSTYPE_WORD); }
296118611Snjl"DWordAcc"                  { count (0); return (PARSEOP_ACCESSTYPE_DWORD); }
297118611Snjl"QWordAcc"                  { count (0); return (PARSEOP_ACCESSTYPE_QWORD); }
298118611Snjl"BufferAcc"                 { count (0); return (PARSEOP_ACCESSTYPE_BUF); }
299118611Snjl
300118611Snjl"Lock"                      { count (0); return (PARSEOP_LOCKRULE_LOCK); }
301118611Snjl"NoLock"                    { count (0); return (PARSEOP_LOCKRULE_NOLOCK); }
302118611Snjl
303118611Snjl"Preserve"                  { count (0); return (PARSEOP_UPDATERULE_PRESERVE); }
304118611Snjl"WriteAsOnes"               { count (0); return (PARSEOP_UPDATERULE_ONES); }
305118611Snjl"WriteAsZeros"              { count (0); return (PARSEOP_UPDATERULE_ZEROS); }
306118611Snjl
307118611Snjl"Serialized"                { count (0); return (PARSEOP_SERIALIZERULE_SERIAL); }
308118611Snjl"NotSerialized"             { count (0); return (PARSEOP_SERIALIZERULE_NOTSERIAL); }
309118611Snjl
310118611Snjl"SystemIO"                  { count (0); return (PARSEOP_REGIONSPACE_IO); }
311118611Snjl"SystemMemory"              { count (0); return (PARSEOP_REGIONSPACE_MEM); }
312118611Snjl"PCI_Config"                { count (0); return (PARSEOP_REGIONSPACE_PCI); }
313118611Snjl"EmbeddedControl"           { count (0); return (PARSEOP_REGIONSPACE_EC); }
314118611Snjl"SMBus"                     { count (0); return (PARSEOP_REGIONSPACE_SMBUS); }
315118611Snjl"SystemCMOS"                { count (0); return (PARSEOP_REGIONSPACE_CMOS); }
316118611Snjl"PciBarTarget"              { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); }
317197104Sjkim"IPMI"                      { count (0); return (PARSEOP_REGIONSPACE_IPMI); }
318118611Snjl
319118611Snjl"FFixedHW"                  { count (0); return (PARSEOP_ADDRESSSPACE_FFIXEDHW); }
320118611Snjl
321118611Snjl"SMBQuick"                  { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); }
322118611Snjl"SMBSendReceive"            { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); }
323118611Snjl"SMBByte"                   { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); }
324118611Snjl"SMBWord"                   { count (0); return (PARSEOP_ACCESSATTRIB_WORD); }
325118611Snjl"SMBBlock"                  { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); }
326118611Snjl"SMBProcessCall"            { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); }
327118611Snjl"SMBBlockProcessCall"       { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); }
328118611Snjl
329118611Snjl"MTR"                       { count (0); return (PARSEOP_MATCHTYPE_MTR); }
330118611Snjl"MEQ"                       { count (0); return (PARSEOP_MATCHTYPE_MEQ); }
331118611Snjl"MLE"                       { count (0); return (PARSEOP_MATCHTYPE_MLE); }
332118611Snjl"MLT"                       { count (0); return (PARSEOP_MATCHTYPE_MLT); }
333118611Snjl"MGE"                       { count (0); return (PARSEOP_MATCHTYPE_MGE); }
334118611Snjl"MGT"                       { count (0); return (PARSEOP_MATCHTYPE_MGT); }
335118611Snjl
336118611Snjl"Compatibility"             { count (0); return (PARSEOP_DMATYPE_COMPATIBILITY); }
337118611Snjl"TypeA"                     { count (0); return (PARSEOP_DMATYPE_A); }
338118611Snjl"TypeB"                     { count (0); return (PARSEOP_DMATYPE_B); }
339118611Snjl"TypeF"                     { count (0); return (PARSEOP_DMATYPE_F); }
340118611Snjl
341118611Snjl"BusMaster"                 { count (0); return (PARSEOP_BUSMASTERTYPE_MASTER); }
342118611Snjl"NotBusMaster"              { count (0); return (PARSEOP_BUSMASTERTYPE_NOTMASTER); }
343118611Snjl
344118611Snjl"Transfer8"                 { count (0); return (PARSEOP_XFERTYPE_8); }
345118611Snjl"Transfer8_16"              { count (0); return (PARSEOP_XFERTYPE_8_16); }
346118611Snjl"Transfer16"                { count (0); return (PARSEOP_XFERTYPE_16); }
347118611Snjl
348118611Snjl"ResourceConsumer"          { count (0); return (PARSEOP_RESOURCETYPE_CONSUMER); }
349118611Snjl"ResourceProducer"          { count (0); return (PARSEOP_RESOURCETYPE_PRODUCER); }
350118611Snjl
351118611Snjl"MinFixed"                  { count (0); return (PARSEOP_MINTYPE_FIXED); }
352118611Snjl"MinNotFixed"               { count (0); return (PARSEOP_MINTYPE_NOTFIXED); }
353118611Snjl
354118611Snjl"MaxFixed"                  { count (0); return (PARSEOP_MAXTYPE_FIXED); }
355118611Snjl"MaxNotFixed"               { count (0); return (PARSEOP_MAXTYPE_NOTFIXED); }
356118611Snjl
357118611Snjl"PosDecode"                 { count (0); return (PARSEOP_DECODETYPE_POS); }
358118611Snjl"SubDecode"                 { count (0); return (PARSEOP_DECODETYPE_SUB); }
359118611Snjl
360118611Snjl"ISAOnlyRanges"             { count (0); return (PARSEOP_RANGETYPE_ISAONLY); }
361118611Snjl"NonISAOnlyRanges"          { count (0); return (PARSEOP_RANGETYPE_NONISAONLY); }
362118611Snjl"EntireRange"               { count (0); return (PARSEOP_RANGETYPE_ENTIRE); }
363118611Snjl
364118611Snjl"Cacheable"                 { count (0); return (PARSEOP_MEMTYPE_CACHEABLE); }
365118611Snjl"WriteCombining"            { count (0); return (PARSEOP_MEMTYPE_WRITECOMBINING); }
366118611Snjl"Prefetchable"              { count (0); return (PARSEOP_MEMTYPE_PREFETCHABLE); }
367118611Snjl"NonCacheable"              { count (0); return (PARSEOP_MEMTYPE_NONCACHEABLE); }
368118611Snjl
369118611Snjl"ReadWrite"                 { count (0); return (PARSEOP_READWRITETYPE_BOTH); }
370118611Snjl"ReadOnly"                  { count (0); return (PARSEOP_READWRITETYPE_READONLY); }
371118611Snjl
372118611Snjl"Edge"                      { count (0); return (PARSEOP_INTTYPE_EDGE); }
373118611Snjl"Level"                     { count (0); return (PARSEOP_INTTYPE_LEVEL); }
374118611Snjl
375118611Snjl"ActiveHigh"                { count (0); return (PARSEOP_INTLEVEL_ACTIVEHIGH); }
376118611Snjl"ActiveLow"                 { count (0); return (PARSEOP_INTLEVEL_ACTIVELOW); }
377118611Snjl
378118611Snjl"Shared"                    { count (0); return (PARSEOP_SHARETYPE_SHARED); }
379118611Snjl"Exclusive"                 { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVE); }
380118611Snjl
381118611Snjl"Decode10"                  { count (0); return (PARSEOP_IODECODETYPE_10); }
382118611Snjl"Decode16"                  { count (0); return (PARSEOP_IODECODETYPE_16); }
383118611Snjl
384118611Snjl"TypeTranslation"           { count (0); return (PARSEOP_TYPE_TRANSLATION); }
385118611Snjl"TypeStatic"                { count (0); return (PARSEOP_TYPE_STATIC); }
386118611Snjl
387118611Snjl"SparseTranslation"         { count (0); return (PARSEOP_TRANSLATIONTYPE_SPARSE); }
388118611Snjl"DenseTranslation"          { count (0); return (PARSEOP_TRANSLATIONTYPE_DENSE); }
389118611Snjl
390118611Snjl"AddressRangeMemory"        { count (0); return (PARSEOP_ADDRESSTYPE_MEMORY); }
391118611Snjl"AddressRangeReserved"      { count (0); return (PARSEOP_ADDRESSTYPE_RESERVED); }
392118611Snjl"AddressRangeNVS"           { count (0); return (PARSEOP_ADDRESSTYPE_NVS); }
393118611Snjl"AddressRangeACPI"          { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); }
394118611Snjl
395218590Sjkim"__DATE__"                  { count (0); return (PARSEOP___DATE__); }
396218590Sjkim"__FILE__"                  { count (0); return (PARSEOP___FILE__); }
397218590Sjkim"__LINE__"                  { count (0); return (PARSEOP___LINE__); }
398118611Snjl
399118611Snjl"{"                         { count (0); return('{'); }
400118611Snjl"}"                         { count (0); return('}'); }
401118611Snjl","                         { count (0); return(','); }
402118611Snjl"("                         { count (0); return('('); }
403118611Snjl")"                         { count (0); return(')'); }
404118611Snjl
405118611Snjl
406118611Snjl{NameSeg}                   { char *s;
407118611Snjl                                count (0);
408118611Snjl                                s=malloc (ACPI_NAME_SIZE + 1);
409118611Snjl                                if (strcmp (AslCompilertext, "\\"))
410118611Snjl                                {
411118611Snjl                                    strcpy (s, "____");
412151937Sjkim                                    AcpiUtStrupr (AslCompilertext);
413118611Snjl                                }
414118611Snjl                                memcpy (s, AslCompilertext, strlen (AslCompilertext));
415118611Snjl                                AslCompilerlval.s = s;
416118611Snjl                                DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s);
417118611Snjl                                return (PARSEOP_NAMESEG); }
418118611Snjl
419118611Snjl{NameString}                { char *s;
420118611Snjl                                count (0);
421118611Snjl                                s=malloc (strlen (AslCompilertext)+1);
422151937Sjkim                                AcpiUtStrupr (AslCompilertext);
423118611Snjl                                strcpy (s, AslCompilertext);
424118611Snjl                                s[strlen (AslCompilertext)] = 0;
425118611Snjl                                AslCompilerlval.s = s;
426118611Snjl                                DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s);
427118611Snjl                                return (PARSEOP_NAMESTRING); }
428118611Snjl
429118611Snjl"*" |
430118611Snjl"/"                         { count (1);
431118611Snjl                                AslCompilererror ("Parse error, expecting ASL keyword or name");}
432118611Snjl
433118611Snjl.                           { count (1);
434118611Snjl                                sprintf (MsgBuffer,
435118611Snjl                                    "Invalid character (0x%2.2X), expecting ASL keyword or name",
436118611Snjl                                    *AslCompilertext);
437118611Snjl                                AslCompilererror (MsgBuffer);}
438118611Snjl
439118611Snjl<<EOF>>                     { if (AslPopInputFileStack ())
440118611Snjl                                yyterminate();
441118611Snjl                              else
442118611Snjl                                return (PARSEOP_INCLUDE_END);};
443118611Snjl
444118611Snjl%%
445118611Snjl
446118611Snjl/*! [End] no source code translation !*/
447118611Snjl
448118611Snjltypedef struct asl_file_node
449118611Snjl{
450118611Snjl    FILE                    *File;
451118611Snjl    UINT32                  CurrentLineNumber;
452118611Snjl    YY_BUFFER_STATE         State;
453118611Snjl    char                    *Filename;
454118611Snjl    struct asl_file_node    *Next;
455118611Snjl
456118611Snjl} ASL_FILE_NODE;
457118611Snjl
458118611SnjlASL_FILE_NODE               *InputStack = NULL;
459118611Snjl
460118611Snjl
461118611Snjl/*******************************************************************************
462118611Snjl *
463118611Snjl * FUNCTION:    AslPopInputFileStack
464118611Snjl *
465118611Snjl * PARAMETERS:  None
466118611Snjl *
467118611Snjl * RETURN:      0 if a node was popped, -1 otherwise
468118611Snjl *
469118611Snjl * DESCRIPTION: Pop the top of the input file stack and point the parser to
470118611Snjl *              the saved parse buffer contained in the fnode.  Also, set the
471118611Snjl *              global line counters to the saved values.  This function is
472118611Snjl *              called when an include file reaches EOF.
473118611Snjl *
474118611Snjl ******************************************************************************/
475118611Snjl
476118611Snjlint
477118611SnjlAslPopInputFileStack (
478118611Snjl    void)
479118611Snjl{
480118611Snjl    ASL_FILE_NODE           *Fnode;
481118611Snjl    FILE                    *InputFile = NULL;
482118611Snjl
483118611Snjl
484118611Snjl    Fnode = InputStack;
485118611Snjl    DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode);
486118611Snjl
487118611Snjl
488118611Snjl    if (!Fnode)
489118611Snjl    {
490118611Snjl        return -1;
491118611Snjl    }
492118611Snjl
493118611Snjl    /* Close the current include file */
494118611Snjl
495118611Snjl    fclose (yyin);
496118611Snjl
497118611Snjl    /* Update the top-of-stack */
498118611Snjl
499118611Snjl    InputStack = Fnode->Next;
500118611Snjl    InputFile = Fnode->File;
501118611Snjl
502118611Snjl    /* Reset global line counter and filename */
503118611Snjl
504118611Snjl    Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename;
505118611Snjl    Gbl_CurrentLineNumber = Fnode->CurrentLineNumber;
506118611Snjl
507118611Snjl    /* Point the parser to the popped file */
508118611Snjl
509118611Snjl    yy_delete_buffer (YY_CURRENT_BUFFER);
510118611Snjl    yy_switch_to_buffer (Fnode->State);
511118611Snjl
512118611Snjl    /* All done with this node */
513118611Snjl
514167802Sjkim    ACPI_FREE (Fnode);
515118611Snjl    return 0;
516118611Snjl}
517118611Snjl
518118611Snjl
519118611Snjl/*******************************************************************************
520118611Snjl *
521118611Snjl * FUNCTION:    AslPushInputFileStack
522118611Snjl *
523118611Snjl * PARAMETERS:  InputFile           - Open file pointer
524118611Snjl *              Filename            - Name of the file
525118611Snjl *
526118611Snjl * RETURN:      None
527118611Snjl *
528118611Snjl * DESCRIPTION: Push the InputFile onto the file stack, and point the parser
529118611Snjl *              to this file.  Called when an include file is successfully
530118611Snjl *              opened.
531118611Snjl *
532118611Snjl ******************************************************************************/
533118611Snjl
534118611Snjlvoid
535118611SnjlAslPushInputFileStack (
536118611Snjl    FILE                    *InputFile,
537118611Snjl    char                    *Filename)
538118611Snjl{
539118611Snjl    ASL_FILE_NODE           *Fnode;
540118611Snjl    YY_BUFFER_STATE         State;
541118611Snjl
542118611Snjl
543118611Snjl    /* Save the current state in an Fnode */
544118611Snjl
545118611Snjl    Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE));
546118611Snjl
547118611Snjl    Fnode->File                 = yyin;
548118611Snjl    Fnode->Next                 = InputStack;
549118611Snjl    Fnode->State                = YY_CURRENT_BUFFER;
550118611Snjl    Fnode->CurrentLineNumber    = Gbl_CurrentLineNumber;
551118611Snjl    Fnode->Filename             = Gbl_Files[ASL_FILE_INPUT].Filename;
552118611Snjl
553118611Snjl    /* Push it on the stack */
554118611Snjl
555118611Snjl    InputStack = Fnode;
556118611Snjl
557118611Snjl    /* Point the parser to this file */
558118611Snjl
559118611Snjl    State = yy_create_buffer (InputFile, YY_BUF_SIZE);
560118611Snjl    yy_switch_to_buffer (State);
561118611Snjl
562118611Snjl    DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile);
563118611Snjl
564118611Snjl    /* Reset the global line count and filename */
565118611Snjl
566118611Snjl    Gbl_Files[ASL_FILE_INPUT].Filename = Filename;
567118611Snjl    Gbl_CurrentLineNumber = 1;
568118611Snjl    yyin = InputFile;
569118611Snjl}
570118611Snjl
571118611Snjl
572118611Snjl/*******************************************************************************
573118611Snjl *
574118611Snjl * FUNCTION:    ResetCurrentLineBuffer
575118611Snjl *
576118611Snjl * PARAMETERS:  None
577118611Snjl *
578118611Snjl * RETURN:      None
579118611Snjl *
580118611Snjl * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers.
581118611Snjl *
582118611Snjl ******************************************************************************/
583118611Snjl
584118611Snjlvoid
585118611SnjlResetCurrentLineBuffer (
586118611Snjl    void)
587118611Snjl{
588118611Snjl
589118611Snjl    if (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle)
590118611Snjl    {
591118611Snjl        FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer,
592118611Snjl            Gbl_LineBufPtr - Gbl_CurrentLineBuffer);
593118611Snjl    }
594118611Snjl
595118611Snjl    Gbl_CurrentLineOffset += Gbl_CurrentColumn;
596118611Snjl    Gbl_CurrentColumn = 0;
597118611Snjl
598118611Snjl    Gbl_CurrentLineNumber++;
599118611Snjl    Gbl_LogicalLineNumber++;
600118611Snjl    Gbl_LineBufPtr = Gbl_CurrentLineBuffer;
601118611Snjl}
602118611Snjl
603118611Snjl
604118611Snjl/*******************************************************************************
605118611Snjl *
606118611Snjl * FUNCTION:    InsertLineBuffer
607118611Snjl *
608118611Snjl * PARAMETERS:  SourceChar      - One char from the input ASL source file
609118611Snjl *
610118611Snjl * RETURN:      None
611118611Snjl *
612118611Snjl * DESCRIPTION: Put one character of the source file into the temp line buffer
613118611Snjl *
614118611Snjl ******************************************************************************/
615118611Snjl
616118611Snjl#define ASL_SPACES_PER_TAB  4
617118611Snjl
618118611Snjlvoid
619118611SnjlInsertLineBuffer (
620118611Snjl    int                     SourceChar)
621118611Snjl{
622118611Snjl    UINT32                  i;
623118611Snjl    UINT32                  Count = 1;
624118611Snjl
625118611Snjl
626118611Snjl    if (SourceChar == EOF)
627118611Snjl    {
628118611Snjl        return;
629118611Snjl    }
630118611Snjl
631118611Snjl    Gbl_InputByteCount++;
632118611Snjl
633118611Snjl    /* Handle tabs.  Convert to spaces */
634118611Snjl
635118611Snjl    if (SourceChar == '\t')
636118611Snjl    {
637118611Snjl        SourceChar = ' ';
638118611Snjl        Count = ASL_SPACES_PER_TAB -
639118611Snjl                    (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1));
640118611Snjl    }
641118611Snjl
642118611Snjl
643118611Snjl    for (i = 0; i < Count; i++)
644118611Snjl    {
645118611Snjl        Gbl_CurrentColumn++;
646118611Snjl
647118611Snjl        /* Insert the character into the line buffer */
648118611Snjl
649118611Snjl        *Gbl_LineBufPtr = (UINT8) SourceChar;
650118611Snjl        Gbl_LineBufPtr++;
651118611Snjl
652118611Snjl        if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1)))
653118611Snjl        {
654118611Snjl#if 0
655118611Snjl            /*
656118611Snjl             * Warning if we have split a long source line.
657118611Snjl             * <Probably overkill>
658118611Snjl             */
659209746Sjkim            sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE);
660118611Snjl            AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE,
661118611Snjl                            Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
662118611Snjl                            Gbl_CurrentLineOffset, Gbl_CurrentColumn,
663118611Snjl                            Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer);
664118611Snjl#endif
665118611Snjl
666118611Snjl            ResetCurrentLineBuffer ();
667118611Snjl        }
668118611Snjl        else if (SourceChar == '\n')
669118611Snjl        {
670118611Snjl            /* End of line */
671118611Snjl
672118611Snjl            ResetCurrentLineBuffer ();
673118611Snjl        }
674118611Snjl    }
675118611Snjl}
676118611Snjl
677118611Snjl
678118611Snjl/*******************************************************************************
679118611Snjl *
680118611Snjl * FUNCTION:    count
681118611Snjl *
682118611Snjl * PARAMETERS:  yytext      - Contains the matched keyword.
683118611Snjl *              Type        - Keyword/Character type:
684118611Snjl *                             0 = anything except a keyword
685118611Snjl *                             1 = pseudo-keywords
686118611Snjl *                             2 = non-executable ASL keywords
687118611Snjl *                             3 = executable ASL keywords
688118611Snjl *
689118611Snjl * RETURN:      None
690118611Snjl *
691118611Snjl * DESCRIPTION: Count keywords and put them into the line buffer
692118611Snjl *
693118611Snjl ******************************************************************************/
694118611Snjl
695118611Snjlvoid
696118611Snjlcount (
697118611Snjl    int                 Type)
698118611Snjl{
699118611Snjl    int                 i;
700118611Snjl
701118611Snjl
702118611Snjl    switch (Type)
703118611Snjl    {
704118611Snjl    case 2:
705118611Snjl        TotalKeywords++;
706118611Snjl        TotalNamedObjects++;
707118611Snjl        break;
708118611Snjl
709118611Snjl    case 3:
710118611Snjl        TotalKeywords++;
711118611Snjl        TotalExecutableOpcodes++;
712118611Snjl        break;
713118611Snjl    }
714118611Snjl
715118611Snjl    for (i = 0; (yytext[i] != 0) && (yytext[i] != EOF); i++)
716118611Snjl    {
717118611Snjl        InsertLineBuffer (yytext[i]);
718118611Snjl        *Gbl_LineBufPtr = 0;
719118611Snjl    }
720118611Snjl}
721118611Snjl
722118611Snjl
723118611Snjl/*******************************************************************************
724118611Snjl *
725118611Snjl * FUNCTION:    comment
726118611Snjl *
727118611Snjl * PARAMETERS:  none
728118611Snjl *
729118611Snjl * RETURN:      none
730118611Snjl *
731118611Snjl * DESCRIPTION: Process a standard comment.
732118611Snjl *
733118611Snjl ******************************************************************************/
734118611Snjl
735118611Snjlchar
736118611Snjlcomment (void)
737118611Snjl{
738118611Snjl    char                c;
739118611Snjl    char                c1 = 0;
740118611Snjl
741118611Snjl
742118611Snjl    InsertLineBuffer ('/');
743118611Snjl    InsertLineBuffer ('*');
744118611Snjl
745118611Snjlloop:
746118611Snjl
747118611Snjl    /* Eat chars until end-of-comment */
748118611Snjl
749118611Snjl    while ((c = (char) input()) != '*' && c != EOF)
750118611Snjl    {
751118611Snjl        InsertLineBuffer (c);
752118611Snjl        c1 = c;
753118611Snjl    }
754118611Snjl
755118611Snjl    if (c == EOF)
756118611Snjl    {
757118611Snjl        goto EarlyEOF;
758118611Snjl    }
759118611Snjl
760118611Snjl    /*
761118611Snjl     * Check for nested comment -- can help catch cases where a previous
762118611Snjl     * comment was accidently left unterminated
763118611Snjl     */
764118611Snjl    if ((c1 == '/') && (c == '*'))
765118611Snjl    {
766118611Snjl        AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT,
767118611Snjl                        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
768118611Snjl                        Gbl_InputByteCount, Gbl_CurrentColumn,
769118611Snjl                        Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
770118611Snjl    }
771118611Snjl
772118611Snjl    /* Comment is closed only if the NEXT character is a slash */
773118611Snjl
774118611Snjl    InsertLineBuffer (c);
775118611Snjl
776118611Snjl    if ((c1 = (char) input()) != '/' && c1 != EOF)
777118611Snjl    {
778118611Snjl        unput(c1);
779118611Snjl        goto loop;
780118611Snjl    }
781118611Snjl
782118611Snjl    if (c1 == EOF)
783118611Snjl    {
784118611Snjl        goto EarlyEOF;
785118611Snjl    }
786118611Snjl
787118611Snjl    InsertLineBuffer (c1);
788118611Snjl    return TRUE;
789118611Snjl
790118611Snjl
791118611SnjlEarlyEOF:
792118611Snjl    /*
793118611Snjl     * Premature End-Of-File
794118611Snjl     */
795118611Snjl    AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,
796118611Snjl                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
797118611Snjl                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
798118611Snjl                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
799118611Snjl    return (FALSE);
800118611Snjl}
801118611Snjl
802118611Snjl
803118611Snjl/*******************************************************************************
804118611Snjl *
805118611Snjl * FUNCTION:    comment
806118611Snjl *
807118611Snjl * PARAMETERS:  none
808118611Snjl *
809118611Snjl * RETURN:      none
810118611Snjl *
811118611Snjl * DESCRIPTION: Process a new "//" comment.
812118611Snjl *
813118611Snjl ******************************************************************************/
814118611Snjl
815118611Snjlchar
816118611Snjlcomment2 (void)
817118611Snjl{
818118611Snjl    char                c;
819118611Snjl
820118611Snjl
821118611Snjl    InsertLineBuffer ('/');
822118611Snjl    InsertLineBuffer ('/');
823118611Snjl
824118611Snjl    while ((c = (char) input()) != '\n' && c != EOF)
825118611Snjl    {
826118611Snjl        InsertLineBuffer (c);
827118611Snjl    }
828118611Snjl
829118611Snjl    if (c == EOF)
830118611Snjl    {
831138287Smarks        /* End of file is OK, change to newline. Let parser detect EOF later */
832138287Smarks
833138287Smarks        c = '\n';
834118611Snjl    }
835118611Snjl
836118611Snjl    InsertLineBuffer (c);
837118611Snjl    return (TRUE);
838118611Snjl}
839118611Snjl
840118611Snjl
841118611Snjl/*******************************************************************************
842118611Snjl *
843118611Snjl * FUNCTION:    literal
844118611Snjl *
845118611Snjl * PARAMETERS:  none
846118611Snjl *
847118611Snjl * RETURN:      none
848118611Snjl *
849118611Snjl * DESCRIPTION: Process a string literal (surrounded by quotes)
850118611Snjl *
851118611Snjl ******************************************************************************/
852118611Snjl
853118611Snjl#define ASL_NORMAL_CHAR         0
854118611Snjl#define ASL_ESCAPE_SEQUENCE     1
855118611Snjl#define ASL_OCTAL_CONSTANT      2
856118611Snjl#define ASL_HEX_CONSTANT        3
857118611Snjl
858118611Snjlchar
859118611Snjlliteral (void)
860118611Snjl{
861167802Sjkim    char                *StringBuffer = MsgBuffer;
862167802Sjkim    char                *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE;
863118611Snjl    char                *CleanString;
864118611Snjl    char                StringChar;
865118611Snjl    UINT32              State = ASL_NORMAL_CHAR;
866118611Snjl    UINT32              i = 0;
867118611Snjl    UINT8               Digit;
868118611Snjl    char                ConvertBuffer[4];
869118611Snjl
870118611Snjl
871118611Snjl    /*
872118611Snjl     * Eat chars until end-of-literal.
873118611Snjl     * NOTE:  Put back the original surrounding quotes into the
874118611Snjl     * source line buffer.
875118611Snjl     */
876118611Snjl    InsertLineBuffer ('\"');
877118611Snjl    while ((StringChar = (char) input()) != EOF)
878118611Snjl    {
879118611Snjl        InsertLineBuffer (StringChar);
880118611Snjl
881118611SnjlDoCharacter:
882118611Snjl
883118611Snjl        switch (State)
884118611Snjl        {
885118611Snjl        case ASL_NORMAL_CHAR:
886118611Snjl
887118611Snjl            switch (StringChar)
888118611Snjl            {
889118611Snjl            case '\\':
890118611Snjl                /*
891118611Snjl                 * Special handling for backslash-escape sequence.  We will
892118611Snjl                 * toss the backslash and translate the escape char(s).
893118611Snjl                 */
894118611Snjl                State = ASL_ESCAPE_SEQUENCE;
895118611Snjl                continue;
896118611Snjl
897118611Snjl            case '\"':
898118611Snjl
899118611Snjl                /* String terminator */
900118611Snjl
901118611Snjl                goto CompletedString;
902118611Snjl            }
903118611Snjl            break;
904118611Snjl
905118611Snjl
906118611Snjl        case ASL_ESCAPE_SEQUENCE:
907118611Snjl
908118611Snjl            State = ASL_NORMAL_CHAR;
909118611Snjl            switch (StringChar)
910118611Snjl            {
911118611Snjl            case 'a':
912118611Snjl                StringChar = 0x07;      /* BELL */
913118611Snjl                break;
914118611Snjl
915118611Snjl            case 'b':
916118611Snjl                StringChar = 0x08;      /* BACKSPACE */
917118611Snjl                break;
918118611Snjl
919118611Snjl            case 'f':
920118611Snjl                StringChar = 0x0C;      /* FORMFEED */
921118611Snjl                break;
922118611Snjl
923118611Snjl            case 'n':
924118611Snjl                StringChar = 0x0A;      /* LINEFEED */
925118611Snjl                break;
926118611Snjl
927118611Snjl            case 'r':
928118611Snjl                StringChar = 0x0D;      /* CARRIAGE RETURN*/
929118611Snjl                break;
930118611Snjl
931118611Snjl            case 't':
932118611Snjl                StringChar = 0x09;      /* HORIZONTAL TAB */
933118611Snjl                break;
934118611Snjl
935118611Snjl            case 'v':
936118611Snjl                StringChar = 0x0B;      /* VERTICAL TAB */
937118611Snjl                break;
938118611Snjl
939118611Snjl            case 'x':
940118611Snjl                State = ASL_HEX_CONSTANT;
941118611Snjl                i = 0;
942118611Snjl                continue;
943118611Snjl
944118611Snjl            case '\'':                  /* Single Quote */
945118611Snjl            case '\"':                  /* Double Quote */
946118611Snjl            case '\\':                  /* Backslash */
947118611Snjl                break;
948118611Snjl
949118611Snjl            default:
950118611Snjl
951118611Snjl                /* Check for an octal digit (0-7) */
952118611Snjl
953118611Snjl                if (ACPI_IS_OCTAL_DIGIT (StringChar))
954118611Snjl                {
955118611Snjl                    State = ASL_OCTAL_CONSTANT;
956118611Snjl                    ConvertBuffer[0] = StringChar;
957118611Snjl                    i = 1;
958118611Snjl                    continue;
959118611Snjl                }
960118611Snjl
961118611Snjl                /* Unknown escape sequence issue warning, but use the character */
962118611Snjl
963118611Snjl                AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE,
964118611Snjl                                Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
965118611Snjl                                Gbl_CurrentLineOffset, Gbl_CurrentColumn,
966118611Snjl                                Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
967118611Snjl				break;
968118611Snjl            }
969118611Snjl            break;
970118611Snjl
971118611Snjl
972118611Snjl        case ASL_OCTAL_CONSTANT:
973118611Snjl
974118611Snjl            /* Up to three octal digits allowed */
975118611Snjl
976118611Snjl            if (!ACPI_IS_OCTAL_DIGIT (StringChar) ||
977118611Snjl                (i > 2))
978118611Snjl            {
979118611Snjl                /*
980118611Snjl                 * Reached end of the constant.  Convert the assembled ASCII
981118611Snjl                 * string and resume processing of the next character
982118611Snjl                 */
983118611Snjl                ConvertBuffer[i] = 0;
984118611Snjl                Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8);
985118611Snjl
986118611Snjl                /* Check for NULL or non-ascii character (ignore if so) */
987118611Snjl
988118611Snjl                if ((Digit == 0) || (Digit > ACPI_ASCII_MAX))
989118611Snjl                {
990118611Snjl                    AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,
991118611Snjl                                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
992118611Snjl                                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
993118611Snjl                                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
994118611Snjl                }
995118611Snjl                else
996118611Snjl                {
997167802Sjkim                    *StringBuffer = (char) Digit;
998167802Sjkim                    StringBuffer++;
999167802Sjkim                    if (StringBuffer >= EndBuffer)
1000167802Sjkim                    {
1001167802Sjkim                        goto BufferOverflow;
1002167802Sjkim                    }
1003118611Snjl                }
1004118611Snjl
1005118611Snjl                State = ASL_NORMAL_CHAR;
1006118611Snjl                goto DoCharacter;
1007118611Snjl                break;
1008118611Snjl            }
1009118611Snjl
1010118611Snjl            /* Append another digit of the constant */
1011118611Snjl
1012118611Snjl            ConvertBuffer[i] = StringChar;
1013118611Snjl            i++;
1014118611Snjl            continue;
1015118611Snjl
1016118611Snjl
1017118611Snjl        case ASL_HEX_CONSTANT:
1018118611Snjl
1019118611Snjl            /* Up to two hex digits allowed */
1020118611Snjl
1021118611Snjl            if (!ACPI_IS_XDIGIT (StringChar) ||
1022118611Snjl                (i > 1))
1023118611Snjl            {
1024118611Snjl                /*
1025118611Snjl                 * Reached end of the constant.  Convert the assembled ASCII
1026118611Snjl                 * string and resume processing of the next character
1027118611Snjl                 */
1028118611Snjl                ConvertBuffer[i] = 0;
1029118611Snjl                Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16);
1030118611Snjl
1031118611Snjl                /* Check for NULL or non-ascii character (ignore if so) */
1032118611Snjl
1033118611Snjl                if ((Digit == 0) || (Digit > ACPI_ASCII_MAX))
1034118611Snjl                {
1035118611Snjl                    AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING,
1036118611Snjl                                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1037118611Snjl                                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1038118611Snjl                                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1039118611Snjl                }
1040118611Snjl                else
1041118611Snjl                {
1042167802Sjkim                    *StringBuffer = (char) Digit;
1043167802Sjkim                    StringBuffer++;
1044167802Sjkim                    if (StringBuffer >= EndBuffer)
1045167802Sjkim                    {
1046167802Sjkim                        goto BufferOverflow;
1047167802Sjkim                    }
1048118611Snjl                }
1049118611Snjl
1050118611Snjl                State = ASL_NORMAL_CHAR;
1051118611Snjl                goto DoCharacter;
1052118611Snjl                break;
1053118611Snjl            }
1054118611Snjl
1055118611Snjl            /* Append another digit of the constant */
1056118611Snjl
1057118611Snjl            ConvertBuffer[i] = StringChar;
1058118611Snjl            i++;
1059118611Snjl            continue;
1060118611Snjl        }
1061118611Snjl
1062118611Snjl        /* Save the finished character */
1063118611Snjl
1064167802Sjkim        *StringBuffer = StringChar;
1065167802Sjkim        StringBuffer++;
1066167802Sjkim        if (StringBuffer >= EndBuffer)
1067167802Sjkim        {
1068167802Sjkim            goto BufferOverflow;
1069167802Sjkim        }
1070118611Snjl    }
1071118611Snjl
1072118611Snjl    /*
1073118611Snjl     * Premature End-Of-File
1074118611Snjl     */
1075118611Snjl    AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF,
1076118611Snjl                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1077118611Snjl                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1078118611Snjl                    Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1079118611Snjl    return (FALSE);
1080118611Snjl
1081118611Snjl
1082118611SnjlCompletedString:
1083118611Snjl    /*
1084118611Snjl     * Null terminate the input string and copy string to a new buffer
1085118611Snjl     */
1086167802Sjkim    *StringBuffer = 0;
1087118611Snjl
1088118611Snjl    CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1);
1089118611Snjl    if (!CleanString)
1090118611Snjl    {
1091118611Snjl        AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
1092118611Snjl                        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1093118611Snjl                        Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1094118611Snjl                        Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
1095118611Snjl        return (FALSE);
1096118611Snjl    }
1097118611Snjl
1098118611Snjl    ACPI_STRCPY (CleanString, MsgBuffer);
1099118611Snjl    AslCompilerlval.s = CleanString;
1100118611Snjl    return (TRUE);
1101167802Sjkim
1102167802Sjkim
1103167802SjkimBufferOverflow:
1104167802Sjkim
1105167802Sjkim    /* Literal was too long */
1106167802Sjkim
1107167802Sjkim    AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH,
1108167802Sjkim                    Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
1109167802Sjkim                    Gbl_CurrentLineOffset, Gbl_CurrentColumn,
1110167802Sjkim                    Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096");
1111167802Sjkim    return (FALSE);
1112118611Snjl}
1113118611Snjl
1114118611Snjl
1115