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():
|
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(
|
parser = argparse.ArgumentParser(
|
||||||
prog="UCompiler", description="Compiles based on language", epilog="LOL"
|
prog="UCompiler", description="Compiles based on language", epilog="LOL"
|
||||||
)
|
)
|
||||||
@ -200,16 +205,8 @@ def main():
|
|||||||
|
|
||||||
args.tests_dir = args.tests if args.tests else "."
|
args.tests_dir = args.tests if args.tests else "."
|
||||||
|
|
||||||
if file_ext == ".c":
|
SUPPORTED_LANGS[file_ext](file_name, args)
|
||||||
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)
|
|
||||||
|
|
||||||
print(args)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user