#
# DO NOT EDIT THIS FILE!
#
# Parser generated by BisonGen on Fri Jun  1 02:04:43 2001.
#


# token definitions
AND = 257
OR = 258
EQ = 259
NE = 260
LT = 261
LE = 262
GT = 263
GE = 264
LSH = 265
RSH = 266
INTEGER = 267
IDENTIFIER = 268
DEFINED = 269

# vector mapping lexer token numbers into internal token numbers
token_translations = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 24, 2, 2, 2, 23, 18, 2, 
26, 27, 21, 19, 2, 20, 2, 22, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 17, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 2, 25, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

YYTRANSLATE = lambda x: x > 269 and 42 or token_translations[x]

# vector of items of all rules.
rhs_tokens = [None,
              [29],
              [30],
              [31],
              [30, 4, 31],
              [32],
              [31, 3, 32],
              [33],
              [32, 16, 33],
              [34],
              [33, 17, 34],
              [35],
              [34, 18, 35],
              [36],
              [35, 5, 36],
              [35, 6, 36],
              [37],
              [36, 7, 37],
              [36, 8, 37],
              [36, 9, 37],
              [36, 10, 37],
              [38],
              [37, 11, 38],
              [37, 12, 38],
              [39],
              [38, 19, 39],
              [38, 20, 39],
              [40],
              [39, 21, 40],
              [39, 22, 40],
              [39, 23, 40],
              [41],
              [20, 41],
              [19, 41],
              [24, 41],
              [25, 41],
              [14],
              [13],
              [15, 26, 14, 27],
              [15, 14],
              [26, 29, 27],
              ]

# vector of line numbers and filename of all rules
rule_info = [": line 0",
             "Ods/Parsers/Odl/IfExpr.bgen: line 25",
             "Ods/Parsers/Odl/IfExpr.bgen: line 32",
             "Ods/Parsers/Odl/IfExpr.bgen: line 39",
             "Ods/Parsers/Odl/IfExpr.bgen: line 42",
             "Ods/Parsers/Odl/IfExpr.bgen: line 54",
             "Ods/Parsers/Odl/IfExpr.bgen: line 57",
             "Ods/Parsers/Odl/IfExpr.bgen: line 69",
             "Ods/Parsers/Odl/IfExpr.bgen: line 72",
             "Ods/Parsers/Odl/IfExpr.bgen: line 84",
             "Ods/Parsers/Odl/IfExpr.bgen: line 87",
             "Ods/Parsers/Odl/IfExpr.bgen: line 99",
             "Ods/Parsers/Odl/IfExpr.bgen: line 102",
             "Ods/Parsers/Odl/IfExpr.bgen: line 114",
             "Ods/Parsers/Odl/IfExpr.bgen: line 117",
             "Ods/Parsers/Odl/IfExpr.bgen: line 125",
             "Ods/Parsers/Odl/IfExpr.bgen: line 137",
             "Ods/Parsers/Odl/IfExpr.bgen: line 140",
             "Ods/Parsers/Odl/IfExpr.bgen: line 148",
             "Ods/Parsers/Odl/IfExpr.bgen: line 156",
             "Ods/Parsers/Odl/IfExpr.bgen: line 164",
             "Ods/Parsers/Odl/IfExpr.bgen: line 176",
             "Ods/Parsers/Odl/IfExpr.bgen: line 179",
             "Ods/Parsers/Odl/IfExpr.bgen: line 187",
             "Ods/Parsers/Odl/IfExpr.bgen: line 199",
             "Ods/Parsers/Odl/IfExpr.bgen: line 202",
             "Ods/Parsers/Odl/IfExpr.bgen: line 210",
             "Ods/Parsers/Odl/IfExpr.bgen: line 222",
             "Ods/Parsers/Odl/IfExpr.bgen: line 225",
             "Ods/Parsers/Odl/IfExpr.bgen: line 233",
             "Ods/Parsers/Odl/IfExpr.bgen: line 241",
             "Ods/Parsers/Odl/IfExpr.bgen: line 253",
             "Ods/Parsers/Odl/IfExpr.bgen: line 256",
             "Ods/Parsers/Odl/IfExpr.bgen: line 263",
             "Ods/Parsers/Odl/IfExpr.bgen: line 270",
             "Ods/Parsers/Odl/IfExpr.bgen: line 277",
             "Ods/Parsers/Odl/IfExpr.bgen: line 288",
             "Ods/Parsers/Odl/IfExpr.bgen: line 294",
             "Ods/Parsers/Odl/IfExpr.bgen: line 300",
             "Ods/Parsers/Odl/IfExpr.bgen: line 309",
             "Ods/Parsers/Odl/IfExpr.bgen: line 316",
             ]

