Advertisement
here2share

# py2cpp.py

Jul 14th, 2020
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.49 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3.  
  4. # py2cpp.py # ZZZ
  5.  
  6. zzz = '''
  7. '''
  8.  
  9. zzz = [z.split()[0] for z in zzz.strip().splitlines()]
  10. zzz = '\n'.join(zzz)
  11.  
  12. zzz = zzz + '''
  13.  
  14. '''.strip()
  15.  
  16. escapes = '''
  17. \n
  18. \r
  19. \t
  20. \v
  21. \b
  22. \f
  23. \a
  24. \'
  25. \"
  26. \?
  27. \\
  28. '''
  29.  
  30. inPrecedence = '''
  31. ()
  32. *   /   %
  33. +   -
  34. <   >   <=   >=
  35. ==   !=
  36. &&
  37. ||
  38. '''
  39.  
  40. def p():
  41.     t = zzz
  42.     for z in [',', ';', '\t', '  ']:
  43.         while z in t:
  44.             t = t.replace(z,' ')
  45.     return t
  46.  
  47. def p2():
  48.     p = []
  49.     ttt = zzz
  50.     for z in range(10):
  51.         ttt = ttt.replace(str(z),'\n')
  52.     ttt = ttt.splitlines()
  53.     for t in ttt:
  54.         for z in ['keyword','::',';','()']:
  55.             if z in t:
  56.                 if 40 > len(t) > 3:
  57.                     t = t.strip()
  58.                     if t.endswith(','):
  59.                         t = t[:-1]
  60.                     p.append(t)
  61.                 break
  62.     return '\n'.join(p).replace(';','')
  63.  
  64. zzz = p()
  65. ttt = zzz.replace(' ','\n')
  66.  
  67. zzz = '''
  68. *cmp
  69. #include
  70. #include <algorithm>
  71. #include <array>
  72. #include <assert.h>
  73. #include <atomic>
  74. #include <bitset>
  75. #include <cassert>
  76. #include <ccomplex>
  77. #include <cctype>
  78. #include <cerrno>
  79. #include <cfenv>
  80. #include <cfloat>
  81. #include <cgicc/CgiDefs.h>
  82. #include <cgicc/Cgicc.h>
  83. #include <cgicc/HTMLClasses.h>
  84. #include <cgicc/HTTPHTMLHeader.h>
  85. #include <chrono>
  86. #include <cinttypes>
  87. #include <ciso646>
  88. #include <climits>
  89. #include <clocale>
  90. #include <cmath>
  91. #include <codecvt>
  92. #include <complex.h>
  93. #include <complex>
  94. #include <condition_variable>
  95. #include <csetjmp>
  96. #include <csignal>
  97. #include <cstdalign>
  98. #include <cstdarg>
  99. #include <cstdbool>
  100. #include <cstddef>
  101. #include <cstdint>
  102. #include <cstdio>
  103. #include <cstdlib>
  104. #include <cstring>
  105. #include <ctgmath>
  106. #include <ctime>
  107. #include <ctype.h>
  108. #include <cuchar>
  109. #include <cwchar>
  110. #include <cwctype>
  111. #include <deque>
  112. #include <errno.h>
  113. #include <exception>
  114. #include <fcntl.h>
  115. #include <fenv.h>
  116. #include <float.h>
  117. #include <forward_list>
  118. #include <fstream.h>
  119. #include <fstream>
  120. #include <functional>
  121. #include <future>
  122. #include <initializer_list>
  123. #include <inttypes.h>
  124. #include <iomanip.h>
  125. #include <iomanip>
  126. #include <ios>
  127. #include <iosfwd>
  128. #include <iostream.h>
  129. #include <iostream>
  130. #include <iso646.h>
  131. #include <istream>
  132. #include <iterator>
  133. #include <libgen.h>
  134. #include <limits.h>
  135. #include <limits>
  136. #include <list>
  137. #include <locale.h>
  138. #include <locale>
  139. #include <map>
  140. #include <math.h>
  141. #include <memory>
  142. #include <mutex>
  143. #include <new>
  144. #include <numeric>
  145. #include <ostream>
  146. #include <publib.h>
  147. #include <queue>
  148. #include <random>
  149. #include <ratio>
  150. #include <regex>
  151. #include <scoped_allocator>
  152. #include <set>
  153. #include <setjmp.h>
  154. #include <signal.h>
  155. #include <sstream>
  156. #include <stack>
  157. #include <stdalign.h>
  158. #include <stdarg.h>
  159. #include <stdbool.h>
  160. #include <stddef.h>
  161. #include <stdexcept>
  162. #include <stdint.h>
  163. #include <stdio.h>
  164. #include <stdlib.h>
  165. #include <streambuf>
  166. #include <string.h>
  167. #include <string>
  168. #include <strstrea.h>
  169. #include <strstream>
  170. #include <system_error>
  171. #include <tgmath.h>
  172. #include <thread>
  173. #include <time.h>
  174. #include <tuple>
  175. #include <type_traits>
  176. #include <typeindex>
  177. #include <typeinfo>
  178. #include <uchar.h>
  179. #include <unistd.h>
  180. #include <unordered_map>
  181. #include <unordered_set>
  182. #include <utility>
  183. #include <valarray>
  184. #include <vector>
  185. #include <vector>
  186. #include <wchar.h>
  187. #include <wctype.h>
  188. char ios::fill()
  189. int ios::bad()
  190. int ios::eof()
  191. int ios::fail()
  192. int ios::good()
  193. int ios::precision()
  194. int istream:: peek()
  195. int istream::gcount()
  196. int istream::get()
  197. long ios::flags()
  198. ostream& ostream::flush()
  199. void fstreambase::close()
  200. __DATE__
  201. __FILE__
  202. __LINE__
  203. __TIME__
  204. abort()
  205. abs()
  206. accumulate()
  207. acos()
  208. append()
  209. asin()
  210. assert()
  211. at()
  212. atan()
  213. atof()
  214. atoi()
  215. atol()
  216. back()
  217. back_inserter()
  218. bad()
  219. begin()
  220. bind2nd()
  221. bsearch()
  222. cat()
  223. ceil()
  224. char ios::fill(char c)
  225. chr()
  226. clear()
  227. clearerr()
  228. clock()
  229. close()
  230. cmp()
  231. copy()
  232. cos()
  233. cosh()
  234. cpy()
  235. cube()
  236. derivative()
  237. difftime()
  238. end()
  239. eof()
  240. equal()
  241. equal_to()
  242. erase()
  243. exit()
  244. exp()
  245. extremes()
  246. fabs()
  247. fail()
  248. fclose()
  249. fgetc()
  250. fgets()
  251. fill()
  252. find()
  253. flags()
  254. floor()
  255. flush()
  256. fopen()
  257. fprintf()
  258. fputc()
  259. fputs()
  260. fread()
  261. frequency()
  262. front()
  263. fscanf()
  264. fseek()
  265. ftell()
  266. fwrite()
  267. gcd()
  268. gcount()
  269. get()
  270. getc()
  271. getchar()
  272. getline()
  273. gets()
  274. good()
  275. ignore()
  276. inner_product()
  277. insert()
  278. int getchar()
  279. int ios::precision(int k)
  280. isPalindrome()
  281. isalnum()
  282. isalpha()
  283. iscntrl()
  284. isdigit()
  285. isgraph()
  286. islower()
  287. isprint()
  288. ispunct()
  289. isspace()
  290. istream& istream::get(signed char& c)
  291. isupper()
  292. isvowel()
  293. isxdigit()
  294. labs()
  295. largest()
  296. len()
  297. less()
  298. log()
  299. log10()
  300. long ios::flags(long n)
  301. main()
  302. max()
  303. memchr()
  304. memcmp()
  305. memcpy()
  306. memmove()
  307. memset()
  308. min()
  309. mirror()
  310. open()
  311. peek()
  312. perror()
  313. pop_back()
  314. pow()
  315. precision()
  316. print()
  317. printf()
  318. product()
  319. push_back()
  320. putback()
  321. rand()
  322. reduce()
  323. remove()
  324. reverse()
  325. riemann()
  326. root()
  327. rotate()
  328. set_new_handler()
  329. setw()
  330. sin()
  331. size()
  332. size_t strftime()
  333. sizeof()
  334. sort()
  335. sqrt()
  336. srand()
  337. strcat()
  338. strchr()
  339. strcmp()
  340. strcpy()
  341. strcspn()
  342. strlen()
  343. strncat()
  344. strncmp()
  345. strncpy()
  346. strpbrk()
  347. strrchr()
  348. strspn()
  349. strstr()
  350. strtok()
  351. sum()
  352. swap()
  353. system()
  354. time()
  355. tokenize()
  356. tolower()
  357. toupper()
  358. trap()
  359. void abort()
  360. int m=ios::in
  361. int m=ios::out
  362. int p=filebuf::openprot)
  363. ios::app
  364. ios::ate
  365. ios::in
  366. ios::out
  367. ios::trunc
  368. std::bad_alloc
  369. std::bad_cast
  370. std::bad_exception
  371. std::bad_typeid
  372. std::domain_error
  373. std::exception
  374. std::invalid_argument
  375. std::length_error
  376. std::logic_error
  377. std::out_of_range
  378. std::overflow_error
  379. std::range_error
  380. std::runtime_error
  381. std::string
  382. std::underflow_error
  383. char *asctime(const struct tm *time)
  384. char *ctime(const time_t *time)
  385. char*fgets(char*s int n FILE*p)
  386. char*gets(char*s)
  387. double atof(const char*s)
  388. int atoi(const char*s)
  389. int fclose(FILE*p)
  390. int fgetc(FILE*p)
  391. int fputc(int c FILE*p)
  392. int fputs(const char*s FILE*p)
  393. int fseek(FILE*p long k int base)
  394. int getc(FILE*p)
  395. int(*cmp)(const void *const void*)
  396. long atol(const char*s)
  397. long ftell(FILE*p)
  398. struct tm *gmtime(const time_t *time)
  399. struct tm *localtime(const time_t *time)
  400. time_t mktime(struct tm *time)
  401. time_t time(time_t *time)
  402. void clearerr(FILE*p)
  403. clock_t clock(void)
  404. double acos(double x)
  405. double asin(double x)
  406. double atan(double x)
  407. double ceil(double x)
  408. double cos(double x)
  409. double cos(double)
  410. double cosh(double x)
  411. double difftime(time_t time2 time_t time1)
  412. double exp(double x)
  413. double fabs(double x)
  414. double fabs(double)
  415. double floor(double x)
  416. double floor(double)
  417. double hypot(double double)
  418. double log(double x)
  419. double log(double)
  420. double pow(double double)
  421. double pow(double x double y)
  422. double sin(double)
  423. double sqrt(double)
  424. double tan(double)
  425. int abs(int n)
  426. int abs(int)
  427. int isalnum(int c)
  428. int isalpha(int c)
  429. int iscntrl(int c)
  430. int isdigit(int c)
  431. int isgraph(int c)
  432. int islower(int c)
  433. int isprint(int c)
  434. int ispunct(int c)
  435. int isspace(int c)
  436. int isupper(int c)
  437. int isxdigit(int c)
  438. int tolower(int c)
  439. int toupper(int c)
  440. long labs(long n)
  441. strcat(s1 s2)
  442. strchr(s1 ch)
  443. strcmp(s1 s2)
  444. strcpy(s1 s2)
  445. strlen(s1)
  446. strstr(s1 s2)
  447. void exit(int n)
  448. FILE*
  449. Auto
  450. Bool
  451. Break
  452. CONTENT_LENGTH
  453. CONTENT_TYPE
  454. Case
  455. Catch
  456. Char
  457. Class
  458. Const
  459. Const_cast
  460. Continue
  461. Default
  462. Delete
  463. Do
  464. HTTP_COOKIE
  465. HTTP_USER_AGENT
  466. INT_MAX
  467. INT_MIN
  468. MAX_RAND
  469. NULL
  470. PATH_INFO
  471. QUERY_STRING
  472. REMOTE_ADDR
  473. REMOTE_HOST
  474. REQUEST_METHOD
  475. SCRIPT_FILENAME
  476. SCRIPT_NAME
  477. SEEK_END
  478. SERVER_NAME
  479. SERVER_SOFTWARE
  480. SIGABRT
  481. SIGFPE
  482. SIGILL
  483. SIGINT
  484. SIGSEGV
  485. SIGTERM
  486. Try
  487. alignas
  488. alignof
  489. and
  490. and_eq
  491. append
  492. appending
  493. arg
  494. asm
  495. assign
  496. at
  497. attr
  498. auto
  499. back
  500. begin
  501. bitand
  502. bitaor
  503. bitor
  504. bitset
  505. bool
  506. break
  507. c_str
  508. capacity
  509. case
  510. cassert
  511. catch
  512. cbegin
  513. cctype
  514. cend
  515. char
  516. char16_t
  517. char32_t
  518. cin
  519. class
  520. clear
  521. cmath
  522. compare
  523. compl
  524. complex
  525. concept
  526. const
  527. const_cast
  528. const_iterator
  529. constexpr
  530. continue
  531. copy
  532. cout
  533. crbegin
  534. crend
  535. cstdio
  536. cstdlib
  537. cstring
  538. ctime
  539. data
  540. decltype
  541. default
  542. delete
  543. deque
  544. do
  545. double
  546. dynamic_cast
  547. else
  548. emplace
  549. emplace_backAsm
  550. empty
  551. end
  552. endl
  553. enum
  554. erase
  555. exception
  556. explicit
  557. export
  558. extern
  559. false
  560. find
  561. find_first_not_of
  562. find_first_of
  563. find_last_not_of
  564. find_last_of
  565. float
  566. for
  567. friend
  568. front
  569. get_allocator
  570. goto
  571. if
  572. ifstream
  573. inline
  574. insert
  575. int
  576. iomanip
  577. iostream
  578. istream
  579. istream&
  580. iterator
  581. length
  582. list
  583. long
  584. long double
  585. long int
  586. long long int
  587. main
  588. map
  589. max_size
  590. memchr
  591. memcmp
  592. memcpy
  593. memmove
  594. memset
  595. mutable
  596. namespace
  597. new
  598. noexcept
  599. not
  600. not_eq
  601. npos
  602. nullptr
  603. ofstream
  604. operator
  605. operator[]
  606. or
  607. or_eq
  608. ostream
  609. pair
  610. pop_back
  611. priority_queue
  612. private
  613. protected
  614. public
  615. push_back
  616. rbegin
  617. register
  618. reinterpret_cast
  619. rend
  620. replace
  621. requires
  622. reserve
  623. resize
  624. return
  625. rfind
  626. short
  627. short int
  628. shrink_to_fit
  629. signed
  630. signed char
  631. signed int
  632. signed long int
  633. signed short int
  634. size
  635. size_t
  636. sizeof
  637. stack
  638. start_routine
  639. static
  640. static_assert
  641. static_cast
  642. std
  643. strcat
  644. strchr
  645. strcmp
  646. strcoll
  647. strcpy
  648. strcspn
  649. strerror
  650. string
  651. strlen
  652. strncat
  653. strncmp
  654. strncpy
  655. strpbrk
  656. strrchr
  657. strspn
  658. strstr
  659. strtok
  660. struct
  661. strxfrm
  662. substr
  663. swap
  664. switch
  665. template
  666. this
  667. thread
  668. thread_local
  669. throw
  670. true
  671. try
  672. trytypedef
  673. typedef
  674. typeid
  675. typename
  676. union
  677. unsigned
  678. unsigned char
  679. unsigned int
  680. unsigned long int
  681. unsigned long long int
  682. unsigned short int
  683. using
  684. using namespace cgicc
  685. using namespace std
  686. valarray
  687. vector
  688. virtual
  689. void
  690. volatile
  691. wchar_t
  692. while
  693. xor
  694. xor_eq
  695. xor_eqalignas
  696. '''
  697.  
  698. zzz = p() + ttt
  699.  
  700. zzz = zzz.replace(' (','(')
  701. zzz = zzz.replace('( ','(')
  702. zzz = zzz.replace(' )',')')
  703. zzz = zzz.replace(') ',')')
  704. zzz = zzz.replace('* ','*')
  705. zzz = zzz.splitlines()
  706. zzz = list(set(zzz))
  707. for z in range(len(zzz)):
  708.     for i in ['*']+['(']*3+['()']*6+[':']*6+['__']*12+['#']*15:
  709.         if i in zzz[z]:
  710.             zzz[z] = '@'+zzz[z]
  711. zzz.sort()
  712. # print '\n'.join(zzz).replace('@','')
  713. # print len(zzz)
  714.  
  715. zzz = '''
  716.  
  717. '''.splitlines()
  718. for i in range(len(zzz)):
  719.     if ' // ' in zzz[i]:
  720.         zzz[i] = zzz[i].split(' // ')[0].strip()
  721. zzz = list(set(zzz))
  722. zzz.sort()
  723. # print '"'+'" "'.join(zzz)+'"'
  724. print '\n'.join(zzz)
  725.  
  726. # for my Google search
  727. "cin" "cout" "std" "sqrt" "namespace" "iostream" "const" "void" "float" "break" "catch" "char" "continue" "double" "int" "while" "goto" "case" "class"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement