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