# vector of string-names indexed by token number
token_names = ['$',
               'error',
               '$undefined.',
               'AND',
               'OR',
               'EQ',
               'NE',
               'LT',
               'LE',
               'GT',
               'GE',
               'LSH',
               'RSH',
               'INTEGER',
               'IDENTIFIER',
               'DEFINED',
               '|',
               '^',
               '&',
               '+',
               '-',
               '*',
               '/',
               '%',
               '!',
               '~',
               '(',
               ')',
               'const_expr',
               'expr',
               'logical_or_expr',
               'logical_and_expr',
               'bitwise_or_expr',
               'bitwise_xor_expr',
               'bitwise_and_expr',
               'equality_expr',
               'relational_expr',
               'shift_expr',
               'additive_expr',
               'multiplicative_expr',
               'unary_expr',
               'primary_expr',
               '0',
               ]

# symbol number of symbol that rule derives.
derives = [0, 28, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 35, 
36, 36, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 
40, 40, 41, 41, 41, 41, 41]

# number of symbols composing right hand side of rule.
rhs_size = [0, 1, 1, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 1, 3, 3, 3, 
3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 3, 1, 2, 2, 2, 2, 1, 1, 4, 2, 3]

# default rule to reduce with in state. 0 means the default is an error.
# indexed by state number
default_action = [0, 37, 36, 0, 0, 0, 0, 0, 0, 1, 2, 3, 5, 7, 9, 11, 13, 
16, 21, 24, 27, 31, 39, 0, 33, 32, 34, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 4, 6, 8, 10, 12, 14, 15, 17, 18, 19, 
20, 22, 23, 25, 26, 28, 29, 30, 38, 0, 0, 0]

# default state to go to after a reduction of a rule.
# indexed by variable number (lhs token)
default_goto = [68, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]

# index in yytable of the portion describing state (indexed by state number)
# If the value in yytable is positive, we shift the token and go to that state.
# If the value is negative, it is minus a rule number to reduce by.
# If the value is zero, the default action from yydefact[s] is used.
action_idx = [-13, -32768, -32768, 3, -10, -10, -10, -10, -5, -32768, 14, 
48, 38, 39, 37, 33, 15, 32, 26, 5, -32768, -32768, -32768, 43, -32768, 
-32768, -32768, -32768, 31, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 
-5, -5, -5, -5, -5, -5, -5, 34, -32768, 48, 38, 39, 37, 33, 15, 15, 32, 
32, 32, 32, 26, 26, 5, 5, -32768, -32768, -32768, -32768, 59, 60, -32768]

# the index in yytable of the portion describing what to do after reducing a rule.
# The value from yytable is the state to go to.
goto_idx = [-32768, 54, -32768, 35, 36, 40, 41, 42, 13, -6, 9, 10, -4, 
30]

# a vector filled with portions for different uses. (using action_idx and goto_idx)
yytable = [1, 2, 3, 1, 2, 3, 4, 5, 1, 2, 3, 6, 7, 8, 4, 5, 8, 22, 29, 6, 
7, 8, 36, 37, 38, 39, 44, 45, 46, 23, 56, 57, 58, 59, 24, 25, 26, 27, 34, 
35, 64, 65, 66, 40, 41, 42, 43, 54, 55, 60, 61, 30, 62, 63, 31, 33, 32, 
47, 48, 69, 70, 67, 28, 0, 49, 0, 50, 0, 0, 0, 0, 51, 0, 52, 0, 53]

