1233237Sjkim%{
2233237Sjkim/******************************************************************************
3233237Sjkim *
4233237Sjkim * Module Name: prparser.l - Flex input file for preprocessor lexer
5233237Sjkim *
6233237Sjkim *****************************************************************************/
7233237Sjkim
8233237Sjkim/*
9281075Sdim * Copyright (C) 2000 - 2015, Intel Corp.
10233237Sjkim * All rights reserved.
11233237Sjkim *
12233237Sjkim * Redistribution and use in source and binary forms, with or without
13233237Sjkim * modification, are permitted provided that the following conditions
14233237Sjkim * are met:
15233237Sjkim * 1. Redistributions of source code must retain the above copyright
16233237Sjkim *    notice, this list of conditions, and the following disclaimer,
17233237Sjkim *    without modification.
18233237Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19233237Sjkim *    substantially similar to the "NO WARRANTY" disclaimer below
20233237Sjkim *    ("Disclaimer") and any redistribution must be conditioned upon
21233237Sjkim *    including a substantially similar Disclaimer requirement for further
22233237Sjkim *    binary redistribution.
23233237Sjkim * 3. Neither the names of the above-listed copyright holders nor the names
24233237Sjkim *    of any contributors may be used to endorse or promote products derived
25233237Sjkim *    from this software without specific prior written permission.
26233237Sjkim *
27233237Sjkim * Alternatively, this software may be distributed under the terms of the
28233237Sjkim * GNU General Public License ("GPL") version 2 as published by the Free
29233237Sjkim * Software Foundation.
30233237Sjkim *
31233237Sjkim * NO WARRANTY
32233237Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33233237Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34233237Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35233237Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36233237Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37233237Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38233237Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39233237Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40233237Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41233237Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42233237Sjkim * POSSIBILITY OF SUCH DAMAGES.
43233237Sjkim */
44233237Sjkim
45233250Sjkim#include <contrib/dev/acpica/compiler/aslcompiler.h>
46233237Sjkim#include "prparser.y.h"
47233237Sjkim
48233237Sjkim/* Buffer to pass strings to the parser */
49233237Sjkim
50233237Sjkim#define STRING_SETUP    strcpy (StringBuffer, PrParsertext);\
51233237Sjkim    PrParserlval.str = StringBuffer
52233237Sjkim
53233237Sjkim#define YY_NO_INPUT     /* No file input, we use strings only */
54233237Sjkim
55233237Sjkim#define _COMPONENT          ACPI_COMPILER
56233237Sjkim        ACPI_MODULE_NAME    ("prscanner")
57233237Sjkim%}
58233237Sjkim
59233237Sjkim%option noyywrap
60233237Sjkim%option nounput
61233237Sjkim
62233237SjkimNumber          [0-9a-fA-F]+
63233237SjkimHexNumber       0[xX][0-9a-fA-F]+
64233237SjkimWhiteSpace      [ \t\v\r]+
65233237SjkimNewLine         [\n]
66233237SjkimIdentifier      [a-zA-Z][0-9a-zA-Z]*
67233237Sjkim
68233237Sjkim%%
69233237Sjkim
70233237Sjkim\(              return (EXPOP_PAREN_OPEN);
71233237Sjkim\)              return (EXPOP_PAREN_CLOSE);
72233237Sjkim\~              return (EXPOP_ONES_COMPLIMENT);
73233237Sjkim\!              return (EXPOP_LOGICAL_NOT);
74233237Sjkim\*              return (EXPOP_MULTIPLY);
75233237Sjkim\/              return (EXPOP_DIVIDE);
76233237Sjkim\%              return (EXPOP_MODULO);
77233237Sjkim\+              return (EXPOP_ADD);
78233237Sjkim\-              return (EXPOP_SUBTRACT);
79233237Sjkim">>"            return (EXPOP_SHIFT_RIGHT);
80233237Sjkim"<<"            return (EXPOP_SHIFT_LEFT);
81233237Sjkim\<              return (EXPOP_LESS);
82233237Sjkim\>              return (EXPOP_GREATER);
83233237Sjkim"<="            return (EXPOP_LESS_EQUAL);
84233237Sjkim">="            return (EXPOP_GREATER_EQUAL);
85233237Sjkim"=="            return (EXPOP_EQUAL);
86233237Sjkim"!="            return (EXPOP_NOT_EQUAL);
87233237Sjkim\&              return (EXPOP_AND);
88233237Sjkim\^              return (EXPOP_XOR);
89233237Sjkim\|              return (EXPOP_OR);
90233237Sjkim"&&"            return (EXPOP_LOGICAL_AND);
91233237Sjkim"||"            return (EXPOP_LOGICAL_OR);
92233237Sjkim
93233237Sjkim"defined"       return (EXPOP_DEFINE);
94233237Sjkim{Identifier}    {STRING_SETUP; return (EXPOP_IDENTIFIER);}
95233237Sjkim
96233237Sjkim<<EOF>>         return (EXPOP_EOF); /* null end-of-string */
97233237Sjkim
98233237Sjkim{Number}        return (EXPOP_NUMBER);
99233237Sjkim{HexNumber}     return (EXPOP_HEX_NUMBER);
100233237Sjkim{NewLine}       return (EXPOP_NEW_LINE);
101233237Sjkim{WhiteSpace}    /* Ignore */
102233237Sjkim
103233237Sjkim.               return (EXPOP_EOF);
104233237Sjkim%%
105233237Sjkim
106233237Sjkim/*
107233237Sjkim * Local support functions
108233237Sjkim */
109233237SjkimYY_BUFFER_STATE         LexBuffer;
110233237Sjkim
111233237Sjkim
112233237Sjkim/******************************************************************************
113233237Sjkim *
114233237Sjkim * FUNCTION:    PrInitLexer
115233237Sjkim *
116233237Sjkim * PARAMETERS:  String              - Input string to be parsed
117233237Sjkim *
118233237Sjkim * RETURN:      TRUE if parser returns NULL. FALSE otherwise.
119233237Sjkim *
120233237Sjkim * DESCRIPTION: Initialization routine for lexer. The lexer needs
121233237Sjkim *              a buffer to handle strings instead of a file.
122233237Sjkim *
123233237Sjkim *****************************************************************************/
124233237Sjkim
125233237Sjkimint
126233237SjkimPrInitLexer (
127233237Sjkim    char                    *String)
128233237Sjkim{
129233237Sjkim
130233237Sjkim    LexBuffer = yy_scan_string (String);
131233237Sjkim    return (LexBuffer == NULL);
132233237Sjkim}
133233237Sjkim
134233237Sjkim
135233237Sjkim/******************************************************************************
136233237Sjkim *
137233237Sjkim * FUNCTION:    PrTerminateLexer
138233237Sjkim *
139233237Sjkim * PARAMETERS:  None
140233237Sjkim *
141233237Sjkim * RETURN:      None
142233237Sjkim *
143233237Sjkim * DESCRIPTION: Termination routine for thelexer.
144233237Sjkim *
145233237Sjkim *****************************************************************************/
146233237Sjkim
147233237Sjkimvoid
148233237SjkimPrTerminateLexer (
149233237Sjkim    void)
150233237Sjkim{
151233237Sjkim
152233237Sjkim    yy_delete_buffer (LexBuffer);
153233237Sjkim}
154