prparser.l revision 1.1.1.1.10.3 1 1.1.1.1.10.2 tls %{
2 1.1.1.1.10.2 tls /******************************************************************************
3 1.1.1.1.10.2 tls *
4 1.1.1.1.10.2 tls * Module Name: prparser.l - Flex input file for preprocessor lexer
5 1.1.1.1.10.2 tls *
6 1.1.1.1.10.2 tls *****************************************************************************/
7 1.1.1.1.10.2 tls
8 1.1.1.1.10.2 tls /*
9 1.1.1.1.10.3 jdolecek * Copyright (C) 2000 - 2017, Intel Corp.
10 1.1.1.1.10.2 tls * All rights reserved.
11 1.1.1.1.10.2 tls *
12 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
13 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
14 1.1.1.1.10.2 tls * are met:
15 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
16 1.1.1.1.10.2 tls * notice, this list of conditions, and the following disclaimer,
17 1.1.1.1.10.2 tls * without modification.
18 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 1.1.1.1.10.2 tls * substantially similar to the "NO WARRANTY" disclaimer below
20 1.1.1.1.10.2 tls * ("Disclaimer") and any redistribution must be conditioned upon
21 1.1.1.1.10.2 tls * including a substantially similar Disclaimer requirement for further
22 1.1.1.1.10.2 tls * binary redistribution.
23 1.1.1.1.10.2 tls * 3. Neither the names of the above-listed copyright holders nor the names
24 1.1.1.1.10.2 tls * of any contributors may be used to endorse or promote products derived
25 1.1.1.1.10.2 tls * from this software without specific prior written permission.
26 1.1.1.1.10.2 tls *
27 1.1.1.1.10.2 tls * Alternatively, this software may be distributed under the terms of the
28 1.1.1.1.10.2 tls * GNU General Public License ("GPL") version 2 as published by the Free
29 1.1.1.1.10.2 tls * Software Foundation.
30 1.1.1.1.10.2 tls *
31 1.1.1.1.10.2 tls * NO WARRANTY
32 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 1.1.1.1.10.2 tls * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 1.1.1.1.10.2 tls * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 1.1.1.1.10.2 tls * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 1.1.1.1.10.2 tls * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 1.1.1.1.10.2 tls * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 1.1.1.1.10.2 tls * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 1.1.1.1.10.2 tls * POSSIBILITY OF SUCH DAMAGES.
43 1.1.1.1.10.2 tls */
44 1.1.1.1.10.2 tls
45 1.1.1.1.10.2 tls #include "aslcompiler.h"
46 1.1.1.1.10.2 tls #include "prparser.y.h"
47 1.1.1.1.10.2 tls
48 1.1.1.1.10.2 tls /* Buffer to pass strings to the parser */
49 1.1.1.1.10.2 tls
50 1.1.1.1.10.2 tls #define STRING_SETUP strcpy (StringBuffer, PrParsertext);\
51 1.1.1.1.10.2 tls PrParserlval.str = StringBuffer
52 1.1.1.1.10.2 tls
53 1.1.1.1.10.2 tls #define _COMPONENT ACPI_COMPILER
54 1.1.1.1.10.2 tls ACPI_MODULE_NAME ("prscanner")
55 1.1.1.1.10.3 jdolecek
56 1.1.1.1.10.3 jdolecek
57 1.1.1.1.10.3 jdolecek /* Local prototypes */
58 1.1.1.1.10.3 jdolecek
59 1.1.1.1.10.3 jdolecek static char
60 1.1.1.1.10.3 jdolecek PrDoCommentType1 (
61 1.1.1.1.10.3 jdolecek void);
62 1.1.1.1.10.3 jdolecek
63 1.1.1.1.10.3 jdolecek static char
64 1.1.1.1.10.3 jdolecek PrDoCommentType2 (
65 1.1.1.1.10.3 jdolecek void);
66 1.1.1.1.10.2 tls %}
67 1.1.1.1.10.2 tls
68 1.1.1.1.10.2 tls %option noyywrap
69 1.1.1.1.10.2 tls
70 1.1.1.1.10.2 tls Number [0-9a-fA-F]+
71 1.1.1.1.10.2 tls HexNumber 0[xX][0-9a-fA-F]+
72 1.1.1.1.10.2 tls WhiteSpace [ \t\v\r]+
73 1.1.1.1.10.2 tls NewLine [\n]
74 1.1.1.1.10.2 tls Identifier [a-zA-Z][0-9a-zA-Z]*
75 1.1.1.1.10.2 tls
76 1.1.1.1.10.2 tls %%
77 1.1.1.1.10.3 jdolecek "/*" { if (!PrDoCommentType1 ()) {yyterminate ();} }
78 1.1.1.1.10.3 jdolecek "//" { if (!PrDoCommentType2 ()) {yyterminate ();} }
79 1.1.1.1.10.2 tls
80 1.1.1.1.10.2 tls \( return (EXPOP_PAREN_OPEN);
81 1.1.1.1.10.2 tls \) return (EXPOP_PAREN_CLOSE);
82 1.1.1.1.10.2 tls \~ return (EXPOP_ONES_COMPLIMENT);
83 1.1.1.1.10.2 tls \! return (EXPOP_LOGICAL_NOT);
84 1.1.1.1.10.2 tls \* return (EXPOP_MULTIPLY);
85 1.1.1.1.10.2 tls \/ return (EXPOP_DIVIDE);
86 1.1.1.1.10.2 tls \% return (EXPOP_MODULO);
87 1.1.1.1.10.2 tls \+ return (EXPOP_ADD);
88 1.1.1.1.10.2 tls \- return (EXPOP_SUBTRACT);
89 1.1.1.1.10.2 tls ">>" return (EXPOP_SHIFT_RIGHT);
90 1.1.1.1.10.2 tls "<<" return (EXPOP_SHIFT_LEFT);
91 1.1.1.1.10.2 tls \< return (EXPOP_LESS);
92 1.1.1.1.10.2 tls \> return (EXPOP_GREATER);
93 1.1.1.1.10.2 tls "<=" return (EXPOP_LESS_EQUAL);
94 1.1.1.1.10.2 tls ">=" return (EXPOP_GREATER_EQUAL);
95 1.1.1.1.10.2 tls "==" return (EXPOP_EQUAL);
96 1.1.1.1.10.2 tls "!=" return (EXPOP_NOT_EQUAL);
97 1.1.1.1.10.2 tls \& return (EXPOP_AND);
98 1.1.1.1.10.2 tls \^ return (EXPOP_XOR);
99 1.1.1.1.10.2 tls \| return (EXPOP_OR);
100 1.1.1.1.10.2 tls "&&" return (EXPOP_LOGICAL_AND);
101 1.1.1.1.10.2 tls "||" return (EXPOP_LOGICAL_OR);
102 1.1.1.1.10.2 tls
103 1.1.1.1.10.2 tls "defined" return (EXPOP_DEFINE);
104 1.1.1.1.10.2 tls {Identifier} {STRING_SETUP; return (EXPOP_IDENTIFIER);}
105 1.1.1.1.10.2 tls
106 1.1.1.1.10.2 tls <<EOF>> return (EXPOP_EOF); /* null end-of-string */
107 1.1.1.1.10.2 tls
108 1.1.1.1.10.2 tls {Number} return (EXPOP_NUMBER);
109 1.1.1.1.10.2 tls {HexNumber} return (EXPOP_HEX_NUMBER);
110 1.1.1.1.10.2 tls {NewLine} return (EXPOP_NEW_LINE);
111 1.1.1.1.10.2 tls {WhiteSpace} /* Ignore */
112 1.1.1.1.10.2 tls
113 1.1.1.1.10.2 tls . return (EXPOP_EOF);
114 1.1.1.1.10.2 tls %%
115 1.1.1.1.10.2 tls
116 1.1.1.1.10.2 tls /*
117 1.1.1.1.10.2 tls * Local support functions
118 1.1.1.1.10.2 tls */
119 1.1.1.1.10.2 tls YY_BUFFER_STATE LexBuffer;
120 1.1.1.1.10.2 tls
121 1.1.1.1.10.2 tls
122 1.1.1.1.10.2 tls /******************************************************************************
123 1.1.1.1.10.2 tls *
124 1.1.1.1.10.2 tls * FUNCTION: PrInitLexer
125 1.1.1.1.10.2 tls *
126 1.1.1.1.10.2 tls * PARAMETERS: String - Input string to be parsed
127 1.1.1.1.10.2 tls *
128 1.1.1.1.10.2 tls * RETURN: TRUE if parser returns NULL. FALSE otherwise.
129 1.1.1.1.10.2 tls *
130 1.1.1.1.10.2 tls * DESCRIPTION: Initialization routine for lexer. The lexer needs
131 1.1.1.1.10.2 tls * a buffer to handle strings instead of a file.
132 1.1.1.1.10.2 tls *
133 1.1.1.1.10.2 tls *****************************************************************************/
134 1.1.1.1.10.2 tls
135 1.1.1.1.10.2 tls int
136 1.1.1.1.10.2 tls PrInitLexer (
137 1.1.1.1.10.2 tls char *String)
138 1.1.1.1.10.2 tls {
139 1.1.1.1.10.2 tls
140 1.1.1.1.10.2 tls LexBuffer = yy_scan_string (String);
141 1.1.1.1.10.2 tls return (LexBuffer == NULL);
142 1.1.1.1.10.2 tls }
143 1.1.1.1.10.2 tls
144 1.1.1.1.10.2 tls
145 1.1.1.1.10.2 tls /******************************************************************************
146 1.1.1.1.10.2 tls *
147 1.1.1.1.10.2 tls * FUNCTION: PrTerminateLexer
148 1.1.1.1.10.2 tls *
149 1.1.1.1.10.2 tls * PARAMETERS: None
150 1.1.1.1.10.2 tls *
151 1.1.1.1.10.2 tls * RETURN: None
152 1.1.1.1.10.2 tls *
153 1.1.1.1.10.2 tls * DESCRIPTION: Termination routine for thelexer.
154 1.1.1.1.10.2 tls *
155 1.1.1.1.10.2 tls *****************************************************************************/
156 1.1.1.1.10.2 tls
157 1.1.1.1.10.2 tls void
158 1.1.1.1.10.2 tls PrTerminateLexer (
159 1.1.1.1.10.2 tls void)
160 1.1.1.1.10.2 tls {
161 1.1.1.1.10.2 tls
162 1.1.1.1.10.2 tls yy_delete_buffer (LexBuffer);
163 1.1.1.1.10.2 tls }
164 1.1.1.1.10.3 jdolecek
165 1.1.1.1.10.3 jdolecek
166 1.1.1.1.10.3 jdolecek /********************************************************************************
167 1.1.1.1.10.3 jdolecek *
168 1.1.1.1.10.3 jdolecek * FUNCTION: PrDoCommentType1
169 1.1.1.1.10.3 jdolecek *
170 1.1.1.1.10.3 jdolecek * PARAMETERS: none
171 1.1.1.1.10.3 jdolecek *
172 1.1.1.1.10.3 jdolecek * RETURN: none
173 1.1.1.1.10.3 jdolecek *
174 1.1.1.1.10.3 jdolecek * DESCRIPTION: Process a new legacy comment. Just toss it.
175 1.1.1.1.10.3 jdolecek *
176 1.1.1.1.10.3 jdolecek ******************************************************************************/
177 1.1.1.1.10.3 jdolecek
178 1.1.1.1.10.3 jdolecek static char
179 1.1.1.1.10.3 jdolecek PrDoCommentType1 (
180 1.1.1.1.10.3 jdolecek void)
181 1.1.1.1.10.3 jdolecek {
182 1.1.1.1.10.3 jdolecek int c;
183 1.1.1.1.10.3 jdolecek
184 1.1.1.1.10.3 jdolecek
185 1.1.1.1.10.3 jdolecek Loop:
186 1.1.1.1.10.3 jdolecek while (((c = input ()) != '*') && (c != EOF))
187 1.1.1.1.10.3 jdolecek {
188 1.1.1.1.10.3 jdolecek }
189 1.1.1.1.10.3 jdolecek if (c == EOF)
190 1.1.1.1.10.3 jdolecek {
191 1.1.1.1.10.3 jdolecek return (FALSE);
192 1.1.1.1.10.3 jdolecek }
193 1.1.1.1.10.3 jdolecek
194 1.1.1.1.10.3 jdolecek if (((c = input ()) != '/') && (c != EOF))
195 1.1.1.1.10.3 jdolecek {
196 1.1.1.1.10.3 jdolecek unput (c);
197 1.1.1.1.10.3 jdolecek goto Loop;
198 1.1.1.1.10.3 jdolecek }
199 1.1.1.1.10.3 jdolecek if (c == EOF)
200 1.1.1.1.10.3 jdolecek {
201 1.1.1.1.10.3 jdolecek return (FALSE);
202 1.1.1.1.10.3 jdolecek }
203 1.1.1.1.10.3 jdolecek
204 1.1.1.1.10.3 jdolecek return (TRUE);
205 1.1.1.1.10.3 jdolecek }
206 1.1.1.1.10.3 jdolecek
207 1.1.1.1.10.3 jdolecek
208 1.1.1.1.10.3 jdolecek /********************************************************************************
209 1.1.1.1.10.3 jdolecek *
210 1.1.1.1.10.3 jdolecek * FUNCTION: PrDoCommentType2
211 1.1.1.1.10.3 jdolecek *
212 1.1.1.1.10.3 jdolecek * PARAMETERS: none
213 1.1.1.1.10.3 jdolecek *
214 1.1.1.1.10.3 jdolecek * RETURN: none
215 1.1.1.1.10.3 jdolecek *
216 1.1.1.1.10.3 jdolecek * DESCRIPTION: Process a new "//" comment. Just toss it.
217 1.1.1.1.10.3 jdolecek *
218 1.1.1.1.10.3 jdolecek ******************************************************************************/
219 1.1.1.1.10.3 jdolecek
220 1.1.1.1.10.3 jdolecek static char
221 1.1.1.1.10.3 jdolecek PrDoCommentType2 (
222 1.1.1.1.10.3 jdolecek void)
223 1.1.1.1.10.3 jdolecek {
224 1.1.1.1.10.3 jdolecek int c;
225 1.1.1.1.10.3 jdolecek
226 1.1.1.1.10.3 jdolecek
227 1.1.1.1.10.3 jdolecek while (((c = input ()) != '\n') && (c != EOF))
228 1.1.1.1.10.3 jdolecek {
229 1.1.1.1.10.3 jdolecek }
230 1.1.1.1.10.3 jdolecek if (c == EOF)
231 1.1.1.1.10.3 jdolecek {
232 1.1.1.1.10.3 jdolecek return (FALSE);
233 1.1.1.1.10.3 jdolecek }
234 1.1.1.1.10.3 jdolecek
235 1.1.1.1.10.3 jdolecek return (TRUE);
236 1.1.1.1.10.3 jdolecek }
237