# a vector indexed in parallel with yytable.
# It indicates the bounds of the portion you are trying to examine.
yycheck = [13, 14, 15, 13, 14, 15, 19, 20, 13, 14, 15, 24, 25, 26, 19, 
20, 26, 14, 4, 24, 25, 26, 7, 8, 9, 10, 21, 22, 23, 26, 36, 37, 38, 39, 
4, 5, 6, 7, 5, 6, 44, 45, 46, 11, 12, 19, 20, 34, 35, 40, 41, 3, 42, 43, 
16, 18, 17, 14, 27, 0, 0, 27, 8, -1, 29, -1, 30, -1, -1, -1, -1, 31, -1, 
32, -1, 33]

YYLAST = 75
YYFINAL = 70
YYFLAG = -32768
YYNTBASE = 28

# Static definitions
YYEMPTY = -2
YYEOF = 0
YYINITDEPTH = 1000

LEXER_FUNCTIONS = 0

class Parser:
    def __init__(self, verbose=0):
        self.verbose = verbose
        
    def debug_mode(self, flag=None):
        if flag is None:
            return self.verbose

        if type(flag) != type(1):
            raise TypeError('an integer is required')
        self.verbose = flag
        return flag

    def parse(self, text):
        state_stack = [0]*YYINITDEPTH
        value_stack = [0]*YYINITDEPTH

        
        lexer_pos = 0
        lexer_end = len(text)
        lexer_state = INITIAL
        lexer_last = 0
        yylval = ''

        yyline = 1
        yycolumn = 1
        
        yystate = 0
        yychar = YYEMPTY        # cause a token to be read
        
        # Initialize stack pointers
        # Waste one element of value and location stack
        # so that they stay on the same level as the state stack.
        # The wasted elements are never initialized.
        state_ptr = -1
        value_ptr = 0
        
        while 1:
            # Push a new state, which is found in yystate.
            # In all cases, when you get here, the value and location stacks
            # have just been pushed.  So pushing a state here evens the stacks.
            state_ptr = state_ptr + 1
            state_stack[state_ptr] = yystate
        
            
            # Do appropriate processing given the current state.
            # Read a lookahead token if we need one and don't already have one.
        
            # First try to decide what to do without reference to lookahead token.
            yyn = action_idx[yystate]
            if yyn == YYFLAG:
                yyn = default_action[yystate]
                if yyn == 0:
                    self.report_error(yystate, yyline, yycolumn, yylval)
                    return 1
                # Do a reduction. yyn is the number of a rule to reduce with.
        
                state_ptr = state_ptr - rhs_size[yyn]
                value_ptr = value_ptr - rhs_size[yyn]
        
                if action_routines[yyn]:
                    yyval = action_routines[yyn](self, value_stack, value_ptr)
                    value_ptr = value_ptr + 1
                    value_stack[value_ptr] = yyval
                else:
                    value_ptr = value_ptr + 1

        
                # Now "shift" the result of the reduction.
                # Determine what state that goes to, based on the state
                # we popped back to and the rule number reduced by.
        
                yyn = derives[yyn] - YYNTBASE
                yystate = goto_idx[yyn] + state_stack[state_ptr]
                if 0 <= yystate <= YYLAST and yycheck[yystate] == state_stack[state_ptr]:
                    yystate = yytable[yystate]
                else:
                    yystate = default_goto[yyn]
                continue
            
            # Not known => get a lookahead token if don't already have one.
        
            # yychar is either YYEMPTY, YYEOF or a valid token in external form
            if yychar == YYEMPTY:
                # Setup line and column numbers
                for ch in yylval:
                    if ch == '\n':
                        yyline = yyline + 1
                        yycolumn = 1
                    else:
                        yycolumn = yycolumn + 1

                ### Lexical analysis ###
                while lexer_last < lexer_end:
                    lexer_pos = lexer_last
                    try:
                        match = patterns[lexer_state].match(text, lexer_pos)
                        matched = reduce(lambda result, item:
                                         item[1] is None and result or item,
                                         match.groupdict().items(),
                                         (None, None))
                    except AttributeError:
                        # comes here when match is none, it is an error anyway
                        self.error('No action found for "%s"' % text[lexer_pos:])

                    lexer_last = lexer_last + len(matched[1])
                    lexer_action = pattern_actions[matched[0]]
                    
                    if lexer_action:
                        lexer_state = lexer_action[0] or lexer_state
                        if len(lexer_action) > 1:
                            yylval = matched[1]
                            yychar = lexer_action[1] or ord(yylval)
                            break
                        else:
                            # Just a state change, reprocess the text
                            lexer_last = lexer_pos
                    else:
                        # throw away matched text and update position
                        for ch in matched[1]:
                            if ch == '\n':
                                yyline = yyline + 1
                                yycolumn = 1
                            else:
                                yycolumn = yycolumn + 1
                    continue
                else:
                    # Reached end of input
                    yychar = YYEOF
            # Convert token to internal form (in yychar1) for indexing tables with

            if yychar <= 0:
                # This means end-of-input.
                yychar1 = 0
            else:
                yychar1 = YYTRANSLATE(yychar)
                yyn = yyn + yychar1

            if yyn < 0 or yyn > YYLAST or  yycheck[yyn] != yychar1:
                # comes here after end of input
                yyn = default_action[yystate]
                if yyn == 0:
                    self.report_error(yystate, yyline, yycolumn, yylval)
                    return None
                # Do a reduction. yyn is the number of a rule to reduce with.
        
                state_ptr = state_ptr - rhs_size[yyn]
                value_ptr = value_ptr - rhs_size[yyn]
        
                if action_routines[yyn]:
                    yyval = action_routines[yyn](self, value_stack, value_ptr)
                    value_ptr = value_ptr + 1
                    value_stack[value_ptr] = yyval
                else:
                    value_ptr = value_ptr + 1

        
                # Now "shift" the result of the reduction.
                # Determine what state that goes to, based on the state
                # we popped back to and the rule number reduced by.
        
                yyn = derives[yyn] - YYNTBASE
                yystate = goto_idx[yyn] + state_stack[state_ptr]
                if 0 <= yystate <= YYLAST and yycheck[yystate] == state_stack[state_ptr]:
                    yystate = yytable[yystate]
                else:
                    yystate = default_goto[yyn]
                continue
            
            yyn = yytable[yyn]
        
            # yyn is what to do for this token type in this state.
            # Negative => reduce, -yyn is rule number.
            # Positive => shift, yyn is new state.
            #   New state is final state => don't bother to shift
            #   just return success.
            # 0, or max negative number => error.
        
            if YYFLAG < yyn < 0:
                yyn = -yyn
                # Do a reduction. yyn is the number of a rule to reduce with.
        
                state_ptr = state_ptr - rhs_size[yyn]
                value_ptr = value_ptr - rhs_size[yyn]
        
                if action_routines[yyn]:
                    yyval = action_routines[yyn](self, value_stack, value_ptr)
                    value_ptr = value_ptr + 1
                    value_stack[value_ptr] = yyval
                else:
                    value_ptr = value_ptr + 1

        
                # Now "shift" the result of the reduction.
                # Determine what state that goes to, based on the state
                # we popped back to and the rule number reduced by.
        
                yyn = derives[yyn] - YYNTBASE
                yystate = goto_idx[yyn] + state_stack[state_ptr]
                if 0 <= yystate <= YYLAST and yycheck[yystate] == state_stack[state_ptr]:
                    yystate = yytable[yystate]
                else:
                    yystate = default_goto[yyn]
                continue
            elif yyn == YYFINAL:
                return value_stack[value_ptr-1]
            elif yyn <= 0:
                # Now it is either 0 or YYFLAG
                self.report_error(yystate, yyline, yycolumn, yylval)
                return None
            
            # Shift the lookahead token.
        
 
            if yychar != YYEOF:
                yychar = YYEMPTY
            
            value_ptr = value_ptr + 1
            value_stack[value_ptr] = yylval
        
            yystate = yyn
            continue
        # should never get here
        return None
        
    def report_error(self, state, line, column, lval):
        ruleno = action_idx[state]
        msg = "parse error at line %d, column %d: matched '%s'" % (
            line, column, lval)
        if YYFLAG < ruleno < YYLAST:
            # Start X at -ruleno to avoid negative indexes in yycheck
            start = ruleno < 0 and -ruleno or 0
            first = 1
            for x in range(start, len(token_names)):
                if (x + ruleno) < len(yycheck) and yycheck[x + ruleno] == x:
                    if first:
                        msg = msg + ", expecting"
                        first = 0
                    else:
                        msg = msg + " or"
                    msg = msg + " '%s'" % token_names[x]
        self.error(msg)
        return
        
    def announce(self, format, *args):
        sys.stderr.write(format % args)
        return

    def error(self, format, *args):
        raise SyntaxError(format % args)

    def print_reduce(self, rule):
        sys.stderr.write("Reducing via rule %d (%s), " % (rule, rule_info[rule]))
        # print the symbols being reduced and their result.
        for token in rhs_tokens[rule]:
            sys.stderr.write("%s " % token_names[token])
        sys.stderr.write("-> %s\n" % token_names[derives[rule]])
        return

    def print_state_stack(self, stack, size):
        sys.stderr.write("state stack now")
        for i in range(size+1):
            sys.stderr.write(" %d" % stack[i])
        sys.stderr.write("\n")
        return

