aboutsummaryrefslogtreecommitdiff
path: root/src/smp/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/smp/__init__.py')
-rw-r--r--src/smp/__init__.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/smp/__init__.py b/src/smp/__init__.py
new file mode 100644
index 0000000..63cecaf
--- /dev/null
+++ b/src/smp/__init__.py
@@ -0,0 +1,45 @@
+__version__ = "0.0.1"
+import smp.macro_processor
+import smp.builtins
+
+
+def repl():
+ print("=Skaldpress Macro Processor (REPL)")
+ # print(" type \"quit\" to exit");
+ print("NOT IMPLEMENTED")
+ # Intend to use code.InteractiveConsole or code.InteractiveInterpreter
+ # as well as the readline library
+
+
+def read_stdin():
+ import sys
+
+ data = sys.stdin.read()
+ smp = macro_processor.MacroProcessor()
+ res = smp.process_input(data)
+ print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━", file=sys.stderr)
+ print(res)
+
+
+def main():
+ import sys
+
+ if not sys.stdin.isatty():
+ read_stdin()
+ sys.exit(0)
+
+ if len(sys.argv) > 1 and sys.argv[1] == "-":
+ read_stdin()
+ sys.exit(0)
+
+ if len(sys.argv) == 1:
+ repl()
+ sys.exit(0)
+
+ with open(sys.argv[1], "r") as f:
+ file_content = f.read()
+
+ smp = macro_processor.MacroProcessor()
+ res = smp.process_input(file_content)
+ print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━", file=sys.stderr)
+ print(res)