diff options
author | Qrius <[email protected]> | 2025-02-21 12:51:08 +0100 |
---|---|---|
committer | Qrius <[email protected]> | 2025-02-21 12:51:11 +0100 |
commit | 5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc (patch) | |
tree | 748dc9a19cdc3e9910f832d1a7a1ba81acbe22e9 /src/smp/__init__.py | |
download | skaldpress-5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc.tar.gz skaldpress-5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc.zip |
first version of python rewrite
Diffstat (limited to 'src/smp/__init__.py')
-rw-r--r-- | src/smp/__init__.py | 45 |
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) |