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