Skip to main content

No project description provided

Project description

Lungo Programming Language

Lungo is a dynamic programming language created just for fun.

License: MIT PyPI Version Python Versions

Getting Started

Installations:

pip install --upgrade lungo

Usage:

lungo [FILE]

Syntax

You need to define variable with let statement before assignment/reference:

let x = 2;

Assign a previously defined variable:

let x = 0;
x = 42;

Define a function:

func inc(x) {
    return x + 1
}

The last statement in each code block is a result of the block evaluation, so in the previous example return is not necessary:

func inc(x) {
  x + 1
}

Function definitions are just an expressions. The previous line is equivalent to:

let inc = func(x) { x + 1 }

Conditional execution:

if ( x > 0 ) {
  print("Positive")
} elif ( x < 0 ) {
  print("Negative")
} else {
  print("X is 0")
}

while-loop:

let x = 0;
while ( x < 10 ) {
  x = x + 1;
  print(x)
}

for-loop:

for ( x in [1,2,3] ) {
  print(x)
}

Almost everything is expression in Lungo (except for return and let statements):

let x = 10;
let message = if(x > 5) { "big" } else { "small" };
print(message)

Output:

big

Another example:

func hello(value) {
    print("Hello " + value)
};

let who = "world";

hello(while(who.size < 20) { who = who + " and " + who })

Output:

Hello world and world and world and world

NOTE: A bit of syntactic bitterness. In the current implementation each statement in a code block (except for the last one) must be followed by a semicolon ;. So the ; must be present after such expressions as function definitions, for and while-loops, etc. This will be fixed in a future release.

Supported binary operators: +, -, *, /, &&, ||, ==, !=, >, >=, <, <=

Unary operators: !, -

Higher order functions:

func inc(x) {
  x + 1
};

func comp(f, g) {
  func(x) {
    f(g(x))
  }
}

print(comp(inc, inc)(0))

Output:

2

More sophisticated example:

func pair(a, b) {
    func(acceptor) {
        acceptor(a, b)
    }
};

func first(p) {
    p(func(a,b) { a })
};

func second(p) {
    p(func(a,b) { b })
};

let p = pair(1, 2);

print(first(p));
print(second(p));

Output:

1
2

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

lungo-0.1.2.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

lungo-0.1.2-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file lungo-0.1.2.tar.gz.

File metadata

  • Download URL: lungo-0.1.2.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-28-generic

File hashes

Hashes for lungo-0.1.2.tar.gz
Algorithm Hash digest
SHA256 46c9f876d366eed8c844e22e26145b8abee1878f59a025e4cc04a069ac1b608f
MD5 94227b3fe41c7033ba6a0231ac4d328f
BLAKE2b-256 cc98bb86082cb129ebb470a92e531ac649a46089131ae2a98c1c4dd0099704f6

See more details on using hashes here.

File details

Details for the file lungo-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: lungo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.13.0-28-generic

File hashes

Hashes for lungo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1cbb04db69e527b189a1c1c467d4d57eb749465a3b76877be4dceee8b2ef6677
MD5 69555f654a7f94319c37e7a609bae31f
BLAKE2b-256 e58d8272c19e6b4bb648d4b548eaaa2e3537381209a4ee8e03c327f49119a426

See more details on using hashes here.

Supported by

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