Add compilation infrastructure with ANTLR G4 grammar and C# transpiler#114
Draft
Add compilation infrastructure with ANTLR G4 grammar and C# transpiler#114
Conversation
Co-authored-by: joerivanarkel <98022003+joerivanarkel@users.noreply.github.com>
Co-authored-by: joerivanarkel <98022003+joerivanarkel@users.noreply.github.com>
Co-authored-by: joerivanarkel <98022003+joerivanarkel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] - make the langauge compiled
- define a g4 grammer following the defined grammar in the code
Add compilation infrastructure with ANTLR G4 grammar and C# transpiler
Jul 8, 2025
Collaborator
|
Co-authored-by: joerivanarkel <98022003+joerivanarkel@users.noreply.github.com>
Author
I've implemented both requested changes: ✅ Compile to IL instead of C#: The compiler now generates IL bytecode directly using System.Reflection.Emit instead of C# source code. The ILCompiler creates .NET assemblies that can be executed by the runtime. ✅ ANTLR G4 grammar integration: Added ANTLR support with the existing Pirate.g4 grammar. The compiler now supports an Usage examples: # IL compilation with existing parser
pirate compile simple.pirate -o ./output
# IL compilation with ANTLR G4 grammar parser
pirate compile simple.pirate -o ./output --antlrBoth modes generate Commit: c6ada84 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: joerivanarkel <98022003+joerivanarkel@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements compilation support for the Pirate programming language, fulfilling the requirements to make the language compiled and define a G4 grammar.
🎯 Requirements Fulfilled
Pirate.g4ANTLR grammar following the existing language specifications inGRAMMAR.mdandSYNTAX.md🏗️ Architecture Changes
New Components
ICompilerinterfacepirate compileIntegration
compilecommand🚀 Usage Examples
The language now supports both interpretation and compilation modes:
📝 Sample Transformation
Input (
example.pirate):Generated Output (
example.cs):🎨 Grammar Definition
The
Pirate.g4grammar formally defines the language syntax including:🧪 Testing
Added comprehensive test suite covering:
🔄 Backward Compatibility
This change is fully backward compatible:
run,build,shell) work exactly as beforecompilecommand🎯 Benefits
The Pirate language now offers the flexibility of both scripting and compiled languages, making it suitable for a broader range of development scenarios.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.