prparser.l revision 1.1.1.1.10.2 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.2 tls * Copyright (C) 2000 - 2013, 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 YY_NO_INPUT /* No file input, we use strings only */
54 1.1.1.1.10.2 tls
55 1.1.1.1.10.2 tls #define _COMPONENT ACPI_COMPILER
56 1.1.1.1.10.2 tls ACPI_MODULE_NAME ("prscanner")
57 1.1.1.1.10.2 tls %}
58 1.1.1.1.10.2 tls
59 1.1.1.1.10.2 tls %option noyywrap
60 1.1.1.1.10.2 tls %option nounput
61 1.1.1.1.10.2 tls
62 1.1.1.1.10.2 tls Number [0-9a-fA-F]+
63 1.1.1.1.10.2 tls HexNumber 0[xX][0-9a-fA-F]+
64 1.1.1.1.10.2 tls WhiteSpace [ \t\v\r]+
65 1.1.1.1.10.2 tls NewLine [\n]
66 1.1.1.1.10.2 tls Identifier [a-zA-Z][0-9a-zA-Z]*
67 1.1.1.1.10.2 tls
68 1.1.1.1.10.2 tls %%
69 1.1.1.1.10.2 tls
70 1.1.1.1.10.2 tls \( return (EXPOP_PAREN_OPEN);
71 1.1.1.1.10.2 tls \) return (EXPOP_PAREN_CLOSE);
72 1.1.1.1.10.2 tls \~ return (EXPOP_ONES_COMPLIMENT);
73 1.1.1.1.10.2 tls \! return (EXPOP_LOGICAL_NOT);
74 1.1.1.1.10.2 tls \* return (EXPOP_MULTIPLY);
75 1.1.1.1.10.2 tls \/ return (EXPOP_DIVIDE);
76 1.1.1.1.10.2 tls \% return (EXPOP_MODULO);
77 1.1.1.1.10.2 tls \+ return (EXPOP_ADD);
78 1.1.1.1.10.2 tls \- return (EXPOP_SUBTRACT);
79 1.1.1.1.10.2 tls ">>" return (EXPOP_SHIFT_RIGHT);
80 1.1.1.1.10.2 tls "<<" return (EXPOP_SHIFT_LEFT);
81 1.1.1.1.10.2 tls \< return (EXPOP_LESS);
82 1.1.1.1.10.2 tls \> return (EXPOP_GREATER);
83 1.1.1.1.10.2 tls "<=" return (EXPOP_LESS_EQUAL);
84 1.1.1.1.10.2 tls ">=" return (EXPOP_GREATER_EQUAL);
85 1.1.1.1.10.2 tls "==" return (EXPOP_EQUAL);
86 1.1.1.1.10.2 tls "!=" return (EXPOP_NOT_EQUAL);
87 1.1.1.1.10.2 tls \& return (EXPOP_AND);
88 1.1.1.1.10.2 tls \^ return (EXPOP_XOR);
89 1.1.1.1.10.2 tls \| return (EXPOP_OR);
90 1.1.1.1.10.2 tls "&&" return (EXPOP_LOGICAL_AND);
91 1.1.1.1.10.2 tls "||" return (EXPOP_LOGICAL_OR);
92 1.1.1.1.10.2 tls
93 1.1.1.1.10.2 tls "defined" return (EXPOP_DEFINE);
94 1.1.1.1.10.2 tls {Identifier} {STRING_SETUP; return (EXPOP_IDENTIFIER);}
95 1.1.1.1.10.2 tls
96 1.1.1.1.10.2 tls <<EOF>> return (EXPOP_EOF); /* null end-of-string */
97 1.1.1.1.10.2 tls
98 1.1.1.1.10.2 tls {Number} return (EXPOP_NUMBER);
99 1.1.1.1.10.2 tls {HexNumber} return (EXPOP_HEX_NUMBER);
100 1.1.1.1.10.2 tls {NewLine} return (EXPOP_NEW_LINE);
101 1.1.1.1.10.2 tls {WhiteSpace} /* Ignore */
102 1.1.1.1.10.2 tls
103 1.1.1.1.10.2 tls . return (EXPOP_EOF);
104 1.1.1.1.10.2 tls %%
105 1.1.1.1.10.2 tls
106 1.1.1.1.10.2 tls /*
107 1.1.1.1.10.2 tls * Local support functions
108 1.1.1.1.10.2 tls */
109 1.1.1.1.10.2 tls YY_BUFFER_STATE LexBuffer;
110 1.1.1.1.10.2 tls
111 1.1.1.1.10.2 tls
112 1.1.1.1.10.2 tls /******************************************************************************
113 1.1.1.1.10.2 tls *
114 1.1.1.1.10.2 tls * FUNCTION: PrInitLexer
115 1.1.1.1.10.2 tls *
116 1.1.1.1.10.2 tls * PARAMETERS: String - Input string to be parsed
117 1.1.1.1.10.2 tls *
118 1.1.1.1.10.2 tls * RETURN: TRUE if parser returns NULL. FALSE otherwise.
119 1.1.1.1.10.2 tls *
120 1.1.1.1.10.2 tls * DESCRIPTION: Initialization routine for lexer. The lexer needs
121 1.1.1.1.10.2 tls * a buffer to handle strings instead of a file.
122 1.1.1.1.10.2 tls *
123 1.1.1.1.10.2 tls *****************************************************************************/
124 1.1.1.1.10.2 tls
125 1.1.1.1.10.2 tls int
126 1.1.1.1.10.2 tls PrInitLexer (
127 1.1.1.1.10.2 tls char *String)
128 1.1.1.1.10.2 tls {
129 1.1.1.1.10.2 tls
130 1.1.1.1.10.2 tls LexBuffer = yy_scan_string (String);
131 1.1.1.1.10.2 tls return (LexBuffer == NULL);
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 /******************************************************************************
136 1.1.1.1.10.2 tls *
137 1.1.1.1.10.2 tls * FUNCTION: PrTerminateLexer
138 1.1.1.1.10.2 tls *
139 1.1.1.1.10.2 tls * PARAMETERS: None
140 1.1.1.1.10.2 tls *
141 1.1.1.1.10.2 tls * RETURN: None
142 1.1.1.1.10.2 tls *
143 1.1.1.1.10.2 tls * DESCRIPTION: Termination routine for thelexer.
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 void
148 1.1.1.1.10.2 tls PrTerminateLexer (
149 1.1.1.1.10.2 tls void)
150 1.1.1.1.10.2 tls {
151 1.1.1.1.10.2 tls
152 1.1.1.1.10.2 tls yy_delete_buffer (LexBuffer);
153 1.1.1.1.10.2 tls }
154