示例#1
0
def p_for3(p):
    """for : FOR NAME EQ range block
    """
    p[0] = Node("For")
    p[0].iter = p[2]
    p[0].range = p[4]
    p[0].body = p[5]
示例#2
0
def p_for1(p):
    """for : FOR NAME IN load block
    """
    p[0] = Node("ForEach")
    p[0].iter = p[2]
    p[0].list = p[4]
    p[0].body = p[5]
示例#3
0
def p_foreach(p):
    '''foreach : FOR IDENTIFIER IN expr block
                   | FOR vdef IN expr block
    '''
    p[0] = Node('Foreach')
    p[0].iter = p[2]
    p[0].target = p[4]
    p[0].body = p[5].body
示例#4
0
def p_for2(p):
    """for : FOR nameList IN load block
    """
    x = Node("Tuple")
    p[0] = Node("ForEach")
    p[0].iter = x
    p[0].list = p[4]
    p[0].body = p[5]
    p[0].iter.elems = p[2]
示例#5
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