PyForge is a custom Python compiler built using .NET and C#. It provides an interactive shell for real-time Python code execution and supports a variety of commands for enhanced user interaction. PyForge is designed to parse Python code, evaluate expressions, and provide detailed diagnostics to help debug and improve your Python scripts.
- Interactive Python Shell: Directly type and execute Python expressions.
- Parse Tree Visualization: Toggle the visibility of the syntax tree for a detailed understanding of parsing.
- Detailed Diagnostics: Receive detailed error messages and highlights to easily locate and fix issues.
- Command Support: Includes commands for clearing the screen, showing/hiding the parse tree, testing and exiting the compiler.
- Variable Management: Persistent variable states across commands within a session.
- Color-Coded Output: Utilizes different console colors to enhance readability and differentiate output types.
- Language: C#
- Framework: .NET 7.0
- Testing: xUnit.net test suite with MSBuild
-
Clone the repository:
git clone https://github.com/redayzarra/PyForge.git
-
Navigate to the project:
cd PyForge
-
Build the project:
dotnet build
-
Configure PowerShell scripts: To make running the compiler and tests easier, you can add custom functions to your PowerShell profile:
-
Open your PowerShell profile in Notepad:
notepad $PROFILE
-
Add the following functions to the end of the file:
function run-compiler { Set-Location "C:\YOUR\PATH\TO\PyForge\main" clear .\run.bat } function test-compiler { Set-Location "C:\YOUR\PATH\TO\PyForge" clear dotnet build dotnet test .\Tests\Tests.csproj }
-
Save and close Notepad. To load these new functions, restart PowerShell, or reload your profile:
. $PROFILE
-
-
Run the PowerShell functions: Once you've set up the PowerShell functions, you can easily run your compiler or execute the tests with the following commands in PowerShell:
-
To run the compiler:
run-compiler
-
To run the tests:
test-compiler
-
-
To start the compiler, navigate to the main project folder and run the following in the terminal:
run-compiler
-
This will open the interactive shell. You can start typing Python expressions immediately. Use the following commands within the shell:
showTree()
: Show the parse tree of the entered expression.hideTree()
: Hide the parse tree.clear()
,cls
: Clear the console.reset()
: Reset all variables and clear the console.run()
: Rerun the compiler without needing to exit.test()
: Test the compiler using custom tests.
exit()
: Exit the compiler.
Contributions are welcome! If you have suggestions or improvements, please fork the repository and submit a pull request. For major changes or enhancements, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT license. Please see the LICENSE file for details.