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