diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 71602d3..9d723bb 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -6,6 +6,15 @@ reStructuredPython Changelog Major release 1 --------------- +.. raw:: html + +
+ 1.1.0 + +
+ .. raw:: html
diff --git a/docs/source/conf.py b/docs/source/conf.py index 90a24f4..b8a4c78 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -10,7 +10,7 @@ copyright = '2025, Rihaan Meher' author = 'Rihaan Meher' -release = '1.0.0' +release = '1.1.0' html_favicon = "_static/icon.png" # -- General configuration --------------------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 73de512..c9f1d6f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,12 +12,17 @@ To begin using reStructuredPython, install the compiler via pip: pip install --upgrade restructuredpython -After installation, you can compile your .repy files using the following command: +After installation, you can compile your .repy files to .py using the following command: .. code-block:: shell repy path/to/your/file.repy +Or you can directly run .repy programs via the ``repycl`` command if using 1.1.0+ +.. code-block:: shell + + repycl path/to/your/file.repy + Features -------- diff --git a/docs/source/roadmap.rst b/docs/source/roadmap.rst index 7470e7c..ed94126 100644 --- a/docs/source/roadmap.rst +++ b/docs/source/roadmap.rst @@ -1,16 +1,7 @@ Roadmap ======= -1.0.0 ------ - -Enhance reStructuredPython ``include`` function to allow for new decorators that will be implemented as built-in to the reStructuredPython compiler. - -Expected release dates: - -03/16/2025 - 03/18/2025 - -1.1.1 +1.2.0 ----- Possibly add built-in functions, not only decorators. This will definetly happen, we just aren't sure if it will happen in 1.1.1 diff --git a/pyproject.toml b/pyproject.toml index 359e5b2..6d6221a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,17 +4,19 @@ build-backend = "setuptools.build_meta" [project] name = "restructuredpython" -version = "1.0.0" +version = "1.1.0" description = "A superset of Python with js-like syntax" authors = [{name = "Rihaan Meher", email = "meherrihaan@gmail.com"}] license = {text = "MIT"} classifiers = [ "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] [project.scripts] repy = "restructuredpython.restructuredpython:main" +repycl = "restructuredpython.restructuredpython:launch" + diff --git a/restructuredpython.egg-info/PKG-INFO b/restructuredpython.egg-info/PKG-INFO index 2f5c3f1..8b05a45 100644 --- a/restructuredpython.egg-info/PKG-INFO +++ b/restructuredpython.egg-info/PKG-INFO @@ -1,11 +1,11 @@ -Metadata-Version: 2.2 +Metadata-Version: 2.4 Name: restructuredpython -Version: 1.0.0 +Version: 1.1.0 Summary: A superset of Python with js-like syntax Author-email: Rihaan Meher License: MIT Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.9 -Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.19 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 +Classifier: Programming Language :: Python :: 3.13 diff --git a/restructuredpython.egg-info/entry_points.txt b/restructuredpython.egg-info/entry_points.txt index c054618..ced7f1c 100644 --- a/restructuredpython.egg-info/entry_points.txt +++ b/restructuredpython.egg-info/entry_points.txt @@ -1,2 +1,3 @@ [console_scripts] repy = restructuredpython.restructuredpython:main +repycl = restructuredpython.restructuredpython:launch diff --git a/restructuredpython/restructuredpython.py b/restructuredpython/restructuredpython.py index 2b4103a..116f945 100644 --- a/restructuredpython/restructuredpython.py +++ b/restructuredpython/restructuredpython.py @@ -3,6 +3,7 @@ import sys import os import warnings +import tempfile from pathlib import Path token_specification = [ @@ -231,6 +232,16 @@ def process_includes(code, input_file): return header_code, code_without_includes +def execute_code_temporarily(code): + with tempfile.TemporaryDirectory() as tmpdir: + temp_file_path = os.path.join(tmpdir, "compiled_repy.py") + with open(temp_file_path, 'w') as temp_file: + temp_file.write(code) + try: + exec(open(temp_file_path).read(), {"__name__": "__main__"}) + except Exception as e: + print(f"Error during execution: {e}") + print(f"You can view the generated file at {(temp_file_path)}") def main(): parser = argparse.ArgumentParser(description="Compile REPY files.") @@ -258,8 +269,38 @@ def main(): with open(output_file, 'w') as f: f.write(final_code) - print(f"Successfully compiled {input_file} to {output_file}") + print(f"Successfully compiled {input_file} to {output_file}") + +def launch(): + parser = argparse.ArgumentParser(description="Preview REPY execution.") + parser.add_argument("filename", help="The REPY file to preview.") + args = parser.parse_args() + + input_file = args.filename + + if not os.path.exists(input_file): + print(f"Error: The file {input_file} does not exist.") + return + + with open(input_file, 'r') as f: + source_code = f.read() + + header_code, code_without_includes = process_includes( + source_code, input_file) + + python_code = parse_repython(code_without_includes) + + final_code = header_code + python_code + + # Execute the compiled code directly + try: + execute_code_temporarily(final_code) + except Exception as e: + print(f"Error during execution: {e}") if __name__ == "__main__": - main() + main(1) + +if __name__ == "__launch__": + main(2) \ No newline at end of file