1a009b7dcSJung-uk Kim %{ 2a009b7dcSJung-uk Kim /****************************************************************************** 3a009b7dcSJung-uk Kim * 4a009b7dcSJung-uk Kim * Module Name: dtcompilerparser.l - Flex input file for table compiler lexer 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*58308fadSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2025, 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 #include "dtcompilerparser.y.h" 155a009b7dcSJung-uk Kim 156a009b7dcSJung-uk Kim 157a009b7dcSJung-uk Kim #define _COMPONENT ACPI_COMPILER 158a009b7dcSJung-uk Kim ACPI_MODULE_NAME ("dtcompilerscanner") 159a009b7dcSJung-uk Kim 160a009b7dcSJung-uk Kim /* handle locations */ 161a009b7dcSJung-uk Kim 162a009b7dcSJung-uk Kim int DtCompilerParsercolumn = 1; 163a009b7dcSJung-uk Kim int DtLabelByteOffset = 0; 164a009b7dcSJung-uk Kim int DtCompilerParserByteOffset = 0; 165a009b7dcSJung-uk Kim 166a009b7dcSJung-uk Kim UINT32 DtTokenFirstLine = 0; 167a009b7dcSJung-uk Kim UINT32 DtTokenFirstColumn = 0; 168a009b7dcSJung-uk Kim 169a009b7dcSJung-uk Kim #define YY_USER_ACTION \ 170a009b7dcSJung-uk Kim DtTokenFirstLine = DtCompilerParserlineno; \ 171a009b7dcSJung-uk Kim DtTokenFirstColumn = DtCompilerParsercolumn; \ 172a009b7dcSJung-uk Kim DtCompilerParsercolumn += DtCompilerParserleng; \ 173a009b7dcSJung-uk Kim DtCompilerParserByteOffset += DtCompilerParserleng; \ 174a009b7dcSJung-uk Kim DbgPrint (ASL_PARSE_OUTPUT,\ 175a009b7dcSJung-uk Kim "user action occurred. DtCompilerParserlloc.first_line: %u\n",\ 176a009b7dcSJung-uk Kim DtTokenFirstLine); 177a009b7dcSJung-uk Kim %} 178a009b7dcSJung-uk Kim 179a009b7dcSJung-uk Kim %option nounput noinput yylineno 180a009b7dcSJung-uk Kim 181a009b7dcSJung-uk Kim /* Indicates a state used for parsing multiline C comments */ 182a009b7dcSJung-uk Kim %x ML_COMMENT 183a009b7dcSJung-uk Kim %x DATA_STATE 184a009b7dcSJung-uk Kim 185a009b7dcSJung-uk Kim WhiteSpace [ \t\v\r]+ 186a009b7dcSJung-uk Kim NewLines [\n]+ 187a009b7dcSJung-uk Kim 188a009b7dcSJung-uk Kim /* Avoid ", \n, and [] as a part of label name. These are not valid characters of a label name */ 189a009b7dcSJung-uk Kim LabelName [^ ":\n\[\]]([^":\n\[\]]*[^" :\n\[\]])? 190a009b7dcSJung-uk Kim 191a009b7dcSJung-uk Kim /* Avoid ", \n, \\, and [] as a part of data. These are not valid characters of data */ 192a009b7dcSJung-uk Kim Data [^ \\":\n\[\]]([^":\n\[\]\\]*[^" :\n\[\]\\])? 193a009b7dcSJung-uk Kim 194a009b7dcSJung-uk Kim Text [^ ":\n][^":\n]* 195a009b7dcSJung-uk Kim Comment \[[^\n\[\]]*\] 196a009b7dcSJung-uk Kim CommentField {LabelName}{WhiteSpace}*:{WhiteSpace}{Comment}?$ 197a009b7dcSJung-uk Kim 198a009b7dcSJung-uk Kim 199a009b7dcSJung-uk Kim %% 200a009b7dcSJung-uk Kim 201a009b7dcSJung-uk Kim <DATA_STATE>{WhiteSpace}"\\\n" { 202a009b7dcSJung-uk Kim DbgPrint(ASL_PARSE_OUTPUT,"Continuation matched\n"); 203a009b7dcSJung-uk Kim return (DT_PARSEOP_LINE_CONTINUATION); 204a009b7dcSJung-uk Kim } 205a009b7dcSJung-uk Kim 206a009b7dcSJung-uk Kim ":" { 207a009b7dcSJung-uk Kim DbgPrint(ASL_PARSE_OUTPUT, ": Matched\n"); 208a009b7dcSJung-uk Kim BEGIN (DATA_STATE); 209a009b7dcSJung-uk Kim return (':'); 210a009b7dcSJung-uk Kim } 211a009b7dcSJung-uk Kim 212a009b7dcSJung-uk Kim <INITIAL,DATA_STATE>{WhiteSpace} { DbgPrint(ASL_PARSE_OUTPUT,"Whitespace matched\n"); } 213a009b7dcSJung-uk Kim 214a009b7dcSJung-uk Kim <INITIAL,DATA_STATE>{Comment} { DbgPrint(ASL_PARSE_OUTPUT,"Comment matched\n"); } 215a009b7dcSJung-uk Kim 216a009b7dcSJung-uk Kim "/*" { BEGIN (ML_COMMENT); } 217a009b7dcSJung-uk Kim <ML_COMMENT>"*/" { BEGIN (INITIAL); } 218a009b7dcSJung-uk Kim <ML_COMMENT>"*/\n" { BEGIN (INITIAL); } 219a009b7dcSJung-uk Kim <ML_COMMENT>([^*]|\n)+|. /* Ignore */ 220a009b7dcSJung-uk Kim "//".* /* Ignore */ 221a009b7dcSJung-uk Kim 222a009b7dcSJung-uk Kim 223a009b7dcSJung-uk Kim <DATA_STATE>{Data} { 224a009b7dcSJung-uk Kim char *s; 225a009b7dcSJung-uk Kim int size = strlen (DtCompilerParsertext); 226a009b7dcSJung-uk Kim s=UtLocalCacheCalloc (size + 1); 227a009b7dcSJung-uk Kim AcpiUtSafeStrncpy (s, DtCompilerParsertext, size + 1); 228a009b7dcSJung-uk Kim DtCompilerParserlval.s = s; 229a009b7dcSJung-uk Kim DbgPrint (ASL_PARSE_OUTPUT, "Data: %s\n", s); 230a009b7dcSJung-uk Kim return (DT_PARSEOP_DATA); 231a009b7dcSJung-uk Kim } 232a009b7dcSJung-uk Kim 233a009b7dcSJung-uk Kim {CommentField} /* ignore */ 234a009b7dcSJung-uk Kim 235a009b7dcSJung-uk Kim {LabelName} { 236a009b7dcSJung-uk Kim char *s; 237a009b7dcSJung-uk Kim int size = strlen (DtCompilerParsertext); 238a009b7dcSJung-uk Kim s=UtLocalCacheCalloc (size + 1); 239a009b7dcSJung-uk Kim AcpiUtSafeStrncpy (s, DtCompilerParsertext, size + 1); 240a009b7dcSJung-uk Kim DtCompilerParserlval.u = (DT_TABLE_UNIT *) UtLocalCacheCalloc (sizeof (DT_TABLE_UNIT)); 241a009b7dcSJung-uk Kim DtCompilerParserlval.u->Value = s; 242a009b7dcSJung-uk Kim DtCompilerParserlval.u->Line = DtCompilerParserlineno; 243a009b7dcSJung-uk Kim DtCompilerParserlval.u->Column = DtCompilerParsercolumn; 244a009b7dcSJung-uk Kim DtLabelByteOffset = DtCompilerParserByteOffset; 245a009b7dcSJung-uk Kim DbgPrint (ASL_PARSE_OUTPUT, "Label: %s\n", s); 246a009b7dcSJung-uk Kim return (DT_PARSEOP_LABEL); 247a009b7dcSJung-uk Kim } 248a009b7dcSJung-uk Kim 249a009b7dcSJung-uk Kim 250a009b7dcSJung-uk Kim <DATA_STATE>\"{Text}?\" { // remove outer quotes from the string, they are unnecessary 251a009b7dcSJung-uk Kim char *s; 252a009b7dcSJung-uk Kim int size = strlen (DtCompilerParsertext); 253a009b7dcSJung-uk Kim s=UtLocalCacheCalloc (size - 1); 254a009b7dcSJung-uk Kim AcpiUtSafeStrncpy (s, DtCompilerParsertext + 1, size - 1); 255a009b7dcSJung-uk Kim DtCompilerParserlval.s = s; 256a009b7dcSJung-uk Kim DbgPrint (ASL_PARSE_OUTPUT, "String Data: %s\n", s); 257a009b7dcSJung-uk Kim BEGIN (INITIAL); 258a009b7dcSJung-uk Kim return (DT_PARSEOP_STRING_DATA); 259a009b7dcSJung-uk Kim } 260a009b7dcSJung-uk Kim 261a009b7dcSJung-uk Kim 262a009b7dcSJung-uk Kim <INITIAL,DATA_STATE>{NewLines} { 263a009b7dcSJung-uk Kim DbgPrint(ASL_PARSE_OUTPUT, 264a009b7dcSJung-uk Kim "Newline matched (data state). Current line number: %u\n",DtCompilerParserlineno); 265a009b7dcSJung-uk Kim BEGIN (INITIAL); DtCompilerParsercolumn = 1; 266a009b7dcSJung-uk Kim } 267a009b7dcSJung-uk Kim 268a009b7dcSJung-uk Kim 269a009b7dcSJung-uk Kim %% 270a009b7dcSJung-uk Kim 271a009b7dcSJung-uk Kim 272a009b7dcSJung-uk Kim /* 273a009b7dcSJung-uk Kim * Local support functions 274a009b7dcSJung-uk Kim */ 275a009b7dcSJung-uk Kim 276a009b7dcSJung-uk Kim void 277a009b7dcSJung-uk Kim DtCompilerInitLexer ( 278a009b7dcSJung-uk Kim FILE *inFile) 279a009b7dcSJung-uk Kim { 280a009b7dcSJung-uk Kim yyin = inFile; 281a009b7dcSJung-uk Kim } 282a009b7dcSJung-uk Kim 283a009b7dcSJung-uk Kim void 284a009b7dcSJung-uk Kim DtCompilerTerminateLexer ( 285a009b7dcSJung-uk Kim void) 286a009b7dcSJung-uk Kim { 287a009b7dcSJung-uk Kim /* 288a009b7dcSJung-uk Kim * Flex/Bison increments the lineno for the EOF so decrement by 1 to get 289a009b7dcSJung-uk Kim * the correct number of lines. 290a009b7dcSJung-uk Kim */ 291a009b7dcSJung-uk Kim AslGbl_CurrentLineNumber = DtCompilerParserlineno - 1; 292a009b7dcSJung-uk Kim AslGbl_InputByteCount = DtCompilerParserByteOffset; 293a009b7dcSJung-uk Kim } 294