A Python superset with static typing features including interfaces, abstract classes, final modifiers, and more.
Spice/
├── spice-lang/ # Core language implementation (Python package)
│ ├── spice/ # Main package
│ │ ├── lexer/ # Tokenization
│ │ ├── parser/ # AST generation
│ │ ├── compilation/ # Type checking & compilation pipeline
│ │ ├── transformer/ # Spice → Python transformation
│ │ └── cli/ # Command Line handling
│ └── tests/ # Unit tests
├── spice-lsp/ # Language Server Protocol Impl
│ └── spice_lsp/ # LSP server using pygls
├── spice-vscode/ # VSCode extension
│ └── src/ # LSP client + commands
└── examples/ # Example .spc files
The main compiler implementation:
- Lexer: Tokenizes
.spcsource files - Parser: Generates Abstract Syntax Trees (AST)
- Type System: Static type checking with interfaces
- Transformer: Converts Spice code to Python
LSP server that provides IDE features:
- Real-time diagnostics (syntax/type errors)
- Code completion
- Hover information
- Uses the core Spice Lexer/Parser
Minimal extension that:
- Starts the LSP server
- Provides syntax highlighting
- Registers compile/run commands
cd spice-lang
pip install -e .cd spice-lsp
pip install -e .cd spice-vscode
npm install
npm run compileThen press F5 in VSCode to launch the extension development host.
spicy input.spc -o output.pyspice input.spc- Open a
.spcfile - LSP provides:
- Syntax checking (red squiggles)
- Auto-completion (Ctrl+Space)
- Hover info (hover over keywords)
- Commands:
Ctrl+Shift+B: Compile to PythonCtrl+Shift+R: Run file
// Interfaces
interface Drawable {
def draw() -> None;
}
// Abstract classes
abstract class Shape {
abstract def area() -> float;
}
// Final classes (cannot be inherited)
final class Circle extends Shape implements Drawable {
def __init__(self, radius: float) -> None {
self.radius = radius;
}
def area() -> float {
return 3.14 * self.radius ** 2;
}
def draw() -> None {
print(f"Drawing circle with radius {self.radius}");
}
}
// Strict Typing - Anything not directly made with a constructor / primitive requires type inference
myVar = A(); // Will automatically get the A type infered on Transform
or
myVar = 100; // Will automatically be set as int
myNotSetVar = aRandomMethod(); // Will crash at compile time
mySetVar: B = aRandomMethod(); // Will not crash
// And many more planned <3
cd spice-lang
pytestspice-lsp
# Then connect VSCode to stdio- Core language changes →
spice-lang/ - IDE features →
spice-lsp/ - VSCode UI →
spice-vscode/