rm make_exprs.py, moving to the c part
This commit is contained in:
parent
6ff75a0926
commit
727a259638
2 changed files with 0 additions and 60 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
|||
zig-cache/
|
||||
*.mypy_cache*
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
#!/usr/bin/python3.6
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
EXPR_TYPES = {
|
||||
'Binary': ('left: Expr', 'operator: Token', 'right: Expr'),
|
||||
'Grouping': ('expression: Expr',),
|
||||
'Unary': ('operator: Token', 'right: Expr'),
|
||||
|
||||
# NOTE: when adding new Literals, add new Literal types, instead of just
|
||||
# doing Literal with an 'Object value'. it won't work.
|
||||
}
|
||||
|
||||
def _gen_expr_decls():
|
||||
res = []
|
||||
|
||||
for expr_type, expr_params in EXPR_TYPES.items():
|
||||
res.append(f'pub const {expr_type} = struct {{')
|
||||
|
||||
for param in expr_params:
|
||||
res.append(f' {param},')
|
||||
|
||||
res.append('};\n')
|
||||
|
||||
return '\n'.join(res)
|
||||
|
||||
|
||||
def do_base_union(union_name: str):
|
||||
res = [
|
||||
'const Token = @import("token.zig").Token;\n'
|
||||
]
|
||||
|
||||
res.append(_gen_expr_decls())
|
||||
|
||||
res.append(f'pub const {union_name}Type = enum {{')
|
||||
for expr_type in EXPR_TYPES:
|
||||
res.append(f' {expr_type},')
|
||||
res.append('};\n')
|
||||
|
||||
|
||||
res.append(f'pub const {union_name} = union({union_name}Type) {{')
|
||||
|
||||
for expr_type in EXPR_TYPES:
|
||||
res.append(f' {expr_type}: {expr_type},')
|
||||
|
||||
res.append('};\n')
|
||||
|
||||
return '\n'.join(res)
|
||||
|
||||
|
||||
def main():
|
||||
expr_file = Path('./src') / 'expr.zig'
|
||||
expr_file.touch()
|
||||
expr_file.unlink()
|
||||
expr_file.write_text(do_base_union('Expr'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue