phasm/phasm/__main__.py
Johan B.W. de Vries 47aabc1691 Replaces type3 with type5
type5 is much more first principles based, so we get a lot
of weird quirks removed:

- FromLiteral no longer needs to understand AST
- Type unifications works more like Haskell
- Function types are just ordinary types, saving a lot of
  manual busywork

and more.
2025-08-04 19:10:29 +02:00

34 lines
725 B
Python

"""
Functions for using this module from CLI
"""
import sys
from .compiler import phasm_compile
from .optimise.removeunusedfuncs import removeunusedfuncs
from .parser import phasm_parse
from .type5.solver import phasm_type5
def main(source: str, sink: str) -> int:
"""
Main method
"""
with open(source, 'r') as fil:
code_py = fil.read()
our_module = phasm_parse(code_py)
phasm_type5(our_module, verbose=False)
wasm_module = phasm_compile(our_module)
removeunusedfuncs(wasm_module)
code_wat = wasm_module.to_wat()
with open(sink, 'w') as fil:
fil.write(code_wat)
return 0
if __name__ == '__main__':
sys.exit(main(*sys.argv[1:])) # pylint: disable=E1120