44 lines
692 B
Python
Executable File
44 lines
692 B
Python
Executable File
#! /usr/bin/python3
|
|
|
|
import sys
|
|
|
|
from parser import UrlParser
|
|
from printer import print_ast
|
|
|
|
#---
|
|
# fx-92 SC+ interpreter
|
|
#---
|
|
|
|
pass
|
|
|
|
#---
|
|
# Main program
|
|
#---
|
|
|
|
usage_string = f"""
|
|
usage: {sys.argv[0]} <wes.casio.com URL>
|
|
""".strip()
|
|
|
|
def usage(exitcode=None):
|
|
print(usage_string, file=sys.stderr)
|
|
|
|
if exitcode is not None:
|
|
sys.exit(exitcode)
|
|
|
|
def main(argv):
|
|
args = argv[1:]
|
|
|
|
if not args or "-h" in args or "--help" in args or "-?" in args:
|
|
usage(0)
|
|
if len(args) != 1:
|
|
usage(1)
|
|
|
|
parser = UrlParser(args[0])
|
|
ast = parser.parse_program()
|
|
ast = ast.simplify()
|
|
|
|
print_ast(ast, lang="ast")
|
|
|
|
if __name__ == "__main__":
|
|
main(sys.argv)
|