Skip to main content

A low level turing-complete interpreter for YAML

Project description

YIPL

YIPL pronounced Yip-el is a turing-complete interpreted language using YAML as it's syntax, made for Hackclub Horizons.

Quick start

  1. In your terminal of choice type pip install yipl
  2. Create a YAML file with your code (example code below)
print:
  - Hello World!
  1. Run yipl <file.yaml>

AI Disclaimer for hackclub

No AI was used :)

Maybe Helpful Links

Syntax

General rules

Key names

Because of YAML's inherent structure, every key must be unique. YIPL allows any keyword to be appended by text with a leading space. Examples include:

  • print 1:
  • set main variable
  • if a and b are equal

Truthiness

YIPL uses the same truthiness values as Python when using logical operators.

Falsy values: False, None, 0, 0.0, "" (empty string), [] (empty list), {} (empty dict)

Truthy values: Everything else

Function nesting

YIPL allows the nesting of functions to allow for more complex functions than the basic keywords. Some examples include:

Greater than or equal

or:
  - greater:
    - $a
    - $b
  - equality:
    - $a
    - $b

Modulo ($a mod $b)

minus:
  - $a
  - multiply:
    - $b
    - cast:
      - int
      - divide:
        - $a
        - $b

Increment by $b

set:
  - $a
  - plus:
    - $a
    - $b

Keywords

YIPL posesses 17 unique keywords, all listed below.

Comparisons

Equality

a == b

Takes two variables, outputs bool if exactly the same

equality:
  - a
  - b

Greater than

a > b

Takes two int or floats, outputs bool if a is greater than b (not equal to)

greater:
  - a
  - b

Less than

a < b

Takes two int or floats, outputs bool if a is less than b (not equal to)

less:
  - a
  - b

Or

a or b

Takes two bools or comparisons, outputs bool if a or b is True

or:
   - a
   - b

And

a and b

Takes two bools or comparisons, outputs bool if a and b is True

and:
  - a
  - b

Not

not a

Takes one bool or comparisons, outputs the opposite boolean literal

not:
  - a

Conditionals

if a == True:
    print("Yes")
elif a == False:
    print("No")
else:
    print("something else")

If / Goto:

Takes one bool or comparison, jumps to the name of the second entry if true, the third entry if false (think ASM). Every term is required.

Both branching functions require tags to jump to, they will not jump to a function.

if_1:
  - equality:
    - a
    - True
  - print_1
  - if_2
print_1:
  - Yes
goto_1:
  - <code>
if_2:
  - equality:
    - a
    - False
  - print_2
  - print_3
print_2:
  - No
goto_2:
  - <code>
print_3:
  - something else
goto_3:
  - <code>

Arithmetic

All of YIPL's arithmetic only works on two values at a time; a + b + c in one function is not possible in YIPL

a + b

a - b

a * b

a / b

Addition:

Returns the sum of two ints or floats as an int or float

Subtraction:

Returns the difference of two ints or floats as an int or float

Multiplication:

Returns the product of two ints or floats as an int or float

Division:

Returns the Quotient of two ints or floats as an int or float

plus:
  - a
  - b

minus:
  - a
  - b

multiply:
  - a
  - b

divide:
  - a
  - b

Variables

variables are made by prepending a string with $. They do not need to be put in quotes When using set:, the $ is optional

filler_word = "Foobar"
set:
  - $filler word
  - Foobar

I/O

Print:

print(a)

Prints the given data to the terminal

print:
  - a

Set:

input(a)

Returns the typed value as a str. a is the prompt displayed in the terminal/

input:
  - a

Cast:

int(a)
str(b)
float(c)

Returns argument b as the type a

Supported types:

  • int
  • str
  • float
cast:
  - int
  - $a

cast:
  - str
  - $b

cast:
  - float
  - $c

List operations

YIPL posesses multiple operations to be done on a list object. To make a list, use [] like python in the second field of set:

set:
  - $a
  - [a, b, c]

makes a variable $a with the contents [a, b, c]

All operations on lists are done in the list: function, with the first argument being which one to use. Currently implemented functions are:

  • length
  • read
  • delete
  • append
  • replace
list:
  - length
  - $a

Returns the length of the list $a as an int. Equivialent to len(a) in python

list:
  - read
  - $a
  - $b

Returns the item at index $b of list $a. Equivialent to a[b]

list:
  - delete
  - $a
  - $b

Removes the item at index $b of list $a. Equivialent to del a[b]

list:
  - append
  - $a
  - $b

Appends $b to list $a. Equivialent to a.append(b)

list:
  - replace
  - $a
  - $b
  - $c

Replaces the item at index $b of list $a with $c. Equivialent to a[b] = c

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

yipl-1.0.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

yipl-1.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file yipl-1.0.2.tar.gz.

File metadata

  • Download URL: yipl-1.0.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for yipl-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e2add7b054fb97ff8d0ff22da84688e172b788b14b24f448290c75ba06049b07
MD5 7d5c3c697bfa5a61e3430a3be1532bb6
BLAKE2b-256 20a2d02cd81a201dd49a00563b4b3b44fc48edd6e41fa262fcae1e690ed2d381

See more details on using hashes here.

File details

Details for the file yipl-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: yipl-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for yipl-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a6742a1e83615a44c76565e23b3cfafca66a1b63f82c6b55e6461f90e30979db
MD5 c0803234485cab83aee16f0c274a5202
BLAKE2b-256 3763a32205387a9a587c4aa3d57ff8fdc546cd47de9611b9edf703b108c7dc67

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