-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmkfuncs.py
More file actions
26 lines (23 loc) · 817 Bytes
/
mkfuncs.py
File metadata and controls
26 lines (23 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
import fileinput
import re
definition = ''
state = 0
params = 0
for line in fileinput.input():
if test := re.search(r'^\tpublic\s+(.*)', line):
definition = 'public ' + test.group(1)
state = 1
params = 0
elif (state == 1) and (test := re.search(r'(\w+)\s*\(', line)):
definition = '{0} LESSPARAMS (('.format(test.group(1))
state = 2
elif state == 2:
if re.search(r'^{', line):
if not params: definition += 'VOID_PARAM'
print(f'{definition}));')
state = 0
elif test := re.search(r'^\s*([^;]*)', line):
if (definition[-1:] != '('): definition += ', '
definition += test.group(1)
params = 1