1a009b7dcSJung-uk Kim %{ 2a009b7dcSJung-uk Kim /****************************************************************************** 3a009b7dcSJung-uk Kim * 4a009b7dcSJung-uk Kim * Module Name: dtcompilerparser.y - Bison input file for table compiler parser 5a009b7dcSJung-uk Kim * 6a009b7dcSJung-uk Kim *****************************************************************************/ 7a009b7dcSJung-uk Kim 8a009b7dcSJung-uk Kim /****************************************************************************** 9a009b7dcSJung-uk Kim * 10a009b7dcSJung-uk Kim * 1. Copyright Notice 11a009b7dcSJung-uk Kim * 12*804fe266SJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp. 13a009b7dcSJung-uk Kim * All rights reserved. 14a009b7dcSJung-uk Kim * 15a009b7dcSJung-uk Kim * 2. License 16a009b7dcSJung-uk Kim * 17a009b7dcSJung-uk Kim * 2.1. This is your license from Intel Corp. under its intellectual property 18a009b7dcSJung-uk Kim * rights. You may have additional license terms from the party that provided 19a009b7dcSJung-uk Kim * you this software, covering your right to use that party's intellectual 20a009b7dcSJung-uk Kim * property rights. 21a009b7dcSJung-uk Kim * 22a009b7dcSJung-uk Kim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23a009b7dcSJung-uk Kim * copy of the source code appearing in this file ("Covered Code") an 24a009b7dcSJung-uk Kim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25a009b7dcSJung-uk Kim * base code distributed originally by Intel ("Original Intel Code") to copy, 26a009b7dcSJung-uk Kim * make derivatives, distribute, use and display any portion of the Covered 27a009b7dcSJung-uk Kim * Code in any form, with the right to sublicense such rights; and 28a009b7dcSJung-uk Kim * 29a009b7dcSJung-uk Kim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30a009b7dcSJung-uk Kim * license (with the right to sublicense), under only those claims of Intel 31a009b7dcSJung-uk Kim * patents that are infringed by the Original Intel Code, to make, use, sell, 32a009b7dcSJung-uk Kim * offer to sell, and import the Covered Code and derivative works thereof 33a009b7dcSJung-uk Kim * solely to the minimum extent necessary to exercise the above copyright 34a009b7dcSJung-uk Kim * license, and in no event shall the patent license extend to any additions 35a009b7dcSJung-uk Kim * to or modifications of the Original Intel Code. No other license or right 36a009b7dcSJung-uk Kim * is granted directly or by implication, estoppel or otherwise; 37a009b7dcSJung-uk Kim * 38a009b7dcSJung-uk Kim * The above copyright and patent license is granted only if the following 39a009b7dcSJung-uk Kim * conditions are met: 40a009b7dcSJung-uk Kim * 41a009b7dcSJung-uk Kim * 3. Conditions 42a009b7dcSJung-uk Kim * 43a009b7dcSJung-uk Kim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44a009b7dcSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 45a009b7dcSJung-uk Kim * Code or modification with rights to further distribute source must include 46a009b7dcSJung-uk Kim * the above Copyright Notice, the above License, this list of Conditions, 47a009b7dcSJung-uk Kim * and the following Disclaimer and Export Compliance provision. In addition, 48a009b7dcSJung-uk Kim * Licensee must cause all Covered Code to which Licensee contributes to 49a009b7dcSJung-uk Kim * contain a file documenting the changes Licensee made to create that Covered 50a009b7dcSJung-uk Kim * Code and the date of any change. Licensee must include in that file the 51a009b7dcSJung-uk Kim * documentation of any changes made by any predecessor Licensee. Licensee 52a009b7dcSJung-uk Kim * must include a prominent statement that the modification is derived, 53a009b7dcSJung-uk Kim * directly or indirectly, from Original Intel Code. 54a009b7dcSJung-uk Kim * 55a009b7dcSJung-uk Kim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56a009b7dcSJung-uk Kim * Redistribution of source code of any substantial portion of the Covered 57a009b7dcSJung-uk Kim * Code or modification without rights to further distribute source must 58a009b7dcSJung-uk Kim * include the following Disclaimer and Export Compliance provision in the 59a009b7dcSJung-uk Kim * documentation and/or other materials provided with distribution. In 60a009b7dcSJung-uk Kim * addition, Licensee may not authorize further sublicense of source of any 61a009b7dcSJung-uk Kim * portion of the Covered Code, and must include terms to the effect that the 62a009b7dcSJung-uk Kim * license from Licensee to its licensee is limited to the intellectual 63a009b7dcSJung-uk Kim * property embodied in the software Licensee provides to its licensee, and 64a009b7dcSJung-uk Kim * not to intellectual property embodied in modifications its licensee may 65a009b7dcSJung-uk Kim * make. 66a009b7dcSJung-uk Kim * 67a009b7dcSJung-uk Kim * 3.3. Redistribution of Executable. Redistribution in executable form of any 68a009b7dcSJung-uk Kim * substantial portion of the Covered Code or modification must reproduce the 69a009b7dcSJung-uk Kim * above Copyright Notice, and the following Disclaimer and Export Compliance 70a009b7dcSJung-uk Kim * provision in the documentation and/or other materials provided with the 71a009b7dcSJung-uk Kim * distribution. 72a009b7dcSJung-uk Kim * 73a009b7dcSJung-uk Kim * 3.4. Intel retains all right, title, and interest in and to the Original 74a009b7dcSJung-uk Kim * Intel Code. 75a009b7dcSJung-uk Kim * 76a009b7dcSJung-uk Kim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77a009b7dcSJung-uk Kim * Intel shall be used in advertising or otherwise to promote the sale, use or 78a009b7dcSJung-uk Kim * other dealings in products derived from or relating to the Covered Code 79a009b7dcSJung-uk Kim * without prior written authorization from Intel. 80a009b7dcSJung-uk Kim * 81a009b7dcSJung-uk Kim * 4. Disclaimer and Export Compliance 82a009b7dcSJung-uk Kim * 83a009b7dcSJung-uk Kim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84a009b7dcSJung-uk Kim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85a009b7dcSJung-uk Kim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86a009b7dcSJung-uk Kim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87a009b7dcSJung-uk Kim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88a009b7dcSJung-uk Kim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89a009b7dcSJung-uk Kim * PARTICULAR PURPOSE. 90a009b7dcSJung-uk Kim * 91a009b7dcSJung-uk Kim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92a009b7dcSJung-uk Kim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93a009b7dcSJung-uk Kim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94a009b7dcSJung-uk Kim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95a009b7dcSJung-uk Kim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96a009b7dcSJung-uk Kim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97a009b7dcSJung-uk Kim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98a009b7dcSJung-uk Kim * LIMITED REMEDY. 99a009b7dcSJung-uk Kim * 100a009b7dcSJung-uk Kim * 4.3. Licensee shall not export, either directly or indirectly, any of this 101a009b7dcSJung-uk Kim * software or system incorporating such software without first obtaining any 102a009b7dcSJung-uk Kim * required license or other approval from the U. S. Department of Commerce or 103a009b7dcSJung-uk Kim * any other agency or department of the United States Government. In the 104a009b7dcSJung-uk Kim * event Licensee exports any such software from the United States or 105a009b7dcSJung-uk Kim * re-exports any such software from a foreign destination, Licensee shall 106a009b7dcSJung-uk Kim * ensure that the distribution and export/re-export of the software is in 107a009b7dcSJung-uk Kim * compliance with all laws, regulations, orders, or other restrictions of the 108a009b7dcSJung-uk Kim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109a009b7dcSJung-uk Kim * any of its subsidiaries will export/re-export any technical data, process, 110a009b7dcSJung-uk Kim * software, or service, directly or indirectly, to any country for which the 111a009b7dcSJung-uk Kim * United States government or any agency thereof requires an export license, 112a009b7dcSJung-uk Kim * other governmental approval, or letter of assurance, without first obtaining 113a009b7dcSJung-uk Kim * such license, approval or letter. 114a009b7dcSJung-uk Kim * 115a009b7dcSJung-uk Kim ***************************************************************************** 116a009b7dcSJung-uk Kim * 117a009b7dcSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 118a009b7dcSJung-uk Kim * following license: 119a009b7dcSJung-uk Kim * 120a009b7dcSJung-uk Kim * Redistribution and use in source and binary forms, with or without 121a009b7dcSJung-uk Kim * modification, are permitted provided that the following conditions 122a009b7dcSJung-uk Kim * are met: 123a009b7dcSJung-uk Kim * 1. Redistributions of source code must retain the above copyright 124a009b7dcSJung-uk Kim * notice, this list of conditions, and the following disclaimer, 125a009b7dcSJung-uk Kim * without modification. 126a009b7dcSJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 127a009b7dcSJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 128a009b7dcSJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 129a009b7dcSJung-uk Kim * including a substantially similar Disclaimer requirement for further 130a009b7dcSJung-uk Kim * binary redistribution. 131a009b7dcSJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 132a009b7dcSJung-uk Kim * of any contributors may be used to endorse or promote products derived 133a009b7dcSJung-uk Kim * from this software without specific prior written permission. 134a009b7dcSJung-uk Kim * 135a009b7dcSJung-uk Kim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 136a009b7dcSJung-uk Kim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 137a009b7dcSJung-uk Kim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 138a009b7dcSJung-uk Kim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 139a009b7dcSJung-uk Kim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 140a009b7dcSJung-uk Kim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 141a009b7dcSJung-uk Kim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 142a009b7dcSJung-uk Kim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 143a009b7dcSJung-uk Kim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 144a009b7dcSJung-uk Kim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 145a009b7dcSJung-uk Kim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 146a009b7dcSJung-uk Kim * 147a009b7dcSJung-uk Kim * Alternatively, you may choose to be licensed under the terms of the 148a009b7dcSJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 149a009b7dcSJung-uk Kim * Software Foundation. 150a009b7dcSJung-uk Kim * 151a009b7dcSJung-uk Kim *****************************************************************************/ 152a009b7dcSJung-uk Kim 153a009b7dcSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 154a009b7dcSJung-uk Kim 155a009b7dcSJung-uk Kim 156a009b7dcSJung-uk Kim #define _COMPONENT DT_COMPILER 157a009b7dcSJung-uk Kim ACPI_MODULE_NAME ("dtcompilerparser") 158a009b7dcSJung-uk Kim 159a009b7dcSJung-uk Kim void * AslLocalAllocate (unsigned int Size); 160a009b7dcSJung-uk Kim 161a009b7dcSJung-uk Kim /* Bison/yacc configuration */ 162a009b7dcSJung-uk Kim 163a009b7dcSJung-uk Kim #undef alloca 164a009b7dcSJung-uk Kim #define alloca AslLocalAllocate 165a009b7dcSJung-uk Kim 166a009b7dcSJung-uk Kim int DtCompilerParserlex (void); 167a009b7dcSJung-uk Kim int DtCompilerParserparse (void); 168a009b7dcSJung-uk Kim void DtCompilerParsererror (char const *msg); 169a009b7dcSJung-uk Kim extern char *DtCompilerParsertext; 170a009b7dcSJung-uk Kim extern DT_FIELD *AslGbl_CurrentField; 171a009b7dcSJung-uk Kim 172a009b7dcSJung-uk Kim extern int DtLabelByteOffset; 173a009b7dcSJung-uk Kim extern UINT64 DtCompilerParserlineno; /* Current line number */ 174a009b7dcSJung-uk Kim 175a009b7dcSJung-uk Kim extern UINT32 DtTokenFirstLine; 176a009b7dcSJung-uk Kim extern UINT32 DtTokenFirstColumn; 177a009b7dcSJung-uk Kim 178a009b7dcSJung-uk Kim /* Bison/yacc configuration */ 179a009b7dcSJung-uk Kim 180a009b7dcSJung-uk Kim #define yytname DtCompilerParsername 181a009b7dcSJung-uk Kim #define YYDEBUG 1 /* Enable debug output */ 182a009b7dcSJung-uk Kim #define YYERROR_VERBOSE 1 /* Verbose error messages */ 183a009b7dcSJung-uk Kim #define YYFLAG -32768 184a009b7dcSJung-uk Kim 185a009b7dcSJung-uk Kim /* Define YYMALLOC/YYFREE to prevent redefinition errors */ 186a009b7dcSJung-uk Kim 187a009b7dcSJung-uk Kim #define YYMALLOC malloc 188a009b7dcSJung-uk Kim #define YYFREE free 189a009b7dcSJung-uk Kim 190a009b7dcSJung-uk Kim %} 191a009b7dcSJung-uk Kim 192a009b7dcSJung-uk Kim 193a009b7dcSJung-uk Kim %union { 194a009b7dcSJung-uk Kim char *s; 195a009b7dcSJung-uk Kim DT_FIELD *f; 196a009b7dcSJung-uk Kim DT_TABLE_UNIT *u; 197a009b7dcSJung-uk Kim } 198a009b7dcSJung-uk Kim 199a009b7dcSJung-uk Kim 200a009b7dcSJung-uk Kim %type <f> Table 201a009b7dcSJung-uk Kim %token <u> DT_PARSEOP_DATA 202a009b7dcSJung-uk Kim %token <u> DT_PARSEOP_LABEL 203a009b7dcSJung-uk Kim %token <u> DT_PARSEOP_STRING_DATA 204a009b7dcSJung-uk Kim %token <u> DT_PARSEOP_LINE_CONTINUATION 205a009b7dcSJung-uk Kim %type <u> Data 206a009b7dcSJung-uk Kim %type <u> Datum 207a009b7dcSJung-uk Kim %type <u> MultiLineData 208a009b7dcSJung-uk Kim %type <u> MultiLineDataList 209a009b7dcSJung-uk Kim 210a009b7dcSJung-uk Kim 211a009b7dcSJung-uk Kim %% 212a009b7dcSJung-uk Kim 213a009b7dcSJung-uk Kim Table 214a009b7dcSJung-uk Kim : 215a009b7dcSJung-uk Kim FieldList { } 216a009b7dcSJung-uk Kim ; 217a009b7dcSJung-uk Kim 218a009b7dcSJung-uk Kim FieldList 219a009b7dcSJung-uk Kim : Field FieldList 220a009b7dcSJung-uk Kim | Field 221a009b7dcSJung-uk Kim ; 222a009b7dcSJung-uk Kim 223a009b7dcSJung-uk Kim Field 224a009b7dcSJung-uk Kim : DT_PARSEOP_LABEL ':' Data { DtCreateField ($1, $3, DtLabelByteOffset); } 225a009b7dcSJung-uk Kim ; 226a009b7dcSJung-uk Kim 227a009b7dcSJung-uk Kim Data 228a009b7dcSJung-uk Kim : MultiLineDataList { $$ = $1; } 229a009b7dcSJung-uk Kim | Datum { $$ = $1; } 230a009b7dcSJung-uk Kim | Datum MultiLineDataList { $$ = $1; } /* combine the string with strcat */ 231a009b7dcSJung-uk Kim ; 232a009b7dcSJung-uk Kim 233a009b7dcSJung-uk Kim MultiLineDataList 234a009b7dcSJung-uk Kim : MultiLineDataList MultiLineData { $$ = DtCreateTableUnit (AcpiUtStrcat(AcpiUtStrcat($1->Value, " "), $2->Value), $1->Line, $1->Column); } /* combine the strings with strcat */ 235a009b7dcSJung-uk Kim | MultiLineData { $$ = $1; } 236a009b7dcSJung-uk Kim ; 237a009b7dcSJung-uk Kim 238a009b7dcSJung-uk Kim MultiLineData 239a009b7dcSJung-uk Kim : DT_PARSEOP_LINE_CONTINUATION Datum { DbgPrint (ASL_PARSE_OUTPUT, "line continuation detected\n"); $$ = $2; } 240a009b7dcSJung-uk Kim ; 241a009b7dcSJung-uk Kim 242a009b7dcSJung-uk Kim Datum 243a009b7dcSJung-uk Kim : DT_PARSEOP_DATA { 244a009b7dcSJung-uk Kim DbgPrint (ASL_PARSE_OUTPUT, "parser data: [%s]\n", DtCompilerParserlval.s); 245a009b7dcSJung-uk Kim $$ = DtCreateTableUnit (AcpiUtStrdup(DtCompilerParserlval.s), DtTokenFirstLine, DtTokenFirstColumn); 246a009b7dcSJung-uk Kim } 247a009b7dcSJung-uk Kim | DT_PARSEOP_STRING_DATA { 248a009b7dcSJung-uk Kim DbgPrint (ASL_PARSE_OUTPUT, "parser string data: [%s]\n", DtCompilerParserlval.s); 249a009b7dcSJung-uk Kim $$ = DtCreateTableUnit (AcpiUtStrdup(DtCompilerParserlval.s), DtTokenFirstLine, DtTokenFirstColumn); 250a009b7dcSJung-uk Kim } 251a009b7dcSJung-uk Kim ; 252a009b7dcSJung-uk Kim 253a009b7dcSJung-uk Kim 254a009b7dcSJung-uk Kim %% 255a009b7dcSJung-uk Kim 256a009b7dcSJung-uk Kim 257a009b7dcSJung-uk Kim /* 258a009b7dcSJung-uk Kim * Local support functions, including parser entry point 259a009b7dcSJung-uk Kim */ 260a009b7dcSJung-uk Kim /****************************************************************************** 261a009b7dcSJung-uk Kim * 262a009b7dcSJung-uk Kim * FUNCTION: DtCompilerParsererror 263a009b7dcSJung-uk Kim * 264a009b7dcSJung-uk Kim * PARAMETERS: Message - Parser-generated error message 265a009b7dcSJung-uk Kim * 266a009b7dcSJung-uk Kim * RETURN: None 267a009b7dcSJung-uk Kim * 268a009b7dcSJung-uk Kim * DESCRIPTION: Handler for parser errors 269a009b7dcSJung-uk Kim * 270a009b7dcSJung-uk Kim *****************************************************************************/ 271a009b7dcSJung-uk Kim 272a009b7dcSJung-uk Kim void 273a009b7dcSJung-uk Kim DtCompilerParsererror ( 274a009b7dcSJung-uk Kim char const *Message) 275a009b7dcSJung-uk Kim { 276a009b7dcSJung-uk Kim DtError (ASL_ERROR, ASL_MSG_SYNTAX, 277a009b7dcSJung-uk Kim AslGbl_CurrentField, (char *) Message); 278a009b7dcSJung-uk Kim } 279a009b7dcSJung-uk Kim 280a009b7dcSJung-uk Kim int 281a009b7dcSJung-uk Kim DtCompilerParserwrap(void) 282a009b7dcSJung-uk Kim { 283a009b7dcSJung-uk Kim return (1); 284a009b7dcSJung-uk Kim } 285