| 1 |
%{ |
| 2 |
/****************************************************************************** |
| 3 |
* |
| 4 |
* Module Name: dtparser.l - Flex input file for table compiler lexer |
| 5 |
* |
| 6 |
*****************************************************************************/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (C) 2000 - 2026, Intel Corp. |
| 10 |
* All rights reserved. |
| 11 |
* |
| 12 |
* Redistribution and use in source and binary forms, with or without |
| 13 |
* modification, are permitted provided that the following conditions |
| 14 |
* are met: |
| 15 |
* 1. Redistributions of source code must retain the above copyright |
| 16 |
* notice, this list of conditions, and the following disclaimer, |
| 17 |
* without modification. |
| 18 |
* 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 19 |
* substantially similar to the "NO WARRANTY" disclaimer below |
| 20 |
* ("Disclaimer") and any redistribution must be conditioned upon |
| 21 |
* including a substantially similar Disclaimer requirement for further |
| 22 |
* binary redistribution. |
| 23 |
* 3. Neither the names of the above-listed copyright holders nor the names |
| 24 |
* of any contributors may be used to endorse or promote products derived |
| 25 |
* from this software without specific prior written permission. |
| 26 |
* |
| 27 |
* Alternatively, this software may be distributed under the terms of the |
| 28 |
* GNU General Public License ("GPL") version 2 as published by the Free |
| 29 |
* Software Foundation. |
| 30 |
* |
| 31 |
* NO WARRANTY |
| 32 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 33 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 34 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 35 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 36 |
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 37 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 38 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 39 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 40 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 41 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 42 |
* POSSIBILITY OF SUCH DAMAGES. |
| 43 |
*/ |
| 44 |
|
| 45 |
#include "aslcompiler.h" |
| 46 |
#include "dtparser.y.h" |
| 47 |
|
| 48 |
#define YY_NO_INPUT /* No file input, we use strings only */ |
| 49 |
|
| 50 |
#define _COMPONENT ACPI_COMPILER |
| 51 |
ACPI_MODULE_NAME ("dtscanner") |
| 52 |
%} |
| 53 |
|
| 54 |
%option noyywrap |
| 55 |
%option nounput |
| 56 |
|
| 57 |
Number [0-9a-fA-F]+ |
| 58 |
HexNumber 0[xX][0-9a-fA-F]+ |
| 59 |
DecimalNumber 0[dD][0-9]+ |
| 60 |
LabelRef $[a-zA-Z][0-9a-zA-Z]* |
| 61 |
WhiteSpace [ \t\v\r]+ |
| 62 |
NewLine [\n] |
| 63 |
|
| 64 |
%% |
| 65 |
|
| 66 |
\( return (OP_EXP_PAREN_OPEN); |
| 67 |
\) return (OP_EXP_PAREN_CLOSE); |
| 68 |
\~ return (OP_EXP_ONES_COMPLIMENT); |
| 69 |
\! return (OP_EXP_LOGICAL_NOT); |
| 70 |
\* return (OP_EXP_MULTIPLY); |
| 71 |
\/ return (OP_EXP_DIVIDE); |
| 72 |
\% return (OP_EXP_MODULO); |
| 73 |
\+ return (OP_EXP_ADD); |
| 74 |
\- return (OP_EXP_SUBTRACT); |
| 75 |
">>" return (OP_EXP_SHIFT_RIGHT); |
| 76 |
"<<" return (OP_EXP_SHIFT_LEFT); |
| 77 |
\< return (OP_EXP_LESS); |
| 78 |
\> return (OP_EXP_GREATER); |
| 79 |
"<=" return (OP_EXP_LESS_EQUAL); |
| 80 |
">=" return (OP_EXP_GREATER_EQUAL); |
| 81 |
"==" return (OP_EXP_EQUAL); |
| 82 |
"!=" return (OP_EXP_NOT_EQUAL); |
| 83 |
\& return (OP_EXP_AND); |
| 84 |
\^ return (OP_EXP_XOR); |
| 85 |
\| return (OP_EXP_OR); |
| 86 |
"&&" return (OP_EXP_LOGICAL_AND); |
| 87 |
"||" return (OP_EXP_LOGICAL_OR); |
| 88 |
<<EOF>> return (OP_EXP_EOF); /* null end-of-string */ |
| 89 |
|
| 90 |
{LabelRef} return (OP_EXP_LABEL); |
| 91 |
{Number} return (OP_EXP_NUMBER); |
| 92 |
{HexNumber} return (OP_EXP_HEX_NUMBER); |
| 93 |
{NewLine} return (OP_EXP_NEW_LINE); |
| 94 |
{WhiteSpace} /* Ignore */ |
| 95 |
|
| 96 |
. return (OP_EXP_EOF); |
| 97 |
|
| 98 |
%% |
| 99 |
|
| 100 |
/* |
| 101 |
* Local support functions |
| 102 |
*/ |
| 103 |
static YY_BUFFER_STATE LexBuffer; |
| 104 |
|
| 105 |
/****************************************************************************** |
| 106 |
* |
| 107 |
* FUNCTION: DtInitLexer, DtTerminateLexer |
| 108 |
* |
| 109 |
* PARAMETERS: String - Input string to be parsed |
| 110 |
* |
| 111 |
* RETURN: None |
| 112 |
* |
| 113 |
* DESCRIPTION: Initialization and termination routines for lexer. Lexer needs |
| 114 |
* a buffer to handle strings instead of a file. |
| 115 |
* |
| 116 |
*****************************************************************************/ |
| 117 |
|
| 118 |
int |
| 119 |
DtInitLexer ( |
| 120 |
char *String) |
| 121 |
{ |
| 122 |
LexBuffer = yy_scan_string (String); |
| 123 |
return (LexBuffer == NULL); |
| 124 |
} |
| 125 |
|
| 126 |
void |
| 127 |
DtTerminateLexer ( |
| 128 |
void) |
| 129 |
{ |
| 130 |
yy_delete_buffer (LexBuffer); |
| 131 |
} |