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