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