Skip to main content

A Sanskrit-inspired programming language for concise, expressive code

Project description

🕉️ Mantra Programming Language

A Sanskrit-inspired programming language for concise, expressive code

"कम शब्द, अधिक कार्य" (Less Words, More Work)

Python Version License: MIT GitHub Stars GitHub Forks Issues

📚 Documentation🚀 Quick Start💡 Examples🤝 Contributing


🌟 What is Mantra?

Mantra is a revolutionary programming language that brings the elegance and precision of Sanskrit to modern software development. With intuitive keywords rooted in ancient wisdom, Mantra makes code more readable, expressive, and meaningful.

✨ Key Features

  • 🕉️ Sanskrit-Inspired: Keywords like kriya (function), sthana (variable), prakash (print)
  • 🎯 Concise Syntax: Accomplish more with fewer lines of code
  • 🌍 Unicode Ready: Full support for Sanskrit text and symbols
  • ⚡ Fast & Modern: Built on Python with clean, efficient design
  • 🔧 Developer Friendly: REPL, debugging, and excellent error messages
  • 📱 Cross-Platform: Works seamlessly on Windows, macOS, and Linux

🚀 Quick Start

Installation

# Clone the repository
git clone https://github.com/codecravings/mantra-lang.git
cd mantra-lang

# Install dependencies
pip install -r requirements.txt

# Install Mantra
pip install -e .

Your First Program

Create hello.man:

sthana message = "Namaste, World!"
prakash(message)
prakash("🕉️ Welcome to Sanskrit programming!")

Run it:

python -m mantra hello.man

Try the REPL

python -m mantra --repl
Mantra Programming Language REPL v0.1.0
॥ Om Gam Ganapataye Namaha ॥

mantra> sthana name = "Arjuna"
mantra> prakash("Hello,", name)
Hello, Arjuna
mantra> exit

💡 Examples

🔢 Simple Calculator

kriya add(a, b) {
    gati a + b
}

kriya multiply(a, b) {
    gati a * b
}

prakash("5 + 3 =", add(5, 3))        # Output: 5 + 3 = 8
prakash("6 * 7 =", multiply(6, 7))   # Output: 6 * 7 = 42

🔁 Fibonacci Sequence

kriya fibonacci(n) {
    yadi n <= 1 {
        gati n
    } athava {
        gati fibonacci(n - 1) + fibonacci(n - 2)
    }
}

prakash("fib(10) =", fibonacci(10))  # Output: fib(10) = 55

🌐 Pure Sanskrit Programming

# Variables in Sanskrit
sthana naam = "राम"              # naam = name
sthana ayu = 30                  # ayu = age

# Function in Sanskrit  
kriya namaskar(vyakti) {         # vyakti = person
    prakash("नमस्ते", vyakti + "!")
    gati "नमस्कार पूर्ण"         # "greeting complete"
}

namaskar(naam)                   # Output: नमस्ते राम!

🎮 Control Flow

# Conditional statements
sthana score = 85

yadi score >= 90 {               # yadi = if
    prakash("Grade: A")
} athava yadi score >= 80 {      # athava = else
    prakash("Grade: B") 
} athava {
    prakash("Grade: C")
}

# Loops
sthana count = 1
punar count <= 5 {               # punar = repeat/loop
    prakash("Iteration:", count)
    count = count + 1
}

📚 Language Reference

Keywords

Sanskrit English Meaning Usage
kriya function "action" Define functions
sthana variable "place" Declare variables
yadi if "if/when" Conditional statements
athava else "or/else" Alternative conditions
punar loop "again" Iteration
gati return "path/direction" Return values
saty true "truth" Boolean true
asaty false "untruth" Boolean false
shunya null "void/empty" Null value

Built-in Functions

Sanskrit English Purpose Example
prakash() print() Display output prakash("Hello")
lambh() len() Get length lambh("text")
shabd() str() Convert to string shabd(123)
ank() int() Convert to integer ank("42")

🏗️ Project Structure

mantra-lang/
├── mantra/              # Core language implementation
│   ├── lexer.py        # Tokenizer
│   ├── parser.py       # Parser  
│   ├── interpreter.py  # Interpreter
│   ├── ast_nodes.py    # AST definitions
│   └── cli.py          # Command line interface
├── examples/           # Example programs
│   ├── hello.man      # Hello world
│   ├── calculator.man # Calculator demo
│   └── fibonacci.man  # Fibonacci sequence
├── tests/             # Unit tests
├── docs/              # Documentation
└── README.md          # This file

🧪 Running Tests

# Install test dependencies
pip install pytest

# Run all tests
pytest tests/

# Run specific test
pytest tests/test_basic.py -v

🤝 Contributing

We welcome contributions from developers of all backgrounds! Whether you're interested in:

  • 🐛 Bug fixes
  • New features
  • 📚 Documentation
  • 🌍 Translations
  • 💡 Ideas and suggestions

Getting Started

  1. Fork this repository
  2. Clone your fork: git clone https://github.com/your-username/mantra-lang.git
  3. Create a branch: git checkout -b feature/amazing-feature
  4. Make your changes
  5. Add tests for new features
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to your branch: git push origin feature/amazing-feature
  8. Open a Pull Request

Development Setup

# Clone and setup
git clone https://github.com/codecravings/mantra-lang.git
cd mantra-lang

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install in development mode
pip install -e .[dev]

# Run tests
pytest

Code Style

  • Follow PEP 8 for Python code
  • Use meaningful Sanskrit-inspired names where appropriate
  • Add docstrings for all public functions
  • Include tests for new features

🗺️ Roadmap

Version 0.2.0

  • Enhanced error messages with suggestions
  • VS Code extension with syntax highlighting
  • Package manager (mantra install)
  • Module system for imports

Version 0.3.0

  • GUI framework (yantra system)
  • Web development tools (shakti expressions)
  • Standard library expansion
  • Performance optimizations

Version 1.0.0

  • Production-ready interpreter
  • Complete language specification
  • Comprehensive documentation
  • Community ecosystem

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Sanskrit Language: For inspiring the keywords and philosophy
  • Python Community: For the excellent development tools
  • Contributors: Everyone who helps make Mantra better
  • Ancient Wisdom: For teaching us that simplicity is the ultimate sophistication

📞 Support & Community

🌟 Show Your Support

If you find Mantra useful, please:

  • Star this repository
  • 🍴 Fork it for your own experiments
  • 📢 Share it with friends
  • 🐛 Report bugs you find
  • 💡 Suggest new features

॥ सत्यमेव जयते ॥
Truth alone triumphs

Made with ❤️ and ancient wisdom by @codecravings

⬆ Back to Top

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mantra-lang-0.1.0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mantra_lang-0.1.0-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file mantra-lang-0.1.0.tar.gz.

File metadata

  • Download URL: mantra-lang-0.1.0.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for mantra-lang-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4c39ed9123d23cc1bca7a122a8167916b1d24c9fcfe3749962092a52d8279beb
MD5 9e0094b80fdfa686d2d5e0f1aef6248d
BLAKE2b-256 005194bf9ab30e171a50d99471a35b4b7a6b9a9d8b182ba5d47c82e694a078c3

See more details on using hashes here.

File details

Details for the file mantra_lang-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mantra_lang-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for mantra_lang-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76d6b57230cc8b95728df606ceadcabbf480caf0bb4dd757691dca1400e2c8d7
MD5 86947d876f454602d185b89202d10b51
BLAKE2b-256 25b2e78fc16f1a8a0e19aa18488447f05686e26f2e41baa9d3134e461f1dddcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page