Dictionary to handle functions instead of beefy if block
This commit is contained in:
parent
d14c0a725c
commit
3a7e2f2af8
17
ucompile
17
ucompile
@ -154,7 +154,12 @@ def c_compile(file_name, args):
|
||||
|
||||
|
||||
def main():
|
||||
SUPPORTED_LANGS = [".c", ".py", ".java", ".hs"]
|
||||
SUPPORTED_LANGS = {
|
||||
".c": c_compile,
|
||||
".py": python_compile,
|
||||
".java": java_compile,
|
||||
".hs": haskell_compile,
|
||||
}
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="UCompiler", description="Compiles based on language", epilog="LOL"
|
||||
)
|
||||
@ -200,16 +205,8 @@ def main():
|
||||
|
||||
args.tests_dir = args.tests if args.tests else "."
|
||||
|
||||
if file_ext == ".c":
|
||||
c_compile(file_name, args)
|
||||
elif file_ext == ".py":
|
||||
python_compile(file_name, args)
|
||||
elif file_ext == ".java":
|
||||
java_compile(file_name, args)
|
||||
elif file_ext == ".hs":
|
||||
haskell_compile(file_name, args)
|
||||
SUPPORTED_LANGS[file_ext](file_name, args)
|
||||
|
||||
print(args)
|
||||
return
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user