aslcompiler.l revision 197104
1118611Snjl 2118611Snjl%{ 3118611Snjl/****************************************************************************** 4118611Snjl * 5118611Snjl * Module Name: aslcompiler.l - Flex input file 6118611Snjl * 7118611Snjl *****************************************************************************/ 8118611Snjl 9118611Snjl/****************************************************************************** 10118611Snjl * 11118611Snjl * 1. Copyright Notice 12118611Snjl * 13193529Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 14118611Snjl * All rights reserved. 15118611Snjl * 16118611Snjl * 2. License 17118611Snjl * 18118611Snjl * 2.1. This is your license from Intel Corp. under its intellectual property 19118611Snjl * rights. You may have additional license terms from the party that provided 20118611Snjl * you this software, covering your right to use that party's intellectual 21118611Snjl * property rights. 22118611Snjl * 23118611Snjl * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24118611Snjl * copy of the source code appearing in this file ("Covered Code") an 25118611Snjl * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26118611Snjl * base code distributed originally by Intel ("Original Intel Code") to copy, 27118611Snjl * make derivatives, distribute, use and display any portion of the Covered 28118611Snjl * Code in any form, with the right to sublicense such rights; and 29118611Snjl * 30118611Snjl * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31118611Snjl * license (with the right to sublicense), under only those claims of Intel 32118611Snjl * patents that are infringed by the Original Intel Code, to make, use, sell, 33118611Snjl * offer to sell, and import the Covered Code and derivative works thereof 34118611Snjl * solely to the minimum extent necessary to exercise the above copyright 35118611Snjl * license, and in no event shall the patent license extend to any additions 36118611Snjl * to or modifications of the Original Intel Code. No other license or right 37118611Snjl * is granted directly or by implication, estoppel or otherwise; 38118611Snjl * 39118611Snjl * The above copyright and patent license is granted only if the following 40118611Snjl * conditions are met: 41118611Snjl * 42118611Snjl * 3. Conditions 43118611Snjl * 44118611Snjl * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45118611Snjl * Redistribution of source code of any substantial portion of the Covered 46118611Snjl * Code or modification with rights to further distribute source must include 47118611Snjl * the above Copyright Notice, the above License, this list of Conditions, 48118611Snjl * and the following Disclaimer and Export Compliance provision. In addition, 49118611Snjl * Licensee must cause all Covered Code to which Licensee contributes to 50118611Snjl * contain a file documenting the changes Licensee made to create that Covered 51118611Snjl * Code and the date of any change. Licensee must include in that file the 52118611Snjl * documentation of any changes made by any predecessor Licensee. Licensee 53118611Snjl * must include a prominent statement that the modification is derived, 54118611Snjl * directly or indirectly, from Original Intel Code. 55118611Snjl * 56118611Snjl * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57118611Snjl * Redistribution of source code of any substantial portion of the Covered 58118611Snjl * Code or modification without rights to further distribute source must 59118611Snjl * include the following Disclaimer and Export Compliance provision in the 60118611Snjl * documentation and/or other materials provided with distribution. In 61118611Snjl * addition, Licensee may not authorize further sublicense of source of any 62118611Snjl * portion of the Covered Code, and must include terms to the effect that the 63118611Snjl * license from Licensee to its licensee is limited to the intellectual 64118611Snjl * property embodied in the software Licensee provides to its licensee, and 65118611Snjl * not to intellectual property embodied in modifications its licensee may 66118611Snjl * make. 67118611Snjl * 68118611Snjl * 3.3. Redistribution of Executable. Redistribution in executable form of any 69118611Snjl * substantial portion of the Covered Code or modification must reproduce the 70118611Snjl * above Copyright Notice, and the following Disclaimer and Export Compliance 71118611Snjl * provision in the documentation and/or other materials provided with the 72118611Snjl * distribution. 73118611Snjl * 74118611Snjl * 3.4. Intel retains all right, title, and interest in and to the Original 75118611Snjl * Intel Code. 76118611Snjl * 77118611Snjl * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78118611Snjl * Intel shall be used in advertising or otherwise to promote the sale, use or 79118611Snjl * other dealings in products derived from or relating to the Covered Code 80118611Snjl * without prior written authorization from Intel. 81118611Snjl * 82118611Snjl * 4. Disclaimer and Export Compliance 83118611Snjl * 84118611Snjl * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85118611Snjl * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86118611Snjl * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87118611Snjl * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88118611Snjl * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89118611Snjl * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90118611Snjl * PARTICULAR PURPOSE. 91118611Snjl * 92118611Snjl * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93118611Snjl * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94118611Snjl * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95118611Snjl * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96118611Snjl * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97118611Snjl * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98118611Snjl * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99118611Snjl * LIMITED REMEDY. 100118611Snjl * 101118611Snjl * 4.3. Licensee shall not export, either directly or indirectly, any of this 102118611Snjl * software or system incorporating such software without first obtaining any 103118611Snjl * required license or other approval from the U. S. Department of Commerce or 104118611Snjl * any other agency or department of the United States Government. In the 105118611Snjl * event Licensee exports any such software from the United States or 106118611Snjl * re-exports any such software from a foreign destination, Licensee shall 107118611Snjl * ensure that the distribution and export/re-export of the software is in 108118611Snjl * compliance with all laws, regulations, orders, or other restrictions of the 109118611Snjl * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110118611Snjl * any of its subsidiaries will export/re-export any technical data, process, 111118611Snjl * software, or service, directly or indirectly, to any country for which the 112118611Snjl * United States government or any agency thereof requires an export license, 113118611Snjl * other governmental approval, or letter of assurance, without first obtaining 114118611Snjl * such license, approval or letter. 115118611Snjl * 116118611Snjl *****************************************************************************/ 117118611Snjl 118118611Snjl 119118611Snjl#include <stdlib.h> 120118611Snjl#include <string.h> 121151937Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h> 122118611Snjl#include "aslcompiler.y.h" 123118611SnjlYYSTYPE AslCompilerlval; 124118611Snjl 125118611Snjl/* 126118611Snjl * Generation: Use the following command line: 127118611Snjl * 128118611Snjl * flex.exe -PAslCompiler -i -o$(InputPath).c $(InputPath) 129118611Snjl * 130118611Snjl * -i: Scanner must be case-insensitive 131118611Snjl */ 132118611Snjl 133118611Snjl#define _COMPONENT ACPI_COMPILER 134118611Snjl ACPI_MODULE_NAME ("aslscan") 135118611Snjlchar 136118611Snjlcomment (void); 137118611Snjlchar 138118611Snjlcomment2 (void); 139118611Snjlvoid 140118611Snjlcount (int type); 141118611Snjlchar 142118611Snjlliteral (void); 143118611Snjlvoid 144118611Snjlcopy (void); 145118611Snjl 146118611Snjl/*! [Begin] no source code translation */ 147118611Snjl 148118611Snjl%} 149118611Snjl 150118611Snjl 151118611SnjlLeadNameChar [A-Za-z_] 152118611SnjlDigitChar [0-9] 153118611SnjlHexDigitChar [A-Fa-f0-9] 154118611SnjlRootChar [\\] 155118611SnjlNothing [] 156118611Snjl 157118611SnjlNameChar [A-Za-z_0-9] 158118611SnjlNameSeg1 {LeadNameChar}{NameChar} 159118611SnjlNameSeg2 {LeadNameChar}{NameChar}{NameChar} 160118611SnjlNameSeg3 {LeadNameChar}{NameChar}{NameChar}{NameChar} 161118611SnjlNameSeg {LeadNameChar}|{NameSeg1}|{NameSeg2}|{NameSeg3} 162118611Snjl 163118611SnjlNameString {RootChar}|{RootChar}{NamePath}|[\^]+{NamePath}|{NonEmptyNamePath} 164118611SnjlNamePath {NonEmptyNamePath}? 165118611SnjlNonEmptyNamePath {NameSeg}{NamePathTail}* 166118611SnjlNamePathTail [.]{NameSeg} 167118611Snjl 168118611Snjl%% 169118611Snjl 170118611Snjl[ ] { count (0); } 171193529Sjkim[\n] { count (0); } /* Handle files with both LF and CR/LF */ 172193529Sjkim[\r] { count (0); } /* termination on both Unix and Windows */ 173118611Snjl[ \t] { count (0); } 174118611Snjl 175118611Snjl 176118611Snjl"/*" { if (!comment ()) yyterminate (); } 177118611Snjl"//" { if (!comment2 ()) yyterminate (); } 178118611Snjl 179118611Snjl"\"" { if (literal ()) return (PARSEOP_STRING_LITERAL); else yyterminate (); } 180118611Snjl 181118611Snjl 182118611Snjl0[xX]{HexDigitChar}+ | 183118611Snjl{DigitChar}+ { AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext); 184118611Snjl count (1); return (PARSEOP_INTEGER); } 185118611Snjl 186118611Snjl"Include" { count (1); return (PARSEOP_INCLUDE); } 187118611Snjl"#include" { count (1); return (PARSEOP_INCLUDE_CSTYLE); } 188118611Snjl"#line" { count (1); return (PARSEOP_LINE_CSTYLE); } 189118611Snjl"External" { count (1); return (PARSEOP_EXTERNAL); } 190118611Snjl 191118611Snjl 192118611Snjl"Ones" { count (1); return (PARSEOP_ONES); } 193118611Snjl"One" { count (1); return (PARSEOP_ONE); } 194118611Snjl"Zero" { count (1); return (PARSEOP_ZERO); } 195118611Snjl"Revision" { count (1); return (PARSEOP_REVISION); } 196118611Snjl 197118611Snjl"Offset" { count (1); return (PARSEOP_OFFSET); } 198118611Snjl"AccessAs" { count (1); return (PARSEOP_ACCESSAS); } 199118611Snjl"BankField" { count (2); return (PARSEOP_BANKFIELD); } 200118611Snjl"CreateBitField" { count (2); return (PARSEOP_CREATEBITFIELD); } 201118611Snjl"CreateByteField" { count (2); return (PARSEOP_CREATEBYTEFIELD); } 202118611Snjl"CreateDWordField" { count (2); return (PARSEOP_CREATEDWORDFIELD); } 203118611Snjl"CreateField" { count (2); return (PARSEOP_CREATEFIELD); } 204118611Snjl"CreateQWordField" { count (2); return (PARSEOP_CREATEQWORDFIELD); } 205118611Snjl"CreateWordField" { count (2); return (PARSEOP_CREATEWORDFIELD); } 206118611Snjl"DataTableRegion" { count (2); return (PARSEOP_DATATABLEREGION); } 207118611Snjl"Device" { count (2); return (PARSEOP_DEVICE); } 208118611Snjl"Event" { count (2); return (PARSEOP_EVENT); } 209118611Snjl"Field" { count (2); return (PARSEOP_FIELD); } 210138287Smarks"Function" { count (2); return (PARSEOP_FUNCTION); } 211118611Snjl"IndexField" { count (2); return (PARSEOP_INDEXFIELD); } 212118611Snjl"Method" { count (2); return (PARSEOP_METHOD); } 213118611Snjl"Mutex" { count (2); return (PARSEOP_MUTEX); } 214118611Snjl"OperationRegion" { count (2); return (PARSEOP_OPERATIONREGION); } 215118611Snjl"PowerResource" { count (2); return (PARSEOP_POWERRESOURCE); } 216118611Snjl"Processor" { count (2); return (PARSEOP_PROCESSOR); } 217118611Snjl"ThermalZone" { count (2); return (PARSEOP_THERMALZONE); } 218118611Snjl"Alias" { count (2); return (PARSEOP_ALIAS); } 219118611Snjl"Name" { count (2); return (PARSEOP_NAME); } 220118611Snjl"Scope" { count (2); return (PARSEOP_SCOPE); } 221118611Snjl"Break" { count (3); return (PARSEOP_BREAK); } 222118611Snjl"BreakPoint" { count (3); return (PARSEOP_BREAKPOINT); } 223118611Snjl"Continue" { count (3); return (PARSEOP_CONTINUE); } 224118611Snjl"Fatal" { count (3); return (PARSEOP_FATAL); } 225118611Snjl"If" { count (3); return (PARSEOP_IF); } 226118611Snjl"Else" { count (3); return (PARSEOP_ELSE); } 227118611Snjl"ElseIf" { count (3); return (PARSEOP_ELSEIF); } 228118611Snjl"Load" { count (3); return (PARSEOP_LOAD); } 229118611Snjl"Noop" { count (3); return (PARSEOP_NOOP); } 230118611Snjl"Notify" { count (3); return (PARSEOP_NOTIFY); } 231118611Snjl"Release" { count (3); return (PARSEOP_RELEASE); } 232118611Snjl"Reset" { count (3); return (PARSEOP_RESET); } 233118611Snjl"Return" { count (3); return (PARSEOP_RETURN); } 234118611Snjl"Signal" { count (3); return (PARSEOP_SIGNAL); } 235118611Snjl"Sleep" { count (3); return (PARSEOP_SLEEP); } 236118611Snjl"Stall" { count (3); return (PARSEOP_STALL); } 237118611Snjl"Switch" { count (3); return (PARSEOP_SWITCH); } 238118611Snjl"Case" { count (3); return (PARSEOP_CASE); } 239118611Snjl"Default" { count (3); return (PARSEOP_DEFAULT); } 240118611Snjl"Unload" { count (3); return (PARSEOP_UNLOAD); } 241118611Snjl"While" { count (3); return (PARSEOP_WHILE); } 242118611Snjl 243118611Snjl"Acquire" { count (3); return (PARSEOP_ACQUIRE); } 244118611Snjl"Add" { count (3); return (PARSEOP_ADD); } 245118611Snjl"And" { count (3); return (PARSEOP_AND); } 246118611Snjl"Concatenate" { count (3); return (PARSEOP_CONCATENATE); } 247118611Snjl"ConcatenateResTemplate" { count (3); return (PARSEOP_CONCATENATERESTEMPLATE); } 248118611Snjl"CondRefOf" { count (3); return (PARSEOP_CONDREFOF); } 249118611Snjl"CopyObject" { count (3); return (PARSEOP_COPYOBJECT); } 250118611Snjl"Decrement" { count (3); return (PARSEOP_DECREMENT); } 251118611Snjl"DeRefOf" { count (3); return (PARSEOP_DEREFOF); } 252118611Snjl"Divide" { count (3); return (PARSEOP_DIVIDE); } 253118611Snjl"FindSetLeftBit" { count (3); return (PARSEOP_FINDSETLEFTBIT); } 254118611Snjl"FindSetRightBit" { count (3); return (PARSEOP_FINDSETRIGHTBIT); } 255118611Snjl"FromBCD" { count (3); return (PARSEOP_FROMBCD); } 256118611Snjl"Increment" { count (3); return (PARSEOP_INCREMENT); } 257118611Snjl"Index" { count (3); return (PARSEOP_INDEX); } 258118611Snjl"LAnd" { count (3); return (PARSEOP_LAND); } 259118611Snjl"LEqual" { count (3); return (PARSEOP_LEQUAL); } 260118611Snjl"LGreater" { count (3); return (PARSEOP_LGREATER); } 261118611Snjl"LGreaterEqual" { count (3); return (PARSEOP_LGREATEREQUAL); } 262118611Snjl"LLess" { count (3); return (PARSEOP_LLESS); } 263118611Snjl"LLessEqual" { count (3); return (PARSEOP_LLESSEQUAL); } 264118611Snjl"LNot" { count (3); return (PARSEOP_LNOT); } 265118611Snjl"LNotEqual" { count (3); return (PARSEOP_LNOTEQUAL); } 266118611Snjl"LoadTable" { count (3); return (PARSEOP_LOADTABLE); } 267118611Snjl"LOr" { count (3); return (PARSEOP_LOR); } 268118611Snjl"Match" { count (3); return (PARSEOP_MATCH); } 269118611Snjl"Mid" { count (3); return (PARSEOP_MID); } 270118611Snjl"Mod" { count (3); return (PARSEOP_MOD); } 271118611Snjl"Multiply" { count (3); return (PARSEOP_MULTIPLY); } 272118611Snjl"NAnd" { count (3); return (PARSEOP_NAND); } 273118611Snjl"NOr" { count (3); return (PARSEOP_NOR); } 274118611Snjl"Not" { count (3); return (PARSEOP_NOT); } 275118611Snjl"ObjectType" { count (3); return (PARSEOP_OBJECTTYPE); } 276118611Snjl"Or" { count (3); return (PARSEOP_OR); } 277118611Snjl"RefOf" { count (3); return (PARSEOP_REFOF); } 278118611Snjl"ShiftLeft" { count (3); return (PARSEOP_SHIFTLEFT); } 279118611Snjl"ShiftRight" { count (3); return (PARSEOP_SHIFTRIGHT); } 280118611Snjl"SizeOf" { count (3); return (PARSEOP_SIZEOF); } 281118611Snjl"Store" { count (3); return (PARSEOP_STORE); } 282118611Snjl"Subtract" { count (3); return (PARSEOP_SUBTRACT); } 283138287Smarks"Timer" { count (3); return (PARSEOP_TIMER); } 284118611Snjl"ToBCD" { count (3); return (PARSEOP_TOBCD); } 285118611Snjl"ToBuffer" { count (3); return (PARSEOP_TOBUFFER); } 286118611Snjl"ToDecimalString" { count (3); return (PARSEOP_TODECIMALSTRING); } 287118611Snjl"ToHexString" { count (3); return (PARSEOP_TOHEXSTRING); } 288118611Snjl"ToInteger" { count (3); return (PARSEOP_TOINTEGER); } 289118611Snjl"ToString" { count (3); return (PARSEOP_TOSTRING); } 290118611Snjl"Wait" { count (3); return (PARSEOP_WAIT); } 291118611Snjl"XOr" { count (3); return (PARSEOP_XOR); } 292118611Snjl 293118611Snjl"Arg0" { count (1); return (PARSEOP_ARG0); } 294118611Snjl"Arg1" { count (1); return (PARSEOP_ARG1); } 295118611Snjl"Arg2" { count (1); return (PARSEOP_ARG2); } 296118611Snjl"Arg3" { count (1); return (PARSEOP_ARG3); } 297118611Snjl"Arg4" { count (1); return (PARSEOP_ARG4); } 298118611Snjl"Arg5" { count (1); return (PARSEOP_ARG5); } 299118611Snjl"Arg6" { count (1); return (PARSEOP_ARG6); } 300118611Snjl 301118611Snjl"Local0" { count (1); return (PARSEOP_LOCAL0); } 302118611Snjl"Local1" { count (1); return (PARSEOP_LOCAL1); } 303118611Snjl"Local2" { count (1); return (PARSEOP_LOCAL2); } 304118611Snjl"Local3" { count (1); return (PARSEOP_LOCAL3); } 305118611Snjl"Local4" { count (1); return (PARSEOP_LOCAL4); } 306118611Snjl"Local5" { count (1); return (PARSEOP_LOCAL5); } 307118611Snjl"Local6" { count (1); return (PARSEOP_LOCAL6); } 308118611Snjl"Local7" { count (1); return (PARSEOP_LOCAL7); } 309118611Snjl 310118611Snjl"Debug" { count (1); return (PARSEOP_DEBUG); } 311118611Snjl 312118611Snjl"DefinitionBlock" { count (1); return (PARSEOP_DEFINITIONBLOCK); } 313118611Snjl"Buffer" { count (1); return (PARSEOP_BUFFER); } 314118611Snjl"Package" { count (1); return (PARSEOP_PACKAGE); } 315118611Snjl 316118611Snjl"EISAID" { count (1); return (PARSEOP_EISAID); } 317118611Snjl"ResourceTemplate" { count (1); return (PARSEOP_RESOURCETEMPLATE); } 318138287Smarks"ToUUID" { count (1); return (PARSEOP_TOUUID); } 319118611Snjl"Unicode" { count (1); return (PARSEOP_UNICODE); } 320118611Snjl"DMA" { count (1); return (PARSEOP_DMA); } 321118611Snjl"DWordIO" { count (1); return (PARSEOP_DWORDIO); } 322118611Snjl"DWordMemory" { count (1); return (PARSEOP_DWORDMEMORY); } 323138287Smarks"DWordSpace" { count (1); return (PARSEOP_DWORDSPACE); } 324118611Snjl"EndDependentFn" { count (1); return (PARSEOP_ENDDEPENDENTFN); } 325138287Smarks"ExtendedIO" { count (1); return (PARSEOP_EXTENDEDIO); } 326138287Smarks"ExtendedMemory" { count (1); return (PARSEOP_EXTENDEDMEMORY); } 327138287Smarks"ExtendedSpace" { count (1); return (PARSEOP_EXTENDEDSPACE); } 328118611Snjl"FixedIO" { count (1); return (PARSEOP_FIXEDIO); } 329118611Snjl"Interrupt" { count (1); return (PARSEOP_INTERRUPT); } 330118611Snjl"IO" { count (1); return (PARSEOP_IO); } 331118611Snjl"IRQNoFlags" { count (1); return (PARSEOP_IRQNOFLAGS); } 332118611Snjl"IRQ" { count (1); return (PARSEOP_IRQ); } 333118611Snjl"Memory24" { count (1); return (PARSEOP_MEMORY24); } 334118611Snjl"Memory32Fixed" { count (1); return (PARSEOP_MEMORY32FIXED); } 335118611Snjl"Memory32" { count (1); return (PARSEOP_MEMORY32); } 336118611Snjl"QWordIO" { count (1); return (PARSEOP_QWORDIO); } 337118611Snjl"QWordMemory" { count (1); return (PARSEOP_QWORDMEMORY); } 338138287Smarks"QWordSpace" { count (1); return (PARSEOP_QWORDSPACE); } 339118611Snjl"Register" { count (1); return (PARSEOP_REGISTER); } 340118611Snjl"StartDependentFn" { count (1); return (PARSEOP_STARTDEPENDENTFN); } 341118611Snjl"StartDependentFnNoPri" { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); } 342118611Snjl"VendorLong" { count (1); return (PARSEOP_VENDORLONG); } 343118611Snjl"VendorShort" { count (1); return (PARSEOP_VENDORSHORT); } 344118611Snjl"WordBusNumber" { count (1); return (PARSEOP_WORDBUSNUMBER); } 345118611Snjl"WordIO" { count (1); return (PARSEOP_WORDIO); } 346138287Smarks"WordSpace" { count (1); return (PARSEOP_WORDSPACE); } 347118611Snjl 348118611Snjl"UnknownObj" { count (0); return (PARSEOP_OBJECTTYPE_UNK); } 349118611Snjl"IntObj" { count (0); return (PARSEOP_OBJECTTYPE_INT); } 350118611Snjl"StrObj" { count (0); return (PARSEOP_OBJECTTYPE_STR); } 351118611Snjl"BuffObj" { count (0); return (PARSEOP_OBJECTTYPE_BUF); } 352118611Snjl"PkgObj" { count (0); return (PARSEOP_OBJECTTYPE_PKG); } 353118611Snjl"FieldUnitObj" { count (0); return (PARSEOP_OBJECTTYPE_FLD); } 354118611Snjl"DeviceObj" { count (0); return (PARSEOP_OBJECTTYPE_DEV); } 355118611Snjl"EventObj" { count (0); return (PARSEOP_OBJECTTYPE_EVT); } 356118611Snjl"MethodObj" { count (0); return (PARSEOP_OBJECTTYPE_MTH); } 357118611Snjl"MutexObj" { count (0); return (PARSEOP_OBJECTTYPE_MTX); } 358118611Snjl"OpRegionObj" { count (0); return (PARSEOP_OBJECTTYPE_OPR); } 359118611Snjl"PowerResObj" { count (0); return (PARSEOP_OBJECTTYPE_POW); } 360151937Sjkim"ProcessorObj" { count (0); return (PARSEOP_OBJECTTYPE_PRO); } 361118611Snjl"ThermalZoneObj" { count (0); return (PARSEOP_OBJECTTYPE_THZ); } 362118611Snjl"BuffFieldObj" { count (0); return (PARSEOP_OBJECTTYPE_BFF); } 363118611Snjl"DDBHandleObj" { count (0); return (PARSEOP_OBJECTTYPE_DDB); } 364118611Snjl 365118611Snjl"AnyAcc" { count (0); return (PARSEOP_ACCESSTYPE_ANY); } 366118611Snjl"ByteAcc" { count (0); return (PARSEOP_ACCESSTYPE_BYTE); } 367118611Snjl"WordAcc" { count (0); return (PARSEOP_ACCESSTYPE_WORD); } 368118611Snjl"DWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_DWORD); } 369118611Snjl"QWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_QWORD); } 370118611Snjl"BufferAcc" { count (0); return (PARSEOP_ACCESSTYPE_BUF); } 371118611Snjl 372118611Snjl"Lock" { count (0); return (PARSEOP_LOCKRULE_LOCK); } 373118611Snjl"NoLock" { count (0); return (PARSEOP_LOCKRULE_NOLOCK); } 374118611Snjl 375118611Snjl"Preserve" { count (0); return (PARSEOP_UPDATERULE_PRESERVE); } 376118611Snjl"WriteAsOnes" { count (0); return (PARSEOP_UPDATERULE_ONES); } 377118611Snjl"WriteAsZeros" { count (0); return (PARSEOP_UPDATERULE_ZEROS); } 378118611Snjl 379118611Snjl"Serialized" { count (0); return (PARSEOP_SERIALIZERULE_SERIAL); } 380118611Snjl"NotSerialized" { count (0); return (PARSEOP_SERIALIZERULE_NOTSERIAL); } 381118611Snjl 382118611Snjl"SystemIO" { count (0); return (PARSEOP_REGIONSPACE_IO); } 383118611Snjl"SystemMemory" { count (0); return (PARSEOP_REGIONSPACE_MEM); } 384118611Snjl"PCI_Config" { count (0); return (PARSEOP_REGIONSPACE_PCI); } 385118611Snjl"EmbeddedControl" { count (0); return (PARSEOP_REGIONSPACE_EC); } 386118611Snjl"SMBus" { count (0); return (PARSEOP_REGIONSPACE_SMBUS); } 387118611Snjl"SystemCMOS" { count (0); return (PARSEOP_REGIONSPACE_CMOS); } 388118611Snjl"PciBarTarget" { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); } 389197104Sjkim"IPMI" { count (0); return (PARSEOP_REGIONSPACE_IPMI); } 390118611Snjl 391118611Snjl"FFixedHW" { count (0); return (PARSEOP_ADDRESSSPACE_FFIXEDHW); } 392118611Snjl 393118611Snjl"SMBQuick" { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); } 394118611Snjl"SMBSendReceive" { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); } 395118611Snjl"SMBByte" { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); } 396118611Snjl"SMBWord" { count (0); return (PARSEOP_ACCESSATTRIB_WORD); } 397118611Snjl"SMBBlock" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); } 398118611Snjl"SMBProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); } 399118611Snjl"SMBBlockProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); } 400118611Snjl 401118611Snjl"MTR" { count (0); return (PARSEOP_MATCHTYPE_MTR); } 402118611Snjl"MEQ" { count (0); return (PARSEOP_MATCHTYPE_MEQ); } 403118611Snjl"MLE" { count (0); return (PARSEOP_MATCHTYPE_MLE); } 404118611Snjl"MLT" { count (0); return (PARSEOP_MATCHTYPE_MLT); } 405118611Snjl"MGE" { count (0); return (PARSEOP_MATCHTYPE_MGE); } 406118611Snjl"MGT" { count (0); return (PARSEOP_MATCHTYPE_MGT); } 407118611Snjl 408118611Snjl"Compatibility" { count (0); return (PARSEOP_DMATYPE_COMPATIBILITY); } 409118611Snjl"TypeA" { count (0); return (PARSEOP_DMATYPE_A); } 410118611Snjl"TypeB" { count (0); return (PARSEOP_DMATYPE_B); } 411118611Snjl"TypeF" { count (0); return (PARSEOP_DMATYPE_F); } 412118611Snjl 413118611Snjl"BusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_MASTER); } 414118611Snjl"NotBusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_NOTMASTER); } 415118611Snjl 416118611Snjl"Transfer8" { count (0); return (PARSEOP_XFERTYPE_8); } 417118611Snjl"Transfer8_16" { count (0); return (PARSEOP_XFERTYPE_8_16); } 418118611Snjl"Transfer16" { count (0); return (PARSEOP_XFERTYPE_16); } 419118611Snjl 420118611Snjl"ResourceConsumer" { count (0); return (PARSEOP_RESOURCETYPE_CONSUMER); } 421118611Snjl"ResourceProducer" { count (0); return (PARSEOP_RESOURCETYPE_PRODUCER); } 422118611Snjl 423118611Snjl"MinFixed" { count (0); return (PARSEOP_MINTYPE_FIXED); } 424118611Snjl"MinNotFixed" { count (0); return (PARSEOP_MINTYPE_NOTFIXED); } 425118611Snjl 426118611Snjl"MaxFixed" { count (0); return (PARSEOP_MAXTYPE_FIXED); } 427118611Snjl"MaxNotFixed" { count (0); return (PARSEOP_MAXTYPE_NOTFIXED); } 428118611Snjl 429118611Snjl"PosDecode" { count (0); return (PARSEOP_DECODETYPE_POS); } 430118611Snjl"SubDecode" { count (0); return (PARSEOP_DECODETYPE_SUB); } 431118611Snjl 432118611Snjl"ISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_ISAONLY); } 433118611Snjl"NonISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_NONISAONLY); } 434118611Snjl"EntireRange" { count (0); return (PARSEOP_RANGETYPE_ENTIRE); } 435118611Snjl 436118611Snjl"Cacheable" { count (0); return (PARSEOP_MEMTYPE_CACHEABLE); } 437118611Snjl"WriteCombining" { count (0); return (PARSEOP_MEMTYPE_WRITECOMBINING); } 438118611Snjl"Prefetchable" { count (0); return (PARSEOP_MEMTYPE_PREFETCHABLE); } 439118611Snjl"NonCacheable" { count (0); return (PARSEOP_MEMTYPE_NONCACHEABLE); } 440118611Snjl 441118611Snjl"ReadWrite" { count (0); return (PARSEOP_READWRITETYPE_BOTH); } 442118611Snjl"ReadOnly" { count (0); return (PARSEOP_READWRITETYPE_READONLY); } 443118611Snjl 444118611Snjl"Edge" { count (0); return (PARSEOP_INTTYPE_EDGE); } 445118611Snjl"Level" { count (0); return (PARSEOP_INTTYPE_LEVEL); } 446118611Snjl 447118611Snjl"ActiveHigh" { count (0); return (PARSEOP_INTLEVEL_ACTIVEHIGH); } 448118611Snjl"ActiveLow" { count (0); return (PARSEOP_INTLEVEL_ACTIVELOW); } 449118611Snjl 450118611Snjl"Shared" { count (0); return (PARSEOP_SHARETYPE_SHARED); } 451118611Snjl"Exclusive" { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVE); } 452118611Snjl 453118611Snjl"Decode10" { count (0); return (PARSEOP_IODECODETYPE_10); } 454118611Snjl"Decode16" { count (0); return (PARSEOP_IODECODETYPE_16); } 455118611Snjl 456118611Snjl"TypeTranslation" { count (0); return (PARSEOP_TYPE_TRANSLATION); } 457118611Snjl"TypeStatic" { count (0); return (PARSEOP_TYPE_STATIC); } 458118611Snjl 459118611Snjl"SparseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_SPARSE); } 460118611Snjl"DenseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_DENSE); } 461118611Snjl 462118611Snjl"AddressRangeMemory" { count (0); return (PARSEOP_ADDRESSTYPE_MEMORY); } 463118611Snjl"AddressRangeReserved" { count (0); return (PARSEOP_ADDRESSTYPE_RESERVED); } 464118611Snjl"AddressRangeNVS" { count (0); return (PARSEOP_ADDRESSTYPE_NVS); } 465118611Snjl"AddressRangeACPI" { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); } 466118611Snjl 467118611Snjl 468118611Snjl"{" { count (0); return('{'); } 469118611Snjl"}" { count (0); return('}'); } 470118611Snjl"," { count (0); return(','); } 471118611Snjl"(" { count (0); return('('); } 472118611Snjl")" { count (0); return(')'); } 473118611Snjl 474118611Snjl 475118611Snjl{NameSeg} { char *s; 476118611Snjl count (0); 477118611Snjl s=malloc (ACPI_NAME_SIZE + 1); 478118611Snjl if (strcmp (AslCompilertext, "\\")) 479118611Snjl { 480118611Snjl strcpy (s, "____"); 481151937Sjkim AcpiUtStrupr (AslCompilertext); 482118611Snjl } 483118611Snjl memcpy (s, AslCompilertext, strlen (AslCompilertext)); 484118611Snjl AslCompilerlval.s = s; 485118611Snjl DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s); 486118611Snjl return (PARSEOP_NAMESEG); } 487118611Snjl 488118611Snjl{NameString} { char *s; 489118611Snjl count (0); 490118611Snjl s=malloc (strlen (AslCompilertext)+1); 491151937Sjkim AcpiUtStrupr (AslCompilertext); 492118611Snjl strcpy (s, AslCompilertext); 493118611Snjl s[strlen (AslCompilertext)] = 0; 494118611Snjl AslCompilerlval.s = s; 495118611Snjl DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s); 496118611Snjl return (PARSEOP_NAMESTRING); } 497118611Snjl 498118611Snjl"*" | 499118611Snjl"/" { count (1); 500118611Snjl AslCompilererror ("Parse error, expecting ASL keyword or name");} 501118611Snjl 502118611Snjl. { count (1); 503118611Snjl sprintf (MsgBuffer, 504118611Snjl "Invalid character (0x%2.2X), expecting ASL keyword or name", 505118611Snjl *AslCompilertext); 506118611Snjl AslCompilererror (MsgBuffer);} 507118611Snjl 508118611Snjl<<EOF>> { if (AslPopInputFileStack ()) 509118611Snjl yyterminate(); 510118611Snjl else 511118611Snjl return (PARSEOP_INCLUDE_END);}; 512118611Snjl 513118611Snjl%% 514118611Snjl 515118611Snjl/*! [End] no source code translation !*/ 516118611Snjl 517118611Snjltypedef struct asl_file_node 518118611Snjl{ 519118611Snjl FILE *File; 520118611Snjl UINT32 CurrentLineNumber; 521118611Snjl YY_BUFFER_STATE State; 522118611Snjl char *Filename; 523118611Snjl struct asl_file_node *Next; 524118611Snjl 525118611Snjl} ASL_FILE_NODE; 526118611Snjl 527118611SnjlASL_FILE_NODE *InputStack = NULL; 528118611Snjl 529118611Snjl 530118611Snjl/******************************************************************************* 531118611Snjl * 532118611Snjl * FUNCTION: AslPopInputFileStack 533118611Snjl * 534118611Snjl * PARAMETERS: None 535118611Snjl * 536118611Snjl * RETURN: 0 if a node was popped, -1 otherwise 537118611Snjl * 538118611Snjl * DESCRIPTION: Pop the top of the input file stack and point the parser to 539118611Snjl * the saved parse buffer contained in the fnode. Also, set the 540118611Snjl * global line counters to the saved values. This function is 541118611Snjl * called when an include file reaches EOF. 542118611Snjl * 543118611Snjl ******************************************************************************/ 544118611Snjl 545118611Snjlint 546118611SnjlAslPopInputFileStack ( 547118611Snjl void) 548118611Snjl{ 549118611Snjl ASL_FILE_NODE *Fnode; 550118611Snjl FILE *InputFile = NULL; 551118611Snjl 552118611Snjl 553118611Snjl Fnode = InputStack; 554118611Snjl DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode); 555118611Snjl 556118611Snjl 557118611Snjl if (!Fnode) 558118611Snjl { 559118611Snjl return -1; 560118611Snjl } 561118611Snjl 562118611Snjl /* Close the current include file */ 563118611Snjl 564118611Snjl fclose (yyin); 565118611Snjl 566118611Snjl /* Update the top-of-stack */ 567118611Snjl 568118611Snjl InputStack = Fnode->Next; 569118611Snjl InputFile = Fnode->File; 570118611Snjl 571118611Snjl /* Reset global line counter and filename */ 572118611Snjl 573118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; 574118611Snjl Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; 575118611Snjl 576118611Snjl /* Point the parser to the popped file */ 577118611Snjl 578118611Snjl yy_delete_buffer (YY_CURRENT_BUFFER); 579118611Snjl yy_switch_to_buffer (Fnode->State); 580118611Snjl 581118611Snjl /* All done with this node */ 582118611Snjl 583167802Sjkim ACPI_FREE (Fnode); 584118611Snjl return 0; 585118611Snjl} 586118611Snjl 587118611Snjl 588118611Snjl/******************************************************************************* 589118611Snjl * 590118611Snjl * FUNCTION: AslPushInputFileStack 591118611Snjl * 592118611Snjl * PARAMETERS: InputFile - Open file pointer 593118611Snjl * Filename - Name of the file 594118611Snjl * 595118611Snjl * RETURN: None 596118611Snjl * 597118611Snjl * DESCRIPTION: Push the InputFile onto the file stack, and point the parser 598118611Snjl * to this file. Called when an include file is successfully 599118611Snjl * opened. 600118611Snjl * 601118611Snjl ******************************************************************************/ 602118611Snjl 603118611Snjlvoid 604118611SnjlAslPushInputFileStack ( 605118611Snjl FILE *InputFile, 606118611Snjl char *Filename) 607118611Snjl{ 608118611Snjl ASL_FILE_NODE *Fnode; 609118611Snjl YY_BUFFER_STATE State; 610118611Snjl 611118611Snjl 612118611Snjl /* Save the current state in an Fnode */ 613118611Snjl 614118611Snjl Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE)); 615118611Snjl 616118611Snjl Fnode->File = yyin; 617118611Snjl Fnode->Next = InputStack; 618118611Snjl Fnode->State = YY_CURRENT_BUFFER; 619118611Snjl Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; 620118611Snjl Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; 621118611Snjl 622118611Snjl /* Push it on the stack */ 623118611Snjl 624118611Snjl InputStack = Fnode; 625118611Snjl 626118611Snjl /* Point the parser to this file */ 627118611Snjl 628118611Snjl State = yy_create_buffer (InputFile, YY_BUF_SIZE); 629118611Snjl yy_switch_to_buffer (State); 630118611Snjl 631118611Snjl DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile); 632118611Snjl 633118611Snjl /* Reset the global line count and filename */ 634118611Snjl 635118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename = Filename; 636118611Snjl Gbl_CurrentLineNumber = 1; 637118611Snjl yyin = InputFile; 638118611Snjl} 639118611Snjl 640118611Snjl 641118611Snjl/******************************************************************************* 642118611Snjl * 643118611Snjl * FUNCTION: ResetCurrentLineBuffer 644118611Snjl * 645118611Snjl * PARAMETERS: None 646118611Snjl * 647118611Snjl * RETURN: None 648118611Snjl * 649118611Snjl * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers. 650118611Snjl * 651118611Snjl ******************************************************************************/ 652118611Snjl 653118611Snjlvoid 654118611SnjlResetCurrentLineBuffer ( 655118611Snjl void) 656118611Snjl{ 657118611Snjl 658118611Snjl if (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle) 659118611Snjl { 660118611Snjl FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer, 661118611Snjl Gbl_LineBufPtr - Gbl_CurrentLineBuffer); 662118611Snjl } 663118611Snjl 664118611Snjl Gbl_CurrentLineOffset += Gbl_CurrentColumn; 665118611Snjl Gbl_CurrentColumn = 0; 666118611Snjl 667118611Snjl Gbl_CurrentLineNumber++; 668118611Snjl Gbl_LogicalLineNumber++; 669118611Snjl Gbl_LineBufPtr = Gbl_CurrentLineBuffer; 670118611Snjl} 671118611Snjl 672118611Snjl 673118611Snjl/******************************************************************************* 674118611Snjl * 675118611Snjl * FUNCTION: InsertLineBuffer 676118611Snjl * 677118611Snjl * PARAMETERS: SourceChar - One char from the input ASL source file 678118611Snjl * 679118611Snjl * RETURN: None 680118611Snjl * 681118611Snjl * DESCRIPTION: Put one character of the source file into the temp line buffer 682118611Snjl * 683118611Snjl ******************************************************************************/ 684118611Snjl 685118611Snjl#define ASL_SPACES_PER_TAB 4 686118611Snjl 687118611Snjlvoid 688118611SnjlInsertLineBuffer ( 689118611Snjl int SourceChar) 690118611Snjl{ 691118611Snjl UINT32 i; 692118611Snjl UINT32 Count = 1; 693118611Snjl 694118611Snjl 695118611Snjl if (SourceChar == EOF) 696118611Snjl { 697118611Snjl return; 698118611Snjl } 699118611Snjl 700118611Snjl Gbl_InputByteCount++; 701118611Snjl 702118611Snjl /* Handle tabs. Convert to spaces */ 703118611Snjl 704118611Snjl if (SourceChar == '\t') 705118611Snjl { 706118611Snjl SourceChar = ' '; 707118611Snjl Count = ASL_SPACES_PER_TAB - 708118611Snjl (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1)); 709118611Snjl } 710118611Snjl 711118611Snjl 712118611Snjl for (i = 0; i < Count; i++) 713118611Snjl { 714118611Snjl Gbl_CurrentColumn++; 715118611Snjl 716118611Snjl /* Insert the character into the line buffer */ 717118611Snjl 718118611Snjl *Gbl_LineBufPtr = (UINT8) SourceChar; 719118611Snjl Gbl_LineBufPtr++; 720118611Snjl 721118611Snjl if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1))) 722118611Snjl { 723118611Snjl#if 0 724118611Snjl /* 725118611Snjl * Warning if we have split a long source line. 726118611Snjl * <Probably overkill> 727118611Snjl */ 728118611Snjl sprintf (MsgBuffer, "Max %d", ASL_LINE_BUFFER_SIZE); 729118611Snjl AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, 730118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 731118611Snjl Gbl_CurrentLineOffset, Gbl_CurrentColumn, 732118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer); 733118611Snjl#endif 734118611Snjl 735118611Snjl ResetCurrentLineBuffer (); 736118611Snjl } 737118611Snjl else if (SourceChar == '\n') 738118611Snjl { 739118611Snjl /* End of line */ 740118611Snjl 741118611Snjl ResetCurrentLineBuffer (); 742118611Snjl } 743118611Snjl } 744118611Snjl} 745118611Snjl 746118611Snjl 747118611Snjl/******************************************************************************* 748118611Snjl * 749118611Snjl * FUNCTION: count 750118611Snjl * 751118611Snjl * PARAMETERS: yytext - Contains the matched keyword. 752118611Snjl * Type - Keyword/Character type: 753118611Snjl * 0 = anything except a keyword 754118611Snjl * 1 = pseudo-keywords 755118611Snjl * 2 = non-executable ASL keywords 756118611Snjl * 3 = executable ASL keywords 757118611Snjl * 758118611Snjl * RETURN: None 759118611Snjl * 760118611Snjl * DESCRIPTION: Count keywords and put them into the line buffer 761118611Snjl * 762118611Snjl ******************************************************************************/ 763118611Snjl 764118611Snjlvoid 765118611Snjlcount ( 766118611Snjl int Type) 767118611Snjl{ 768118611Snjl int i; 769118611Snjl 770118611Snjl 771118611Snjl switch (Type) 772118611Snjl { 773118611Snjl case 2: 774118611Snjl TotalKeywords++; 775118611Snjl TotalNamedObjects++; 776118611Snjl break; 777118611Snjl 778118611Snjl case 3: 779118611Snjl TotalKeywords++; 780118611Snjl TotalExecutableOpcodes++; 781118611Snjl break; 782118611Snjl } 783118611Snjl 784118611Snjl for (i = 0; (yytext[i] != 0) && (yytext[i] != EOF); i++) 785118611Snjl { 786118611Snjl InsertLineBuffer (yytext[i]); 787118611Snjl *Gbl_LineBufPtr = 0; 788118611Snjl } 789118611Snjl} 790118611Snjl 791118611Snjl 792118611Snjl/******************************************************************************* 793118611Snjl * 794118611Snjl * FUNCTION: comment 795118611Snjl * 796118611Snjl * PARAMETERS: none 797118611Snjl * 798118611Snjl * RETURN: none 799118611Snjl * 800118611Snjl * DESCRIPTION: Process a standard comment. 801118611Snjl * 802118611Snjl ******************************************************************************/ 803118611Snjl 804118611Snjlchar 805118611Snjlcomment (void) 806118611Snjl{ 807118611Snjl char c; 808118611Snjl char c1 = 0; 809118611Snjl 810118611Snjl 811118611Snjl InsertLineBuffer ('/'); 812118611Snjl InsertLineBuffer ('*'); 813118611Snjl 814118611Snjlloop: 815118611Snjl 816118611Snjl /* Eat chars until end-of-comment */ 817118611Snjl 818118611Snjl while ((c = (char) input()) != '*' && c != EOF) 819118611Snjl { 820118611Snjl InsertLineBuffer (c); 821118611Snjl c1 = c; 822118611Snjl } 823118611Snjl 824118611Snjl if (c == EOF) 825118611Snjl { 826118611Snjl goto EarlyEOF; 827118611Snjl } 828118611Snjl 829118611Snjl /* 830118611Snjl * Check for nested comment -- can help catch cases where a previous 831118611Snjl * comment was accidently left unterminated 832118611Snjl */ 833118611Snjl if ((c1 == '/') && (c == '*')) 834118611Snjl { 835118611Snjl AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT, 836118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 837118611Snjl Gbl_InputByteCount, Gbl_CurrentColumn, 838118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 839118611Snjl } 840118611Snjl 841118611Snjl /* Comment is closed only if the NEXT character is a slash */ 842118611Snjl 843118611Snjl InsertLineBuffer (c); 844118611Snjl 845118611Snjl if ((c1 = (char) input()) != '/' && c1 != EOF) 846118611Snjl { 847118611Snjl unput(c1); 848118611Snjl goto loop; 849118611Snjl } 850118611Snjl 851118611Snjl if (c1 == EOF) 852118611Snjl { 853118611Snjl goto EarlyEOF; 854118611Snjl } 855118611Snjl 856118611Snjl InsertLineBuffer (c1); 857118611Snjl return TRUE; 858118611Snjl 859118611Snjl 860118611SnjlEarlyEOF: 861118611Snjl /* 862118611Snjl * Premature End-Of-File 863118611Snjl */ 864118611Snjl AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, 865118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 866118611Snjl Gbl_CurrentLineOffset, Gbl_CurrentColumn, 867118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 868118611Snjl return (FALSE); 869118611Snjl} 870118611Snjl 871118611Snjl 872118611Snjl/******************************************************************************* 873118611Snjl * 874118611Snjl * FUNCTION: comment 875118611Snjl * 876118611Snjl * PARAMETERS: none 877118611Snjl * 878118611Snjl * RETURN: none 879118611Snjl * 880118611Snjl * DESCRIPTION: Process a new "//" comment. 881118611Snjl * 882118611Snjl ******************************************************************************/ 883118611Snjl 884118611Snjlchar 885118611Snjlcomment2 (void) 886118611Snjl{ 887118611Snjl char c; 888118611Snjl 889118611Snjl 890118611Snjl InsertLineBuffer ('/'); 891118611Snjl InsertLineBuffer ('/'); 892118611Snjl 893118611Snjl while ((c = (char) input()) != '\n' && c != EOF) 894118611Snjl { 895118611Snjl InsertLineBuffer (c); 896118611Snjl } 897118611Snjl 898118611Snjl if (c == EOF) 899118611Snjl { 900138287Smarks /* End of file is OK, change to newline. Let parser detect EOF later */ 901138287Smarks 902138287Smarks c = '\n'; 903118611Snjl } 904118611Snjl 905118611Snjl InsertLineBuffer (c); 906118611Snjl return (TRUE); 907118611Snjl} 908118611Snjl 909118611Snjl 910118611Snjl/******************************************************************************* 911118611Snjl * 912118611Snjl * FUNCTION: literal 913118611Snjl * 914118611Snjl * PARAMETERS: none 915118611Snjl * 916118611Snjl * RETURN: none 917118611Snjl * 918118611Snjl * DESCRIPTION: Process a string literal (surrounded by quotes) 919118611Snjl * 920118611Snjl ******************************************************************************/ 921118611Snjl 922118611Snjl#define ASL_NORMAL_CHAR 0 923118611Snjl#define ASL_ESCAPE_SEQUENCE 1 924118611Snjl#define ASL_OCTAL_CONSTANT 2 925118611Snjl#define ASL_HEX_CONSTANT 3 926118611Snjl 927118611Snjlchar 928118611Snjlliteral (void) 929118611Snjl{ 930167802Sjkim char *StringBuffer = MsgBuffer; 931167802Sjkim char *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE; 932118611Snjl char *CleanString; 933118611Snjl char StringChar; 934118611Snjl UINT32 State = ASL_NORMAL_CHAR; 935118611Snjl UINT32 i = 0; 936118611Snjl UINT8 Digit; 937118611Snjl char ConvertBuffer[4]; 938118611Snjl 939118611Snjl 940118611Snjl /* 941118611Snjl * Eat chars until end-of-literal. 942118611Snjl * NOTE: Put back the original surrounding quotes into the 943118611Snjl * source line buffer. 944118611Snjl */ 945118611Snjl InsertLineBuffer ('\"'); 946118611Snjl while ((StringChar = (char) input()) != EOF) 947118611Snjl { 948118611Snjl InsertLineBuffer (StringChar); 949118611Snjl 950118611SnjlDoCharacter: 951118611Snjl 952118611Snjl switch (State) 953118611Snjl { 954118611Snjl case ASL_NORMAL_CHAR: 955118611Snjl 956118611Snjl switch (StringChar) 957118611Snjl { 958118611Snjl case '\\': 959118611Snjl /* 960118611Snjl * Special handling for backslash-escape sequence. We will 961118611Snjl * toss the backslash and translate the escape char(s). 962118611Snjl */ 963118611Snjl State = ASL_ESCAPE_SEQUENCE; 964118611Snjl continue; 965118611Snjl 966118611Snjl case '\"': 967118611Snjl 968118611Snjl /* String terminator */ 969118611Snjl 970118611Snjl goto CompletedString; 971118611Snjl } 972118611Snjl break; 973118611Snjl 974118611Snjl 975118611Snjl case ASL_ESCAPE_SEQUENCE: 976118611Snjl 977118611Snjl State = ASL_NORMAL_CHAR; 978118611Snjl switch (StringChar) 979118611Snjl { 980118611Snjl case 'a': 981118611Snjl StringChar = 0x07; /* BELL */ 982118611Snjl break; 983118611Snjl 984118611Snjl case 'b': 985118611Snjl StringChar = 0x08; /* BACKSPACE */ 986118611Snjl break; 987118611Snjl 988118611Snjl case 'f': 989118611Snjl StringChar = 0x0C; /* FORMFEED */ 990118611Snjl break; 991118611Snjl 992118611Snjl case 'n': 993118611Snjl StringChar = 0x0A; /* LINEFEED */ 994118611Snjl break; 995118611Snjl 996118611Snjl case 'r': 997118611Snjl StringChar = 0x0D; /* CARRIAGE RETURN*/ 998118611Snjl break; 999118611Snjl 1000118611Snjl case 't': 1001118611Snjl StringChar = 0x09; /* HORIZONTAL TAB */ 1002118611Snjl break; 1003118611Snjl 1004118611Snjl case 'v': 1005118611Snjl StringChar = 0x0B; /* VERTICAL TAB */ 1006118611Snjl break; 1007118611Snjl 1008118611Snjl case 'x': 1009118611Snjl State = ASL_HEX_CONSTANT; 1010118611Snjl i = 0; 1011118611Snjl continue; 1012118611Snjl 1013118611Snjl case '\'': /* Single Quote */ 1014118611Snjl case '\"': /* Double Quote */ 1015118611Snjl case '\\': /* Backslash */ 1016118611Snjl break; 1017118611Snjl 1018118611Snjl default: 1019118611Snjl 1020118611Snjl /* Check for an octal digit (0-7) */ 1021118611Snjl 1022118611Snjl if (ACPI_IS_OCTAL_DIGIT (StringChar)) 1023118611Snjl { 1024118611Snjl State = ASL_OCTAL_CONSTANT; 1025118611Snjl ConvertBuffer[0] = StringChar; 1026118611Snjl i = 1; 1027118611Snjl continue; 1028118611Snjl } 1029118611Snjl 1030118611Snjl /* Unknown escape sequence issue warning, but use the character */ 1031118611Snjl 1032118611Snjl AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE, 1033118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1034118611Snjl Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1035118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1036118611Snjl break; 1037118611Snjl } 1038118611Snjl break; 1039118611Snjl 1040118611Snjl 1041118611Snjl case ASL_OCTAL_CONSTANT: 1042118611Snjl 1043118611Snjl /* Up to three octal digits allowed */ 1044118611Snjl 1045118611Snjl if (!ACPI_IS_OCTAL_DIGIT (StringChar) || 1046118611Snjl (i > 2)) 1047118611Snjl { 1048118611Snjl /* 1049118611Snjl * Reached end of the constant. Convert the assembled ASCII 1050118611Snjl * string and resume processing of the next character 1051118611Snjl */ 1052118611Snjl ConvertBuffer[i] = 0; 1053118611Snjl Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8); 1054118611Snjl 1055118611Snjl /* Check for NULL or non-ascii character (ignore if so) */ 1056118611Snjl 1057118611Snjl if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) 1058118611Snjl { 1059118611Snjl AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, 1060118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1061118611Snjl Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1062118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1063118611Snjl } 1064118611Snjl else 1065118611Snjl { 1066167802Sjkim *StringBuffer = (char) Digit; 1067167802Sjkim StringBuffer++; 1068167802Sjkim if (StringBuffer >= EndBuffer) 1069167802Sjkim { 1070167802Sjkim goto BufferOverflow; 1071167802Sjkim } 1072118611Snjl } 1073118611Snjl 1074118611Snjl State = ASL_NORMAL_CHAR; 1075118611Snjl goto DoCharacter; 1076118611Snjl break; 1077118611Snjl } 1078118611Snjl 1079118611Snjl /* Append another digit of the constant */ 1080118611Snjl 1081118611Snjl ConvertBuffer[i] = StringChar; 1082118611Snjl i++; 1083118611Snjl continue; 1084118611Snjl 1085118611Snjl 1086118611Snjl case ASL_HEX_CONSTANT: 1087118611Snjl 1088118611Snjl /* Up to two hex digits allowed */ 1089118611Snjl 1090118611Snjl if (!ACPI_IS_XDIGIT (StringChar) || 1091118611Snjl (i > 1)) 1092118611Snjl { 1093118611Snjl /* 1094118611Snjl * Reached end of the constant. Convert the assembled ASCII 1095118611Snjl * string and resume processing of the next character 1096118611Snjl */ 1097118611Snjl ConvertBuffer[i] = 0; 1098118611Snjl Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16); 1099118611Snjl 1100118611Snjl /* Check for NULL or non-ascii character (ignore if so) */ 1101118611Snjl 1102118611Snjl if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) 1103118611Snjl { 1104118611Snjl AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, 1105118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1106118611Snjl Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1107118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1108118611Snjl } 1109118611Snjl else 1110118611Snjl { 1111167802Sjkim *StringBuffer = (char) Digit; 1112167802Sjkim StringBuffer++; 1113167802Sjkim if (StringBuffer >= EndBuffer) 1114167802Sjkim { 1115167802Sjkim goto BufferOverflow; 1116167802Sjkim } 1117118611Snjl } 1118118611Snjl 1119118611Snjl State = ASL_NORMAL_CHAR; 1120118611Snjl goto DoCharacter; 1121118611Snjl break; 1122118611Snjl } 1123118611Snjl 1124118611Snjl /* Append another digit of the constant */ 1125118611Snjl 1126118611Snjl ConvertBuffer[i] = StringChar; 1127118611Snjl i++; 1128118611Snjl continue; 1129118611Snjl } 1130118611Snjl 1131118611Snjl /* Save the finished character */ 1132118611Snjl 1133167802Sjkim *StringBuffer = StringChar; 1134167802Sjkim StringBuffer++; 1135167802Sjkim if (StringBuffer >= EndBuffer) 1136167802Sjkim { 1137167802Sjkim goto BufferOverflow; 1138167802Sjkim } 1139118611Snjl } 1140118611Snjl 1141118611Snjl /* 1142118611Snjl * Premature End-Of-File 1143118611Snjl */ 1144118611Snjl AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, 1145118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1146118611Snjl Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1147118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1148118611Snjl return (FALSE); 1149118611Snjl 1150118611Snjl 1151118611SnjlCompletedString: 1152118611Snjl /* 1153118611Snjl * Null terminate the input string and copy string to a new buffer 1154118611Snjl */ 1155167802Sjkim *StringBuffer = 0; 1156118611Snjl 1157118611Snjl CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); 1158118611Snjl if (!CleanString) 1159118611Snjl { 1160118611Snjl AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, 1161118611Snjl Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1162118611Snjl Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1163118611Snjl Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1164118611Snjl return (FALSE); 1165118611Snjl } 1166118611Snjl 1167118611Snjl ACPI_STRCPY (CleanString, MsgBuffer); 1168118611Snjl AslCompilerlval.s = CleanString; 1169118611Snjl return (TRUE); 1170167802Sjkim 1171167802Sjkim 1172167802SjkimBufferOverflow: 1173167802Sjkim 1174167802Sjkim /* Literal was too long */ 1175167802Sjkim 1176167802Sjkim AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH, 1177167802Sjkim Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1178167802Sjkim Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1179167802Sjkim Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096"); 1180167802Sjkim return (FALSE); 1181118611Snjl} 1182118611Snjl 1183118611Snjl 1184