Пример #1
0
def p_for(p):
    '''for : FOR IDENTIFIER EQ expr COMMA expr block
               | FOR vdef EQ expr COMMA expr block
    '''
    p[0] = Node('FOR')
    p[0].iter = p[2]
    p[0].start = p[4]
    p[0].step = 1
    p[0].stop = p[6]
    p[0].body = p[7].body 
Пример #2
0
def p_range3(p):
    """range3 : expr COLON expr COLON expr"""
    p[0] = Node("Range")
    p[0].start = p[1]
    p[0].step = p[3]
    p[0].stop = p[5]
Пример #3
0
def p_colonlist(p):
    '''list : LBRACKET expr RCOLON expr RCOLON expr RBRACKET'''
    p[0]=Node('RangeList')
    p[0].start = p[2]
    p[0].step  = p[4]
    p[0].stop  = p[6]
Пример #4
0
def p_rangelist(p):
    '''list : LBRACKET expr RCOLON expr RBRACKET'''
    p[0]=Node('Range')
    p[0].start = p[2]
    p[0].step  = 1
    p[0].stop  = p[4]