- Go 97.8%
- Zirric 2.1%
Reviewed-on: #75 Co-authored-by: Valentin Knabel <dev@vknabel.com> Co-committed-by: Valentin Knabel <dev@vknabel.com> |
||
|---|---|---|
| .github | ||
| ast | ||
| cavefile | ||
| cmd/zirric | ||
| compiler | ||
| docs | ||
| examples/project | ||
| lexer | ||
| op | ||
| parser | ||
| pkgmanager | ||
| proposals | ||
| registry | ||
| runtime | ||
| stdlib | ||
| syncheck | ||
| token | ||
| version | ||
| vm | ||
| world | ||
| .gitattributes | ||
| .goreleaser.yaml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| grammar.ebnf | ||
| LICENSE | ||
| README.md | ||
| renovate.json | ||
Zirric
Zirric is an experimental programming language with a reference implementation in Go. The project is in an early stage and offers the essential building blocks of a modern language:
- Lexer, parser, and AST
- Bytecode compiler and virtual machine
- Standard library with prelude types such as
Array,Bool,Int, andString - Package management via
Cavefileand registries - Documentation on syntax, types, and style in
docs/
Language overview
A quick glimpse at core features:
Variables, functions, and data types
let answer = 42
let items = [1, 2, 3]
func greet(name) {
"Hello, " + name
}
data Person {
name
age
}
let alice = Person("Alice", 30)
print(greet(alice.name))
Control flow
Zirric provides both expression and statement variants of if and for.
The examples below use the expression forms, which yield values and can be
nested inside other expressions.
let message = if answer == 42 { "yes" } else { "no" }
for item <- items {
print(item)
}
When only side effects are required, use the statement forms, which run for their effects and produce no value:
if answer == 42 {
print("yes")
} else {
print("no")
}
for item -> items {
print(item)
}
An empty for { } forms an infinite loop, useful for servers or event
processors. It runs forever and only terminates when a break statement is
encountered.
Enums
enum Result {
data Ok { value }
data Err { message }
}
let r = Ok(42)
Annotations
Zirric has no interfaces; instead, annotations attach behaviour and metadata to types and functions. They enable generic code to rely on declared capabilities without a formal interface system:
annotation Countable { length(value) }
@Countable({ v -> v.length })
data Bag {
items
length
}
Here Countable supplies a length implementation, allowing tools to treat
Bag like any other countable collection.
Prerequisites
- Go 1.23 or newer
Getting started
Clone the repository and run the test suite to see the implementation in action:
go test ./...
For more examples and guides, explore the docs/ and stdlib/ directories.
License
This project is licensed under the Mozilla Public License 2.0.