Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ reStructuredPython Changelog
Major release 1
---------------

.. raw:: html

<details>
<summary>1.1.0</summary>
<ul>
<li>Added the repycl command, which autocompiles and launches reStructuredPython programs</li>
</ul>
</details>

.. raw:: html

<details>
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------
Expand Down
7 changes: 6 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------

Expand Down
11 changes: 1 addition & 10 deletions docs/source/roadmap.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

8 changes: 4 additions & 4 deletions restructuredpython.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -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 <meherrihaan@gmail.com>
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
1 change: 1 addition & 0 deletions restructuredpython.egg-info/entry_points.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[console_scripts]
repy = restructuredpython.restructuredpython:main
repycl = restructuredpython.restructuredpython:launch
45 changes: 43 additions & 2 deletions restructuredpython/restructuredpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import os
import warnings
import tempfile
from pathlib import Path

token_specification = [
Expand Down Expand Up @@ -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.")
Expand Down Expand Up @@ -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)