new = Parser

# modules required for action routines

# the action code for each rule
def logical_or_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 42
    logical_or_expr: logical_or_expr OR logical_and_expr
    """
    __val = not not (__stack[__ptr+1] or __stack[__ptr+3])
    return __val

def logical_and_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 57
    logical_and_expr: logical_and_expr AND bitwise_or_expr
    """
    __val = not not (__stack[__ptr+1] and __stack[__ptr+3])
    return __val

def bitwise_or_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 72
    bitwise_or_expr: bitwise_or_expr '|' bitwise_xor_expr
    """
    __val = __stack[__ptr+1] | __stack[__ptr+3]
    return __val

def bitwise_xor_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 87
    bitwise_xor_expr: bitwise_xor_expr '^' bitwise_and_expr
    """
    __val = __stack[__ptr+1] ^ __stack[__ptr+3]
    return __val

def bitwise_and_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 102
    bitwise_and_expr: bitwise_and_expr '&' equality_expr
    """
    __val = __stack[__ptr+1] & __stack[__ptr+3]
    return __val

def equality_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 117
    equality_expr: equality_expr EQ relational_expr
    """
    __val = __stack[__ptr+1] == __stack[__ptr+3]
    return __val

def equality_expr3(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 125
    equality_expr: equality_expr NE relational_expr
    """
    __val = __stack[__ptr+1] != __stack[__ptr+3]
    return __val

def relational_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 140
    relational_expr: relational_expr LT shift_expr
    """
    __val = __stack[__ptr+1] < __stack[__ptr+3]
    return __val

def relational_expr3(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 148
    relational_expr: relational_expr LE shift_expr
    """
    __val = __stack[__ptr+1] <= __stack[__ptr+3]
    return __val

def relational_expr4(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 156
    relational_expr: relational_expr GT shift_expr
    """
    __val = __stack[__ptr+1] > __stack[__ptr+3]
    return __val

def relational_expr5(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 164
    relational_expr: relational_expr GE shift_expr
    """
    __val = __stack[__ptr+1] >= __stack[__ptr+3]
    return __val

def shift_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 179
    shift_expr: shift_expr LSH additive_expr
    """
    __val = __stack[__ptr+1] << __stack[__ptr+3]
    return __val

def shift_expr3(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 187
    shift_expr: shift_expr RSH additive_expr
    """
    __val = __stack[__ptr+1] >> __stack[__ptr+3]
    return __val

def additive_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 202
    additive_expr: additive_expr '+' multiplicative_expr
    """
    __val = __stack[__ptr+1] + __stack[__ptr+3]
    return __val

def additive_expr3(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 210
    additive_expr: additive_expr '-' multiplicative_expr
    """
    __val = __stack[__ptr+1] - __stack[__ptr+3]
    return __val

def multiplicative_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 225
    multiplicative_expr: multiplicative_expr '*' unary_expr
    """
    __val = __stack[__ptr+1] * __stack[__ptr+3]
    return __val

def multiplicative_expr3(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 233
    multiplicative_expr: multiplicative_expr '/' unary_expr
    """
    __val = __stack[__ptr+1] / __stack[__ptr+3]
    return __val

def multiplicative_expr4(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 241
    multiplicative_expr: multiplicative_expr '%' unary_expr
    """
    __val = __stack[__ptr+1] % __stack[__ptr+3]
    return __val

def unary_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 256
    unary_expr: '-' primary_expr
    """
    __val = -__stack[__ptr+2]
    return __val

def unary_expr3(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 263
    unary_expr: '+' primary_expr
    """
    __val = +__stack[__ptr+2]
    return __val

def unary_expr4(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 270
    unary_expr: '!' primary_expr
    """
    __val = not __stack[__ptr+2]
    return __val

def unary_expr5(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 277
    unary_expr: '~' primary_expr
    """
    __val = ~__stack[__ptr+2]
    return __val

def primary_expr1(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 288
    primary_expr: IDENTIFIER
    """
    __val = self.defines.get(__stack[__ptr+1], 0)
    return __val

def primary_expr2(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 294
    primary_expr: INTEGER
    """
    __val = long(__stack[__ptr+1])
    return __val

def primary_expr3(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 300
    primary_expr: DEFINED '(' IDENTIFIER ')'
    """
    __val = self.defines.has_key(__stack[__ptr+3])
    return __val

def primary_expr4(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 309
    primary_expr: DEFINED IDENTIFIER
    """
    __val = self.defines.has_key(__stack[__ptr+2])
    return __val

def primary_expr5(self, __stack, __ptr):
    """
    from Ods/Parsers/Odl/IfExpr.bgen, line 316
    primary_expr: '(' expr ')'
    """
    __val = __stack[__ptr+2]
    return __val

action_routines = [None,
                   None,
                   None,
                   None,
                   logical_or_expr2,
                   None,
                   logical_and_expr2,
                   None,
                   bitwise_or_expr2,
                   None,
                   bitwise_xor_expr2,
                   None,
                   bitwise_and_expr2,
                   None,
                   equality_expr2,
                   equality_expr3,
                   None,
                   relational_expr2,
                   relational_expr3,
                   relational_expr4,
                   relational_expr5,
                   None,
                   shift_expr2,
                   shift_expr3,
                   None,
                   additive_expr2,
                   additive_expr3,
                   None,
                   multiplicative_expr2,
                   multiplicative_expr3,
                   multiplicative_expr4,
                   None,
                   unary_expr2,
                   unary_expr3,
                   unary_expr4,
                   unary_expr5,
                   primary_expr1,
                   primary_expr2,
                   primary_expr3,
                   primary_expr4,
                   primary_expr5,
                   ]

# start condition definitions for the lexer
INITIAL = 1

# the expressions and information for each rule
import re
patterns = {
    INITIAL : re.compile('(?P<p00>&&)|(?P<p01>\\|\\|)|(?P<p02>=)|(?P<p03>!=)|(?P<p04><)|(?P<p05><=)|(?P<p06>>)|(?P<p07>>=)|(?P<p08><<)|(?P<p09>>>)|(?P<p10>\\d+(L|l)?)|(?P<p11>defined)|(?P<p12>[a-zA-Z_][\\w_]*)|(?P<p13>\\s+)|(?P<p14>.)', re.M),
}
pattern_actions = {
    'p00' : (None, AND),
    'p01' : (None, OR),
    'p02' : (None, EQ),
    'p03' : (None, NE),
    'p04' : (None, LT),
    'p05' : (None, LE),
    'p06' : (None, GT),
    'p07' : (None, GE),
    'p08' : (None, LSH),
    'p09' : (None, RSH),
    'p10' : (None, INTEGER),
    'p11' : (None, DEFINED),
    'p12' : (None, IDENTIFIER),
    'p13' : None,
    'p14' : (None, None),
}
if __name__ == '__main__':
    import sys
    try: import readline
    except: pass

    try:
        import IfExprc
        parser = IfExprc.new(1)
        print 'Using C parser'
    except:
        import IfExpr
        parser = IfExpr.new(1)
        print 'Using Python parser'

    if len(sys.argv) > 1:
        result = parser.parse(sys.argv[1])
        result.pprint()
        raise SystemExit()
    print 'Use <Ctrl>-C to exit.'
    try:
        while 1:
            expr = raw_input('>>>')
            result = parser.parse(expr)
            result.pprint()
    except KeyboardInterrupt:
        raise SystemExit
