Teapot is a statically typed programming language and compiler project written in Python.
The goal of Teapot is to create a simple, readable language while exploring how programming languages work internally, including lexing, parsing, abstract syntax trees, type systems, and compilation.
Currently implemented:
-
Lexer
- Tokenisation of source code
- Keywords, operators, literals, and identifiers
- Error reporting with line and column information
-
Parser
- AST generation
- Variable declarations
- Literal expressions
- Binary expressions
- Unary expressions
-
AST system
- Structured representation of Teapot programs
- Support for future language features such as functions, structs, control flow, and memory management
Teapot source code:
val ui8 a = 5 + 3.
val ui8 b = a + 10.
val str greeting = "Hello " + "World".
val bool enabled = ~True.
The compiler transforms this source code through multiple stages:
Source Code
|
v
Lexer
|
v
Tokens
|
v
Parser
|
v
Abstract Syntax Tree
|
v
Compiler
Teapot is designed around:
- Explicit syntax
- Static typing
- Readable code
- Compiler transparency
- Learning and experimenting with language design
The language includes concepts such as:
- Strongly typed variables
- Signed and unsigned integer types
- References
- Structures
- Functions
- Manual memory management concepts
Teapot is currently in active development.
Current focus:
- Completing the parser
- Expanding expression support
- Adding type checking
- Building the compiler backend
- Developing the standard library
The language is not yet production-ready.
Clone the repository:
git clone https://github.com/Sim20004/teapot-lang.git
cd teapot-langRun the compiler:
python main.pyTeapot source files use:
.tp
Example:
hello.tp
Contributions, suggestions, and discussions are welcome.
If you are interested in language design, compiler development, or experimenting with programming languages, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.