aboutsummaryrefslogtreecommitdiff
path: root/compilador/main.py
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-11-15 08:08:06 -0600
committerIván Ávalos <avalos@disroot.org>2022-11-15 08:08:06 -0600
commitc78465010691d45f5e5bfa6a36a96800d30962ac (patch)
tree93521b0c9788712823937e4c48212bc02f0b04b5 /compilador/main.py
parenta3097d32c66cbdff04de14481923c7464b0a8a29 (diff)
downloadjavanol-c78465010691d45f5e5bfa6a36a96800d30962ac.tar.gz
javanol-c78465010691d45f5e5bfa6a36a96800d30962ac.tar.bz2
javanol-c78465010691d45f5e5bfa6a36a96800d30962ac.zip
Se elimina código de interfaz y se reorganizan directorios
Diffstat (limited to 'compilador/main.py')
-rw-r--r--compilador/main.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/compilador/main.py b/compilador/main.py
new file mode 100644
index 0000000..c27c107
--- /dev/null
+++ b/compilador/main.py
@@ -0,0 +1,38 @@
+import sys, getopt
+from tkinter import *
+from tkinter import ttk, filedialog
+from lexer import *
+
+class Main:
+ input_file = None
+ output_file = None
+
+ def print_help (self, arg0):
+ print("Uso: % s -i entrada.ñ -o salida.ñ" % arg0)
+ print(" % s -h" % arg0)
+
+ def main(self, argv):
+ try:
+ opts, args = getopt.getopt(argv[1:], "hi:o:", ["input=", "output="])
+ except getopt.GetoptError as err:
+ print(err)
+ print_help(argv[0]);
+ sys.exit(2)
+
+ for o, a in opts:
+ if o == "-h":
+ self.print_help (argv[0])
+ elif o in ("-i", "--input"):
+ self.input_file = a
+ elif o in ("-o", "--output"):
+ self.output_file = a
+ else:
+ assert False, "opción desconocida"
+
+ if self.input_file and self.output_file:
+ with open(self.input_file) as f:
+ data = f.read()
+ Lexer(data).inicio()
+
+if __name__ == "__main__":
+ Main().main(sys.argv)