Zeta is a simple, readable programming language with English-like syntax. It is designed to be intuitive for beginners while offering enough expressiveness for educational programming tasks. The language features a clean, keyword-driven syntax that reads like natural language, making it easy to understand and write.
- Variables with
globalandlocalscope: Declare constants withglobalorlocal, and mutate local variables withis now - Arithmetic expressions with standard precedence: Full support for
+,-,*,/,%, and^with proper operator precedence - String literals in curly braces: Write text naturally with
{Hello, World!} - I/O with
tellandask: Output values and read user input with readable keywords - Type checking and constant guarding: Strong type system with INT, DECIMAL, STRING, and BOOL types
- Comments: Single-line comments with
<comment>and multi-line with<<comment>> - Error reporting: Clear syntax and semantic error messages with line and column information
- Java 22 or higher
- Maven 3.8+
Clone the repository and build with Maven:
git clone git@github.com:AliHamzaAzam/Zeta.git
cd Zeta
mvn clean packageThis will compile the project and create an executable JAR at target/Zeta-1.0-SNAPSHOT.jar.
Create a file hello.zeta:
tell {Hello, World!}
Run it:
./zetac hello.zetaOr use the JAR directly:
java -jar target/Zeta-1.0-SNAPSHOT.jar hello.zetaglobal pi is 3.14 <Constant, accessible everywhere>
local radius is 5 <Constant in current scope>
local count is 0
count is now count + 1 <Mutate a local variable>
- INT: Integer numbers (
5,-3,42) - DECIMAL: Floating-point numbers (
3.14,2.5) - STRING: Text in curly braces (
{Hello}) - BOOL: Boolean values (
true,false)
Operator precedence (highest to lowest):
^- Exponentiation (right-associative)*,/,%- Multiplication, division, modulus+,-- Addition, subtraction
Parentheses can be used to override precedence.
tell {The answer is } 42 <Output: The answer is 42>
ask name <Read a line from stdin into 'name'>
<This is a line comment>
global x is 10 <Comments can follow code>
File: examples/01_hello.zeta
tell {Hello, World!}
Expected output:
Hello, World!
File: examples/02_arithmetic.zeta
global pi is 3.14
local radius is 5
local area is pi * radius ^ 2
tell {The area is } area
Expected output:
The area is 78.5
File: examples/03_input.zeta
local name is {Anonymous}
local age is 0
tell {What is your name?}
ask name
tell {How old are you?}
ask age
tell {Hello, } name {. You are } age { years old.}
Expected output (with user input "Alice" and "30"):
What is your name?
Alice
How old are you?
30
Hello, Alice. You are 30 years old.
File: examples/04_scoping.zeta
global max is 100
local count is 0
tell {Max is } max
tell {Count is } count
count is now count + 1
tell {Count is now } count
Expected output:
Max is 100
Count is 0
Count is now 1
File: examples/05_precedence.zeta
local a is 2
local b is 3
local c is 4
local expr1 is a + b * c
local expr2 is (a + b) * c
local expr3 is a ^ b ^ 2
local expr4 is 10 / 3 + 10 % 3
tell {a + b * c = } expr1
tell {(a + b) * c = } expr2
tell {a ^ b ^ 2 = } expr3
tell {10 / 3 + 10 % 3 = } expr4
Expected output:
a + b * c = 14
(a + b) * c = 20
a ^ b ^ 2 = 512
10 / 3 + 10 % 3 = 6
Zeta/
├── docs/ # Documentation
│ ├── language-spec.md # Formal language specification
│ ├── usage.md # Usage guide
│ └── contributor-guide.md # Contribution guidelines
├── examples/ # Example programs
│ ├── 01_hello.zeta
│ ├── 02_arithmetic.zeta
│ ├── 03_input.zeta
│ ├── 04_scoping.zeta
│ └── 05_precedence.zeta
├── src/
│ ├── main/java/org/azaleas/compiler/
│ │ ├── ast/ # AST node classes
│ │ ├── automata/ # NFA/DFA framework (educational)
│ │ ├── cli/ # CLI entry point
│ │ ├── errors/ # Error handling
│ │ ├── interpreter/ # Tree-walking interpreter
│ │ ├── lexer/ # Lexer and preprocessor
│ │ ├── parser/ # Recursive descent parser
│ │ ├── semantic/ # Semantic analyzer
│ │ └── symboltable/ # Symbol table (legacy)
│ └── test/java/org/azaleas/compiler/
│ ├── integration/ # End-to-end tests
│ ├── interpreter/ # Interpreter tests
│ ├── lexer/ # Lexer tests
│ ├── parser/ # Parser tests
│ └── semantic/ # Semantic analyzer tests
├── pom.xml # Maven build configuration
├── zetac # Convenience script to run programs
└── README.md # This file
Run all tests with Maven:
mvn testThe test suite includes:
- Lexer tests: Tokenization accuracy
- Parser tests: Syntax parsing correctness
- Semantic analyzer tests: Type checking and scope validation
- Interpreter tests: Execution correctness
- End-to-end tests: Full compilation pipeline
- Language Specification - Formal grammar, types, and semantics
- Usage Guide - Detailed usage instructions and error messages
- Contributor Guide - Project structure and how to extend the language
Contributions are welcome! To add a new feature or fix a bug:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
mvn test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
To extend the language with a new statement:
- Add an AST node in
src/main/java/org/azaleas/compiler/ast/ - Add parsing logic in
src/main/java/org/azaleas/compiler/parser/Parser.java - Add semantic checks in
src/main/java/org/azaleas/compiler/semantic/SemanticAnalyzer.java - Add execution logic in
src/main/java/org/azaleas/compiler/interpreter/Interpreter.java - Add tests in
src/test/java/org/azaleas/compiler/
This project is licensed under the MIT License.
Zeta was created as an educational programming language to demonstrate compiler construction concepts including lexical analysis, parsing, semantic analysis, and interpretation.