Ejemplo n.º 1
0
    p[0] = CiscoAsaPort.CiscoAsaPort[p[1]]


def p_port_service2(p):
    '''port_service : NUMBER'''
    p[0] = p[1]


def p_error(p):
    if p:
        print("Syntax error at '%s'" % p.value)
    else:
        print("Syntax error at EOF")

    if p_info['raise_on_error']:
        raise SyntaxError


parser = yacc.yacc(optimize=1)

if __name__ == '__main__':
    while True:
        try:
            s = raw_input('CiscoAsa > ')
        except EOFError:
            break
        if not s: continue
        print s
        result = parser.parse(s + '\n')
        print result
Ejemplo n.º 2
0
 def clear(self):
     self.parser = yacc.yacc()
     self.clear()
Ejemplo n.º 3
0
def p_ip_dst_line_2(p):
    '''ip_dst_line : IP_DST COLON WORD'''
    p_info['current_rule'].ip_dest.append(Operator('EQ', Ip(p[3])))


def p_port_src_line(p):
    '''port_src_line : PORT_SRC COLON WORD'''
    p_info['current_rule'].port_source.append(Operator('EQ', Port(p[3])))


def p_port_dst_line(p):
    '''port_dst_line : PORT_DST COLON WORD'''
    p_info['current_rule'].port_dest.append(Operator('EQ', Port(p[3])))


def p_error(p):
    raise SyntaxError


parser = yacc.yacc(optimize=1)

if __name__ == '__main__':
    while True:
        try:
            s = raw_input('QueryPath > ')
        except EOFError:
            break
        if not s: continue
        print s
        result = parser.parse(s + '\n')
        print result
Ejemplo n.º 4
0
 def __init__(self):
     # Use for construct dictionary of object and object group
     self.parser = yacc.yacc()
     self.object_dict = {}