Zero Language Support
A Visual Studio Code extension for testing and running Zero programming language - a custom language created for self-learning compiler development.
📚 About This Project
This extension is designed to test a self-written compiler for the Zero programming language. Zero is a simple C-like language created as a learning exercise to understand:
- Lexical analysis and parsing
- Abstract syntax tree (AST) construction
- Semantic analysis and type checking
- Code generation and compilation techniques
- Language tooling integration
🔧 Language Features
Zero is a minimalistic programming language with:
- Data Types:
int8, uint8, int16 (short), uint16 (ushort),int(int32), uint32 (uint), int64 (long), uint64 (ulong), bool
- Control Flow:
if-else statements, while, for, do-while loops
- Functions: User-defined functions with parameters and return values
- Built-in Function: Only
printf() and scanf() is provided as an external function
- C-like Syntax: Familiar syntax for ease of learning
📝 Example Code
Here's a sample Zero program (main.zr):
const int32 MAX = 100;
int x = 10;
// main function
int main()
{
const int MIN = 1;
int sum = Sum(MIN, MAX);
printf("%d + ... + %d is %d.\n", MIN, MAX, sum);
printf("%d! is %d\n", x, Factorial(x));
bool b = true;
if (b)
{
printf("true");
}
else printf("false");
printf("Sqrt(2) is approximately %f\n", Sqrt2(100));
return 0;
}
int Factorial(int x)
{
if (x < 1) return 1;
else return x * Factorial(x - 1);
}
int Sum(int start, int end)
{
int sum = 0;
while (!(start > end))
{
sum += start;
start += 1;
}
return sum;
}
// Newton method to approximate sqrt(2)
double Sqrt2(int iterations)
{
double x = 1.0; // initial guess
int i = 0;
do
{
x = 0.5 * (x + 2 / x);
i++;
}
while (i < iterations);
return x;
}
✨ Extension Features
- File Association: Automatically recognizes
.zr files as Zero language files
- One-Click Execution: Run Zero programs directly from VS Code
- Terminal Integration: Execute programs in VS Code's integrated terminal
- Keyboard Shortcuts: Press
Ctrl+F5 to quickly run your programs
🚀 Getting Started
Prerequisites
- Visual Studio Code
- The Zero compiler (
zeror.exe) is bundled with this extension
Usage
- Create a new file with
.zr extension (e.g., main.zr)
- Write your Zero program (see example above)
- Click the ▶️ Run button in the editor toolbar, or
- Press
Ctrl+F5, or
- Right-click and select "Run Zero File"
The program will execute in VS Code's integrated terminal.
🎯 Compiler Testing
This extension serves as a practical testing environment for the Zero compiler, allowing you to:
- Write test programs quickly
- Execute them with a single click
- View compilation errors and runtime output
- Iterate on compiler improvements efficiently
⚠️ Educational Purpose
Important Note: This is an educational project created for learning compiler development. The Zero language and its compiler are experimental tools designed for:
- Understanding compilation processes
- Testing language design concepts
- Exploring compiler optimization techniques
This is not intended for production use but rather as a practical learning platform.
🛠️ Language Limitations
Currently, Zero language has intentional limitations to keep the compiler implementation focused:
- Single built-in function: Only
printf() and scanf() is available for output
- No standard library: Minimal runtime environment
- Basic type system: Simple data types only
- No advanced features: No classes, modules, or complex data structures
📄 License
This project is developed for educational purposes as part of compiler development studies.
🎓 Learning Resources
This extension demonstrates practical implementation of:
- Language server protocol concepts
- VS Code extension development
- Compiler testing workflows
- IDE integration for custom languages
Perfect for compiler enthusiasts and language design learners! 🚀