A semantic search engine for source code https://bitshift.benkurtovic.com/
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

parser_test.py 1.0 KiB

12345678910111213141516171819202122232425262728293031323334353637383940
  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;