A semantic search engine for source code https://bitshift.benkurtovic.com/
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

41 rinda
1.0 KiB

  1. import socket, sys
  2. file_name = 'resources/<name>.c'
  3. server_socket_number = 5001
  4. if __name__ == '__main__':
  5. if len(sys.argv) == 1:
  6. print "Please input a parser to test."
  7. elif len(sys.argv) > 2:
  8. print "Too many arguments."
  9. else:
  10. if sys.argv[1] == 'c':
  11. pass
  12. elif sys.argv[1] == 'java':
  13. file_name = "resources/Matrix.java"
  14. server_socket_number = 5002
  15. elif sys.argv[1] == 'ruby':
  16. file_name = "resources/<name>.rb"
  17. server_socket_number = 5003
  18. client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  19. client_socket.connect(("localhost", server_socket_number))
  20. with open(file_name, "r") as source_file:
  21. source = source_file.read()
  22. client_socket.send("%d\n%s" % (len(source), source));
  23. data = ''
  24. while True:
  25. data = client_socket.recv(10000)
  26. if data != '':
  27. client_socket.close()
  28. break;
  29. print data;