forked from nulang-org/nulang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_ast.py
More file actions
28 lines (23 loc) · 766 Bytes
/
Copy pathpatch_ast.py
File metadata and controls
28 lines (23 loc) · 766 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
27
28
import re
with open('src/ast.rs', 'r') as f:
content = f.read()
# Replace in Lambda
content = re.sub(
r'Lambda \{\n\s*params: Vec<\(String, Option<Type>\)>,\n',
r'Lambda {\n params: Vec<Param>,\n',
content
)
# Replace in LetRec
content = re.sub(
r'LetRec \{\n\s*name: String,\n\s*params: Vec<\(String, Option<Type>\)>,\n',
r'LetRec {\n name: String,\n params: Vec<Param>,\n',
content
)
# Replace in Function
content = re.sub(
r'type_param_constraints: Vec<\(String, TypeVar, Vec<String>\)>,\n\s*params: Vec<\(String, Option<Type>\)>,\n',
r'type_param_constraints: Vec<(String, TypeVar, Vec<String>)>,\n params: Vec<Param>,\n',
content
)
with open('src/ast.rs', 'w') as f:
f.write(content)