xref: /dflybsd-src/sys/contrib/dev/acpica/source/compiler/dtparser.l (revision 383048aca08c2de51d27aa8638a36982a0d74550)
10d02842fSSascha Wildner %{
20d02842fSSascha Wildner /******************************************************************************
30d02842fSSascha Wildner  *
40d02842fSSascha Wildner  * Module Name: dtparser.l - Flex input file for table compiler lexer
50d02842fSSascha Wildner  *
60d02842fSSascha Wildner  *****************************************************************************/
70d02842fSSascha Wildner 
8b4315fc7SSascha Wildner /******************************************************************************
9b4315fc7SSascha Wildner  *
10b4315fc7SSascha Wildner  * 1. Copyright Notice
11b4315fc7SSascha Wildner  *
12*383048acSSascha Wildner  * Some or all of this work - Copyright (c) 1999 - 2021, Intel Corp.
130d02842fSSascha Wildner  * All rights reserved.
140d02842fSSascha Wildner  *
15b4315fc7SSascha Wildner  * 2. License
16b4315fc7SSascha Wildner  *
17b4315fc7SSascha Wildner  * 2.1. This is your license from Intel Corp. under its intellectual property
18b4315fc7SSascha Wildner  * rights. You may have additional license terms from the party that provided
19b4315fc7SSascha Wildner  * you this software, covering your right to use that party's intellectual
20b4315fc7SSascha Wildner  * property rights.
21b4315fc7SSascha Wildner  *
22b4315fc7SSascha Wildner  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23b4315fc7SSascha Wildner  * copy of the source code appearing in this file ("Covered Code") an
24b4315fc7SSascha Wildner  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25b4315fc7SSascha Wildner  * base code distributed originally by Intel ("Original Intel Code") to copy,
26b4315fc7SSascha Wildner  * make derivatives, distribute, use and display any portion of the Covered
27b4315fc7SSascha Wildner  * Code in any form, with the right to sublicense such rights; and
28b4315fc7SSascha Wildner  *
29b4315fc7SSascha Wildner  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30b4315fc7SSascha Wildner  * license (with the right to sublicense), under only those claims of Intel
31b4315fc7SSascha Wildner  * patents that are infringed by the Original Intel Code, to make, use, sell,
32b4315fc7SSascha Wildner  * offer to sell, and import the Covered Code and derivative works thereof
33b4315fc7SSascha Wildner  * solely to the minimum extent necessary to exercise the above copyright
34b4315fc7SSascha Wildner  * license, and in no event shall the patent license extend to any additions
35b4315fc7SSascha Wildner  * to or modifications of the Original Intel Code. No other license or right
36b4315fc7SSascha Wildner  * is granted directly or by implication, estoppel or otherwise;
37b4315fc7SSascha Wildner  *
38b4315fc7SSascha Wildner  * The above copyright and patent license is granted only if the following
39b4315fc7SSascha Wildner  * conditions are met:
40b4315fc7SSascha Wildner  *
41b4315fc7SSascha Wildner  * 3. Conditions
42b4315fc7SSascha Wildner  *
43b4315fc7SSascha Wildner  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44b4315fc7SSascha Wildner  * Redistribution of source code of any substantial portion of the Covered
45b4315fc7SSascha Wildner  * Code or modification with rights to further distribute source must include
46b4315fc7SSascha Wildner  * the above Copyright Notice, the above License, this list of Conditions,
47b4315fc7SSascha Wildner  * and the following Disclaimer and Export Compliance provision. In addition,
48b4315fc7SSascha Wildner  * Licensee must cause all Covered Code to which Licensee contributes to
49b4315fc7SSascha Wildner  * contain a file documenting the changes Licensee made to create that Covered
50b4315fc7SSascha Wildner  * Code and the date of any change. Licensee must include in that file the
51b4315fc7SSascha Wildner  * documentation of any changes made by any predecessor Licensee. Licensee
52b4315fc7SSascha Wildner  * must include a prominent statement that the modification is derived,
53b4315fc7SSascha Wildner  * directly or indirectly, from Original Intel Code.
54b4315fc7SSascha Wildner  *
55b4315fc7SSascha Wildner  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56b4315fc7SSascha Wildner  * Redistribution of source code of any substantial portion of the Covered
57b4315fc7SSascha Wildner  * Code or modification without rights to further distribute source must
58b4315fc7SSascha Wildner  * include the following Disclaimer and Export Compliance provision in the
59b4315fc7SSascha Wildner  * documentation and/or other materials provided with distribution. In
60b4315fc7SSascha Wildner  * addition, Licensee may not authorize further sublicense of source of any
61b4315fc7SSascha Wildner  * portion of the Covered Code, and must include terms to the effect that the
62b4315fc7SSascha Wildner  * license from Licensee to its licensee is limited to the intellectual
63b4315fc7SSascha Wildner  * property embodied in the software Licensee provides to its licensee, and
64b4315fc7SSascha Wildner  * not to intellectual property embodied in modifications its licensee may
65b4315fc7SSascha Wildner  * make.
66b4315fc7SSascha Wildner  *
67b4315fc7SSascha Wildner  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68b4315fc7SSascha Wildner  * substantial portion of the Covered Code or modification must reproduce the
69b4315fc7SSascha Wildner  * above Copyright Notice, and the following Disclaimer and Export Compliance
70b4315fc7SSascha Wildner  * provision in the documentation and/or other materials provided with the
71b4315fc7SSascha Wildner  * distribution.
72b4315fc7SSascha Wildner  *
73b4315fc7SSascha Wildner  * 3.4. Intel retains all right, title, and interest in and to the Original
74b4315fc7SSascha Wildner  * Intel Code.
75b4315fc7SSascha Wildner  *
76b4315fc7SSascha Wildner  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77b4315fc7SSascha Wildner  * Intel shall be used in advertising or otherwise to promote the sale, use or
78b4315fc7SSascha Wildner  * other dealings in products derived from or relating to the Covered Code
79b4315fc7SSascha Wildner  * without prior written authorization from Intel.
80b4315fc7SSascha Wildner  *
81b4315fc7SSascha Wildner  * 4. Disclaimer and Export Compliance
82b4315fc7SSascha Wildner  *
83b4315fc7SSascha Wildner  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84b4315fc7SSascha Wildner  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85b4315fc7SSascha Wildner  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86b4315fc7SSascha Wildner  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87b4315fc7SSascha Wildner  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88b4315fc7SSascha Wildner  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89b4315fc7SSascha Wildner  * PARTICULAR PURPOSE.
90b4315fc7SSascha Wildner  *
91b4315fc7SSascha Wildner  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92b4315fc7SSascha Wildner  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93b4315fc7SSascha Wildner  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94b4315fc7SSascha Wildner  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95b4315fc7SSascha Wildner  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96b4315fc7SSascha Wildner  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97b4315fc7SSascha Wildner  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98b4315fc7SSascha Wildner  * LIMITED REMEDY.
99b4315fc7SSascha Wildner  *
100b4315fc7SSascha Wildner  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101b4315fc7SSascha Wildner  * software or system incorporating such software without first obtaining any
102b4315fc7SSascha Wildner  * required license or other approval from the U. S. Department of Commerce or
103b4315fc7SSascha Wildner  * any other agency or department of the United States Government. In the
104b4315fc7SSascha Wildner  * event Licensee exports any such software from the United States or
105b4315fc7SSascha Wildner  * re-exports any such software from a foreign destination, Licensee shall
106b4315fc7SSascha Wildner  * ensure that the distribution and export/re-export of the software is in
107b4315fc7SSascha Wildner  * compliance with all laws, regulations, orders, or other restrictions of the
108b4315fc7SSascha Wildner  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109b4315fc7SSascha Wildner  * any of its subsidiaries will export/re-export any technical data, process,
110b4315fc7SSascha Wildner  * software, or service, directly or indirectly, to any country for which the
111b4315fc7SSascha Wildner  * United States government or any agency thereof requires an export license,
112b4315fc7SSascha Wildner  * other governmental approval, or letter of assurance, without first obtaining
113b4315fc7SSascha Wildner  * such license, approval or letter.
114b4315fc7SSascha Wildner  *
115b4315fc7SSascha Wildner  *****************************************************************************
116b4315fc7SSascha Wildner  *
117b4315fc7SSascha Wildner  * Alternatively, you may choose to be licensed under the terms of the
118b4315fc7SSascha Wildner  * following license:
119b4315fc7SSascha Wildner  *
1200d02842fSSascha Wildner  * Redistribution and use in source and binary forms, with or without
1210d02842fSSascha Wildner  * modification, are permitted provided that the following conditions
1220d02842fSSascha Wildner  * are met:
1230d02842fSSascha Wildner  * 1. Redistributions of source code must retain the above copyright
1240d02842fSSascha Wildner  *    notice, this list of conditions, and the following disclaimer,
1250d02842fSSascha Wildner  *    without modification.
1260d02842fSSascha Wildner  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1270d02842fSSascha Wildner  *    substantially similar to the "NO WARRANTY" disclaimer below
1280d02842fSSascha Wildner  *    ("Disclaimer") and any redistribution must be conditioned upon
1290d02842fSSascha Wildner  *    including a substantially similar Disclaimer requirement for further
1300d02842fSSascha Wildner  *    binary redistribution.
1310d02842fSSascha Wildner  * 3. Neither the names of the above-listed copyright holders nor the names
1320d02842fSSascha Wildner  *    of any contributors may be used to endorse or promote products derived
1330d02842fSSascha Wildner  *    from this software without specific prior written permission.
1340d02842fSSascha Wildner  *
135b4315fc7SSascha Wildner  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136b4315fc7SSascha Wildner  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137b4315fc7SSascha Wildner  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138b4315fc7SSascha Wildner  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139b4315fc7SSascha Wildner  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140b4315fc7SSascha Wildner  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141b4315fc7SSascha Wildner  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142b4315fc7SSascha Wildner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143b4315fc7SSascha Wildner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144b4315fc7SSascha Wildner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145b4315fc7SSascha Wildner  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146b4315fc7SSascha Wildner  *
147b4315fc7SSascha Wildner  * Alternatively, you may choose to be licensed under the terms of the
1480d02842fSSascha Wildner  * GNU General Public License ("GPL") version 2 as published by the Free
1490d02842fSSascha Wildner  * Software Foundation.
1500d02842fSSascha Wildner  *
151b4315fc7SSascha Wildner  *****************************************************************************/
1520d02842fSSascha Wildner 
1530d02842fSSascha Wildner #include "aslcompiler.h"
1540d02842fSSascha Wildner #include "dtparser.y.h"
1550d02842fSSascha Wildner 
1560d02842fSSascha Wildner #define YY_NO_INPUT     /* No file input, we use strings only */
1570d02842fSSascha Wildner 
1580d02842fSSascha Wildner #define _COMPONENT          ACPI_COMPILER
1590d02842fSSascha Wildner         ACPI_MODULE_NAME    ("dtscanner")
1600d02842fSSascha Wildner %}
1610d02842fSSascha Wildner 
1620d02842fSSascha Wildner %option noyywrap
1630d02842fSSascha Wildner %option nounput
1640d02842fSSascha Wildner 
1650d02842fSSascha Wildner Number          [0-9a-fA-F]+
1660d02842fSSascha Wildner HexNumber       0[xX][0-9a-fA-F]+
1670d02842fSSascha Wildner DecimalNumber   0[dD][0-9]+
1680d02842fSSascha Wildner LabelRef        $[a-zA-Z][0-9a-zA-Z]*
1690d02842fSSascha Wildner WhiteSpace      [ \t\v\r]+
1700d02842fSSascha Wildner NewLine         [\n]
1710d02842fSSascha Wildner 
1720d02842fSSascha Wildner %%
1730d02842fSSascha Wildner 
1747bcb6cafSSascha Wildner \(              return (OP_EXP_PAREN_OPEN);
1757bcb6cafSSascha Wildner \)              return (OP_EXP_PAREN_CLOSE);
1767bcb6cafSSascha Wildner \~              return (OP_EXP_ONES_COMPLIMENT);
1777bcb6cafSSascha Wildner \!              return (OP_EXP_LOGICAL_NOT);
1787bcb6cafSSascha Wildner \*              return (OP_EXP_MULTIPLY);
1797bcb6cafSSascha Wildner \/              return (OP_EXP_DIVIDE);
1807bcb6cafSSascha Wildner \%              return (OP_EXP_MODULO);
1817bcb6cafSSascha Wildner \+              return (OP_EXP_ADD);
1827bcb6cafSSascha Wildner \-              return (OP_EXP_SUBTRACT);
1837bcb6cafSSascha Wildner ">>"            return (OP_EXP_SHIFT_RIGHT);
1847bcb6cafSSascha Wildner "<<"            return (OP_EXP_SHIFT_LEFT);
1857bcb6cafSSascha Wildner \<              return (OP_EXP_LESS);
1867bcb6cafSSascha Wildner \>              return (OP_EXP_GREATER);
1877bcb6cafSSascha Wildner "<="            return (OP_EXP_LESS_EQUAL);
1887bcb6cafSSascha Wildner ">="            return (OP_EXP_GREATER_EQUAL);
1897bcb6cafSSascha Wildner "=="            return (OP_EXP_EQUAL);
1907bcb6cafSSascha Wildner "!="            return (OP_EXP_NOT_EQUAL);
1917bcb6cafSSascha Wildner \&              return (OP_EXP_AND);
1927bcb6cafSSascha Wildner \^              return (OP_EXP_XOR);
1937bcb6cafSSascha Wildner \|              return (OP_EXP_OR);
1947bcb6cafSSascha Wildner "&&"            return (OP_EXP_LOGICAL_AND);
1957bcb6cafSSascha Wildner "||"            return (OP_EXP_LOGICAL_OR);
1967bcb6cafSSascha Wildner <<EOF>>         return (OP_EXP_EOF); /* null end-of-string */
1970d02842fSSascha Wildner 
1987bcb6cafSSascha Wildner {LabelRef}      return (OP_EXP_LABEL);
1997bcb6cafSSascha Wildner {Number}        return (OP_EXP_NUMBER);
2007bcb6cafSSascha Wildner {HexNumber}     return (OP_EXP_HEX_NUMBER);
2017bcb6cafSSascha Wildner {NewLine}       return (OP_EXP_NEW_LINE);
2020d02842fSSascha Wildner {WhiteSpace}    /* Ignore */
2030d02842fSSascha Wildner 
2047bcb6cafSSascha Wildner .               return (OP_EXP_EOF);
2050d02842fSSascha Wildner 
2060d02842fSSascha Wildner %%
2070d02842fSSascha Wildner 
2080d02842fSSascha Wildner /*
2090d02842fSSascha Wildner  * Local support functions
2100d02842fSSascha Wildner  */
21171c97a3cSSascha Wildner static YY_BUFFER_STATE         LexBuffer;
2120d02842fSSascha Wildner 
2130d02842fSSascha Wildner /******************************************************************************
2140d02842fSSascha Wildner  *
2150d02842fSSascha Wildner  * FUNCTION:    DtInitLexer, DtTerminateLexer
2160d02842fSSascha Wildner  *
2170d02842fSSascha Wildner  * PARAMETERS:  String              - Input string to be parsed
2180d02842fSSascha Wildner  *
2190d02842fSSascha Wildner  * RETURN:      None
2200d02842fSSascha Wildner  *
2210d02842fSSascha Wildner  * DESCRIPTION: Initialization and termination routines for lexer. Lexer needs
2220d02842fSSascha Wildner  *              a buffer to handle strings instead of a file.
2230d02842fSSascha Wildner  *
2240d02842fSSascha Wildner  *****************************************************************************/
2250d02842fSSascha Wildner 
2260d02842fSSascha Wildner int
DtInitLexer(char * String)2270d02842fSSascha Wildner DtInitLexer (
2280d02842fSSascha Wildner     char                    *String)
2290d02842fSSascha Wildner {
2300d02842fSSascha Wildner     LexBuffer = yy_scan_string (String);
2310d02842fSSascha Wildner     return (LexBuffer == NULL);
2320d02842fSSascha Wildner }
2330d02842fSSascha Wildner 
2340d02842fSSascha Wildner void
DtTerminateLexer(void)2350d02842fSSascha Wildner DtTerminateLexer (
2360d02842fSSascha Wildner     void)
2370d02842fSSascha Wildner {
2380d02842fSSascha Wildner     yy_delete_buffer (LexBuffer);
2390d02842fSSascha Wildner }
240