Skip to content

Girish-1-Goyal/programming-language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MinLang

A minimal, modern interpreted language with unique syntax and powerful features.

Features

  • Modern Syntax: Clean, readable syntax with unique features
  • Type Safety: Optional types and type hints
  • Functional Features: Pattern matching, pipes, and guards
  • Immutable by Default: Variables are immutable unless explicitly marked as mutable
  • Object-Oriented: Classes with methods and properties
  • Error Handling: Try-catch blocks with pattern matching
  • Standard Library: Built-in functions for common operations
  • REPL: Interactive shell for quick testing
  • File Execution: Run MinLang scripts with .gkg extension

Installation

pip install minlang

Usage

REPL (Interactive Shell)

minlang

Run a Script

minlang script.gkg

Language Features

Basic Syntax

# Variables are declared with @
@x = 10
@name = "MinLang"

# Functions use fn
fn greet name
    return 'Hello, ' + name
end

# Classes use indentation
class Person
    fn new name
        @name = name
    end

    fn greet
        return 'Hello, my name is ' + @name
    end
end

Control Flow

# If-Then-Otherwise
if x > 10 then
    print 'Greater'
otherwise
    print 'Less or equal'
end

# While Loop
while x > 0 do
    print x
    x = x - 1
end

# For Loop
for i in 1..10 do
    print i
end

Pattern Matching

fn process data
    match data
        case [x, y] then
            return x + y
        case {name: n} then
            return 'Hello ' + n
    end
end

Pipes

@result = 10 |> square |> add 5 |> to_str

Examples

Hello World

print 'Hello, World!'

Fibonacci Sequence

fn fib n
    if n <= 1 then
        return n
    otherwise
        return fib(n - 1) + fib(n - 2)
    end
end

for i in 0..10 do
    print fib(i)
end

Class Example

class Counter
    fn new
        @count = 0
    end

    fn increment
        @count = @count + 1
    end

    fn get_count
        return @count
    end
end

@counter = Counter.new
counter.increment
print counter.get_count

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

About

Minimal programming language using python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages