A toy functional programming language
Project description
Toy Language Interpreter
A minimalist Scheme-like programming language interpreter written in Python. This project implements a custom programming language with support for basic arithmetic operations, conditionals, and functional programming concepts.
Features
- Lambda functions and closures
- Basic arithmetic operations
(+, -, *, /) - Comparison operators
(<, >, <=, >=) - Boolean operations
(and, or, not) - Conditional statements
(if) - Local variable bindings
- Comments support
Installation
# Using pip
pip install toy_lang
Quick start
; Hello World
(display "Hello, World!")
; Basic arithmetic
(+ 1 2 3) ; => 6
(* 4 5) ; => 20
; Lambda functions
(lambda (x) (* x x))
; Conditional statements
(if (> 5 3)
"yes"
"no")
Language Features
Arithmetic Operations
- Addition:
(+ 1 2 3) - Subtraction:
(- 10 5) - Multiplication:
(* 2 3 4) - Division:
(/ 10 2)
Comparison Operators
- Less than:
(< 5 10) - Greater than:
(> 10 5) - Less than or equal:
(<= 5 5) - Greater than or equal:
(>= 10 10)
Boolean Operations
- And:
(and #t #f) - Or:
(or #t #f) - Not:
(not #t)
Functions
; Define a function
(lambda (x) (* x x))
; Using begin for multiple expressions
(begin
(define square (lambda (x) (* x x)))
(square 5))
Development
To set up the development environment:
git clone https://github.com/M-krishna/toy_lang.git
cd toy_lang
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toy_lang_fun-0.1.2.tar.gz.
File metadata
- Download URL: toy_lang_fun-0.1.2.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91b6e206e42014b4a6f8f5546e82acf66a0db39bde907ce964ad1fc14dc2e2c1
|
|
| MD5 |
45b34c335fbc9a7755d13dac1625d1df
|
|
| BLAKE2b-256 |
c634e1e1ab1fe08e980cdf05ba5dbb9ceac69f7b572c5e378281aa981329bc6b
|
File details
Details for the file toy_lang_fun-0.1.2-py3-none-any.whl.
File metadata
- Download URL: toy_lang_fun-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3109c61b850ba26c95a1310ea6e234999b8ff5dcc6e3cc87e111a1be2c631da1
|
|
| MD5 |
d56e48c703f6bfc63b92d67126dd95e4
|
|
| BLAKE2b-256 |
cb4b5367e68644413d066b4979600f6751f152d1464f0c885a66a63a07926c00
|