util/qlalr/grammar_p.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the utils of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef GRAMMAR_P_H
       
    43 #define GRAMMAR_P_H
       
    44 
       
    45 class grammar
       
    46 {
       
    47 public:
       
    48   enum {
       
    49     EOF_SYMBOL = 0,
       
    50     COLON = 16,
       
    51     DECL = 19,
       
    52     DECL_FILE = 3,
       
    53     ERROR = 21,
       
    54     EXPECT = 4,
       
    55     EXPECT_RR = 5,
       
    56     ID = 1,
       
    57     IMPL = 20,
       
    58     IMPL_FILE = 6,
       
    59     LEFT = 7,
       
    60     MERGED_OUTPUT = 8,
       
    61     NONASSOC = 9,
       
    62     OR = 17,
       
    63     PARSER = 10,
       
    64     PREC = 11,
       
    65     RIGHT = 12,
       
    66     SEMICOLON = 18,
       
    67     START = 13,
       
    68     STRING_LITERAL = 2,
       
    69     TOKEN = 14,
       
    70     TOKEN_PREFIX = 15,
       
    71 
       
    72     ACCEPT_STATE = 68,
       
    73     RULE_COUNT = 45,
       
    74     STATE_COUNT = 69,
       
    75     TERMINAL_COUNT = 22,
       
    76     NON_TERMINAL_COUNT = 24,
       
    77 
       
    78     GOTO_INDEX_OFFSET = 69,
       
    79     GOTO_INFO_OFFSET = 76,
       
    80     GOTO_CHECK_OFFSET = 76
       
    81   };
       
    82 
       
    83   static const char  *const spell [];
       
    84   static const int            lhs [];
       
    85   static const int            rhs [];
       
    86   static const int   goto_default [];
       
    87   static const int action_default [];
       
    88   static const int   action_index [];
       
    89   static const int    action_info [];
       
    90   static const int   action_check [];
       
    91 
       
    92   inline int nt_action (int state, int nt) const
       
    93   {
       
    94     const int *const goto_index = &action_index [GOTO_INDEX_OFFSET];
       
    95     const int *const goto_check = &action_check [GOTO_CHECK_OFFSET];
       
    96 
       
    97     const int yyn = goto_index [state] + nt;
       
    98 
       
    99     if (yyn < 0 || goto_check [yyn] != nt)
       
   100       return goto_default [nt];
       
   101 
       
   102     const int *const goto_info = &action_info [GOTO_INFO_OFFSET];
       
   103     return goto_info [yyn];
       
   104   }
       
   105 
       
   106   inline int t_action (int state, int token) const
       
   107   {
       
   108     const int yyn = action_index [state] + token;
       
   109 
       
   110     if (yyn < 0 || action_check [yyn] != token)
       
   111       return - action_default [state];
       
   112 
       
   113     return action_info [yyn];
       
   114   }
       
   115 };
       
   116 
       
   117 
       
   118 #endif // GRAMMAR_P_H
       
   119