aslcompiler.l revision 217365
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 <contrib/dev/acpica/compiler/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 396"{" { count (0); return('{'); } 397"}" { count (0); return('}'); } 398"," { count (0); return(','); } 399"(" { count (0); return('('); } 400")" { count (0); return(')'); } 401 402 403{NameSeg} { char *s; 404 count (0); 405 s=malloc (ACPI_NAME_SIZE + 1); 406 if (strcmp (AslCompilertext, "\\")) 407 { 408 strcpy (s, "____"); 409 AcpiUtStrupr (AslCompilertext); 410 } 411 memcpy (s, AslCompilertext, strlen (AslCompilertext)); 412 AslCompilerlval.s = s; 413 DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s); 414 return (PARSEOP_NAMESEG); } 415 416{NameString} { char *s; 417 count (0); 418 s=malloc (strlen (AslCompilertext)+1); 419 AcpiUtStrupr (AslCompilertext); 420 strcpy (s, AslCompilertext); 421 s[strlen (AslCompilertext)] = 0; 422 AslCompilerlval.s = s; 423 DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s); 424 return (PARSEOP_NAMESTRING); } 425 426"*" | 427"/" { count (1); 428 AslCompilererror ("Parse error, expecting ASL keyword or name");} 429 430. { count (1); 431 sprintf (MsgBuffer, 432 "Invalid character (0x%2.2X), expecting ASL keyword or name", 433 *AslCompilertext); 434 AslCompilererror (MsgBuffer);} 435 436<<EOF>> { if (AslPopInputFileStack ()) 437 yyterminate(); 438 else 439 return (PARSEOP_INCLUDE_END);}; 440 441%% 442 443/*! [End] no source code translation !*/ 444 445typedef struct asl_file_node 446{ 447 FILE *File; 448 UINT32 CurrentLineNumber; 449 YY_BUFFER_STATE State; 450 char *Filename; 451 struct asl_file_node *Next; 452 453} ASL_FILE_NODE; 454 455ASL_FILE_NODE *InputStack = NULL; 456 457 458/******************************************************************************* 459 * 460 * FUNCTION: AslPopInputFileStack 461 * 462 * PARAMETERS: None 463 * 464 * RETURN: 0 if a node was popped, -1 otherwise 465 * 466 * DESCRIPTION: Pop the top of the input file stack and point the parser to 467 * the saved parse buffer contained in the fnode. Also, set the 468 * global line counters to the saved values. This function is 469 * called when an include file reaches EOF. 470 * 471 ******************************************************************************/ 472 473int 474AslPopInputFileStack ( 475 void) 476{ 477 ASL_FILE_NODE *Fnode; 478 FILE *InputFile = NULL; 479 480 481 Fnode = InputStack; 482 DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode); 483 484 485 if (!Fnode) 486 { 487 return -1; 488 } 489 490 /* Close the current include file */ 491 492 fclose (yyin); 493 494 /* Update the top-of-stack */ 495 496 InputStack = Fnode->Next; 497 InputFile = Fnode->File; 498 499 /* Reset global line counter and filename */ 500 501 Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; 502 Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; 503 504 /* Point the parser to the popped file */ 505 506 yy_delete_buffer (YY_CURRENT_BUFFER); 507 yy_switch_to_buffer (Fnode->State); 508 509 /* All done with this node */ 510 511 ACPI_FREE (Fnode); 512 return 0; 513} 514 515 516/******************************************************************************* 517 * 518 * FUNCTION: AslPushInputFileStack 519 * 520 * PARAMETERS: InputFile - Open file pointer 521 * Filename - Name of the file 522 * 523 * RETURN: None 524 * 525 * DESCRIPTION: Push the InputFile onto the file stack, and point the parser 526 * to this file. Called when an include file is successfully 527 * opened. 528 * 529 ******************************************************************************/ 530 531void 532AslPushInputFileStack ( 533 FILE *InputFile, 534 char *Filename) 535{ 536 ASL_FILE_NODE *Fnode; 537 YY_BUFFER_STATE State; 538 539 540 /* Save the current state in an Fnode */ 541 542 Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE)); 543 544 Fnode->File = yyin; 545 Fnode->Next = InputStack; 546 Fnode->State = YY_CURRENT_BUFFER; 547 Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; 548 Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; 549 550 /* Push it on the stack */ 551 552 InputStack = Fnode; 553 554 /* Point the parser to this file */ 555 556 State = yy_create_buffer (InputFile, YY_BUF_SIZE); 557 yy_switch_to_buffer (State); 558 559 DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile); 560 561 /* Reset the global line count and filename */ 562 563 Gbl_Files[ASL_FILE_INPUT].Filename = Filename; 564 Gbl_CurrentLineNumber = 1; 565 yyin = InputFile; 566} 567 568 569/******************************************************************************* 570 * 571 * FUNCTION: ResetCurrentLineBuffer 572 * 573 * PARAMETERS: None 574 * 575 * RETURN: None 576 * 577 * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers. 578 * 579 ******************************************************************************/ 580 581void 582ResetCurrentLineBuffer ( 583 void) 584{ 585 586 if (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle) 587 { 588 FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer, 589 Gbl_LineBufPtr - Gbl_CurrentLineBuffer); 590 } 591 592 Gbl_CurrentLineOffset += Gbl_CurrentColumn; 593 Gbl_CurrentColumn = 0; 594 595 Gbl_CurrentLineNumber++; 596 Gbl_LogicalLineNumber++; 597 Gbl_LineBufPtr = Gbl_CurrentLineBuffer; 598} 599 600 601/******************************************************************************* 602 * 603 * FUNCTION: InsertLineBuffer 604 * 605 * PARAMETERS: SourceChar - One char from the input ASL source file 606 * 607 * RETURN: None 608 * 609 * DESCRIPTION: Put one character of the source file into the temp line buffer 610 * 611 ******************************************************************************/ 612 613#define ASL_SPACES_PER_TAB 4 614 615void 616InsertLineBuffer ( 617 int SourceChar) 618{ 619 UINT32 i; 620 UINT32 Count = 1; 621 622 623 if (SourceChar == EOF) 624 { 625 return; 626 } 627 628 Gbl_InputByteCount++; 629 630 /* Handle tabs. Convert to spaces */ 631 632 if (SourceChar == '\t') 633 { 634 SourceChar = ' '; 635 Count = ASL_SPACES_PER_TAB - 636 (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1)); 637 } 638 639 640 for (i = 0; i < Count; i++) 641 { 642 Gbl_CurrentColumn++; 643 644 /* Insert the character into the line buffer */ 645 646 *Gbl_LineBufPtr = (UINT8) SourceChar; 647 Gbl_LineBufPtr++; 648 649 if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1))) 650 { 651#if 0 652 /* 653 * Warning if we have split a long source line. 654 * <Probably overkill> 655 */ 656 sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE); 657 AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, 658 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 659 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 660 Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer); 661#endif 662 663 ResetCurrentLineBuffer (); 664 } 665 else if (SourceChar == '\n') 666 { 667 /* End of line */ 668 669 ResetCurrentLineBuffer (); 670 } 671 } 672} 673 674 675/******************************************************************************* 676 * 677 * FUNCTION: count 678 * 679 * PARAMETERS: yytext - Contains the matched keyword. 680 * Type - Keyword/Character type: 681 * 0 = anything except a keyword 682 * 1 = pseudo-keywords 683 * 2 = non-executable ASL keywords 684 * 3 = executable ASL keywords 685 * 686 * RETURN: None 687 * 688 * DESCRIPTION: Count keywords and put them into the line buffer 689 * 690 ******************************************************************************/ 691 692void 693count ( 694 int Type) 695{ 696 int i; 697 698 699 switch (Type) 700 { 701 case 2: 702 TotalKeywords++; 703 TotalNamedObjects++; 704 break; 705 706 case 3: 707 TotalKeywords++; 708 TotalExecutableOpcodes++; 709 break; 710 } 711 712 for (i = 0; (yytext[i] != 0) && (yytext[i] != EOF); i++) 713 { 714 InsertLineBuffer (yytext[i]); 715 *Gbl_LineBufPtr = 0; 716 } 717} 718 719 720/******************************************************************************* 721 * 722 * FUNCTION: comment 723 * 724 * PARAMETERS: none 725 * 726 * RETURN: none 727 * 728 * DESCRIPTION: Process a standard comment. 729 * 730 ******************************************************************************/ 731 732char 733comment (void) 734{ 735 char c; 736 char c1 = 0; 737 738 739 InsertLineBuffer ('/'); 740 InsertLineBuffer ('*'); 741 742loop: 743 744 /* Eat chars until end-of-comment */ 745 746 while ((c = (char) input()) != '*' && c != EOF) 747 { 748 InsertLineBuffer (c); 749 c1 = c; 750 } 751 752 if (c == EOF) 753 { 754 goto EarlyEOF; 755 } 756 757 /* 758 * Check for nested comment -- can help catch cases where a previous 759 * comment was accidently left unterminated 760 */ 761 if ((c1 == '/') && (c == '*')) 762 { 763 AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT, 764 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 765 Gbl_InputByteCount, Gbl_CurrentColumn, 766 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 767 } 768 769 /* Comment is closed only if the NEXT character is a slash */ 770 771 InsertLineBuffer (c); 772 773 if ((c1 = (char) input()) != '/' && c1 != EOF) 774 { 775 unput(c1); 776 goto loop; 777 } 778 779 if (c1 == EOF) 780 { 781 goto EarlyEOF; 782 } 783 784 InsertLineBuffer (c1); 785 return TRUE; 786 787 788EarlyEOF: 789 /* 790 * Premature End-Of-File 791 */ 792 AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, 793 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 794 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 795 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 796 return (FALSE); 797} 798 799 800/******************************************************************************* 801 * 802 * FUNCTION: comment 803 * 804 * PARAMETERS: none 805 * 806 * RETURN: none 807 * 808 * DESCRIPTION: Process a new "//" comment. 809 * 810 ******************************************************************************/ 811 812char 813comment2 (void) 814{ 815 char c; 816 817 818 InsertLineBuffer ('/'); 819 InsertLineBuffer ('/'); 820 821 while ((c = (char) input()) != '\n' && c != EOF) 822 { 823 InsertLineBuffer (c); 824 } 825 826 if (c == EOF) 827 { 828 /* End of file is OK, change to newline. Let parser detect EOF later */ 829 830 c = '\n'; 831 } 832 833 InsertLineBuffer (c); 834 return (TRUE); 835} 836 837 838/******************************************************************************* 839 * 840 * FUNCTION: literal 841 * 842 * PARAMETERS: none 843 * 844 * RETURN: none 845 * 846 * DESCRIPTION: Process a string literal (surrounded by quotes) 847 * 848 ******************************************************************************/ 849 850#define ASL_NORMAL_CHAR 0 851#define ASL_ESCAPE_SEQUENCE 1 852#define ASL_OCTAL_CONSTANT 2 853#define ASL_HEX_CONSTANT 3 854 855char 856literal (void) 857{ 858 char *StringBuffer = MsgBuffer; 859 char *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE; 860 char *CleanString; 861 char StringChar; 862 UINT32 State = ASL_NORMAL_CHAR; 863 UINT32 i = 0; 864 UINT8 Digit; 865 char ConvertBuffer[4]; 866 867 868 /* 869 * Eat chars until end-of-literal. 870 * NOTE: Put back the original surrounding quotes into the 871 * source line buffer. 872 */ 873 InsertLineBuffer ('\"'); 874 while ((StringChar = (char) input()) != EOF) 875 { 876 InsertLineBuffer (StringChar); 877 878DoCharacter: 879 880 switch (State) 881 { 882 case ASL_NORMAL_CHAR: 883 884 switch (StringChar) 885 { 886 case '\\': 887 /* 888 * Special handling for backslash-escape sequence. We will 889 * toss the backslash and translate the escape char(s). 890 */ 891 State = ASL_ESCAPE_SEQUENCE; 892 continue; 893 894 case '\"': 895 896 /* String terminator */ 897 898 goto CompletedString; 899 } 900 break; 901 902 903 case ASL_ESCAPE_SEQUENCE: 904 905 State = ASL_NORMAL_CHAR; 906 switch (StringChar) 907 { 908 case 'a': 909 StringChar = 0x07; /* BELL */ 910 break; 911 912 case 'b': 913 StringChar = 0x08; /* BACKSPACE */ 914 break; 915 916 case 'f': 917 StringChar = 0x0C; /* FORMFEED */ 918 break; 919 920 case 'n': 921 StringChar = 0x0A; /* LINEFEED */ 922 break; 923 924 case 'r': 925 StringChar = 0x0D; /* CARRIAGE RETURN*/ 926 break; 927 928 case 't': 929 StringChar = 0x09; /* HORIZONTAL TAB */ 930 break; 931 932 case 'v': 933 StringChar = 0x0B; /* VERTICAL TAB */ 934 break; 935 936 case 'x': 937 State = ASL_HEX_CONSTANT; 938 i = 0; 939 continue; 940 941 case '\'': /* Single Quote */ 942 case '\"': /* Double Quote */ 943 case '\\': /* Backslash */ 944 break; 945 946 default: 947 948 /* Check for an octal digit (0-7) */ 949 950 if (ACPI_IS_OCTAL_DIGIT (StringChar)) 951 { 952 State = ASL_OCTAL_CONSTANT; 953 ConvertBuffer[0] = StringChar; 954 i = 1; 955 continue; 956 } 957 958 /* Unknown escape sequence issue warning, but use the character */ 959 960 AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE, 961 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 962 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 963 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 964 break; 965 } 966 break; 967 968 969 case ASL_OCTAL_CONSTANT: 970 971 /* Up to three octal digits allowed */ 972 973 if (!ACPI_IS_OCTAL_DIGIT (StringChar) || 974 (i > 2)) 975 { 976 /* 977 * Reached end of the constant. Convert the assembled ASCII 978 * string and resume processing of the next character 979 */ 980 ConvertBuffer[i] = 0; 981 Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8); 982 983 /* Check for NULL or non-ascii character (ignore if so) */ 984 985 if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) 986 { 987 AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, 988 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 989 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 990 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 991 } 992 else 993 { 994 *StringBuffer = (char) Digit; 995 StringBuffer++; 996 if (StringBuffer >= EndBuffer) 997 { 998 goto BufferOverflow; 999 } 1000 } 1001 1002 State = ASL_NORMAL_CHAR; 1003 goto DoCharacter; 1004 break; 1005 } 1006 1007 /* Append another digit of the constant */ 1008 1009 ConvertBuffer[i] = StringChar; 1010 i++; 1011 continue; 1012 1013 1014 case ASL_HEX_CONSTANT: 1015 1016 /* Up to two hex digits allowed */ 1017 1018 if (!ACPI_IS_XDIGIT (StringChar) || 1019 (i > 1)) 1020 { 1021 /* 1022 * Reached end of the constant. Convert the assembled ASCII 1023 * string and resume processing of the next character 1024 */ 1025 ConvertBuffer[i] = 0; 1026 Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16); 1027 1028 /* Check for NULL or non-ascii character (ignore if so) */ 1029 1030 if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) 1031 { 1032 AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, 1033 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1034 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1035 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1036 } 1037 else 1038 { 1039 *StringBuffer = (char) Digit; 1040 StringBuffer++; 1041 if (StringBuffer >= EndBuffer) 1042 { 1043 goto BufferOverflow; 1044 } 1045 } 1046 1047 State = ASL_NORMAL_CHAR; 1048 goto DoCharacter; 1049 break; 1050 } 1051 1052 /* Append another digit of the constant */ 1053 1054 ConvertBuffer[i] = StringChar; 1055 i++; 1056 continue; 1057 } 1058 1059 /* Save the finished character */ 1060 1061 *StringBuffer = StringChar; 1062 StringBuffer++; 1063 if (StringBuffer >= EndBuffer) 1064 { 1065 goto BufferOverflow; 1066 } 1067 } 1068 1069 /* 1070 * Premature End-Of-File 1071 */ 1072 AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, 1073 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1074 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1075 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1076 return (FALSE); 1077 1078 1079CompletedString: 1080 /* 1081 * Null terminate the input string and copy string to a new buffer 1082 */ 1083 *StringBuffer = 0; 1084 1085 CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); 1086 if (!CleanString) 1087 { 1088 AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, 1089 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1090 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1091 Gbl_Files[ASL_FILE_INPUT].Filename, NULL); 1092 return (FALSE); 1093 } 1094 1095 ACPI_STRCPY (CleanString, MsgBuffer); 1096 AslCompilerlval.s = CleanString; 1097 return (TRUE); 1098 1099 1100BufferOverflow: 1101 1102 /* Literal was too long */ 1103 1104 AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH, 1105 Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, 1106 Gbl_CurrentLineOffset, Gbl_CurrentColumn, 1107 Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096"); 1108 return (FALSE); 1109} 1110 1111 1112