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