Skip to main content

A programming language that only uses emojis as syntax.

Project description

spamoji

A programming language that only uses emojis as syntax and encourages writing spaghetti code.

Example

🗒️ A function to calculate factorial
⚙️ 🔢❕🫸🔰🫷
    👋 🏁 🫴 1
    🔃 🔰 🤜 1
        🏁 🫴 🏁 ✖️ 🔰
        🔰 🫴 🔰 ➖ 1
    ↩️ 🏁

💭🫸🔤Enter a number to calculate the factorial: 🔤🫷
👋 😀 🫴 🔢🫸⌨️❗🫷
🤔 😀 🟰 ⚠️
👍
    💬🫸🔤Invalid input.🔤🫷
👎
    💬🫸🔤The factorial of 🔤😀🔤 is 🔤🫸🔢❕🫸😀🫷🫷🫷

What's this all about?

This language is a learning project. Since it lacks many features of a typical programming language, it is not recommended for production use. If this experiment is successful, I might move on and begin working on Esore, a more serious language I've been designing in the past 2 years.

Installation

To install the spamoji interpreter, you will need to have Python 3.10 or higher installed on your machine. You can download Python from the official website.

Once you have Python installed, you can install the spamoji interpreter using pip:

pip install spamoji

Usage

To run a spamoji program, you will need to use the spamoji interpreter.

You can provide a spamoji file (with the .🍝 extension) as input to run it. For example:

spamoji my_program.🍝

If no file is supplied, the interactive REPL will start, which allows to enter and evaluate expressions directly.

If the above command doesn't work, you can also run the interpreter using Python's -m flag:

python -m spamoji my_program.🍝

Syntax

[!IMPORTANT] The emojis used in the syntax were entered on a Windows machine. While they should work on other platforms, some emojis might not render correctly or might be replaced with different emojis. If you encounter any issues, please try copying and pasting the emojis from this documentation into your code.

Statements

Each line of code starts with an emoji that indicates the type of statement. Each statement is followed by the relevant information, separated by spaces. Statements include:

  • 🗒️ Comment: Text in this line will be ignored
  • 👋 Variable declaration: Followed by the variable assignment
  • 🤔 If statement: Followed by the condition
    • 👍 If true block
    • 👎 Else block
  • 🔃 Loop: Followed by the loop variable and condition
    • ⛔ Break statement: Used to exit the loop
    • ⤴️ Continue statement: Used to skip to the next iteration of the loop
  • ⚙️ Function definition: Followed by the function name and parameters
    • ↩️ Return statement: Followed by the value to return

Some statements can be nested, such as if statements and loops. Indentation is used to indicate the scope of these statements. Indented blocks are considered part of the previous statement until the indentation level decreases. Variables declared inside of a block are only accessible inside of that block and any nested blocks.

Functions

Functions are defined using the ⚙️ emoji, followed by the function name and parameters. The function body is indented and can contain any valid statements. The function can return a value using the ↩️ emoji.

Functions can be called by using their name followed by the arguments, separated by 🔸, between 🫸 and 🫷. Functions with no arguments can also be called with the ❗ emoji.

Here's an example of a function definition and call:

⚙️ greetAndAsk 🫸firstName 🔸 lastName🫷
    💬🫸🔤Hello, 🔤firstName🔤 🔤lastName🔤! Please enter a number...🔤🫷
    ↩️ ⌨️❗  🗒️ Return the user input

greetAndAsk🫸🔤John🔤 🔸 🔤Doe🔤🫷

Variables

Variables are declared using the 👋 emoji, followed by the variable assignment expression. An assinment expression starts with the variable name, followed by 🫴 and a value. Variable names can be any combination of letters, numbers, and emojis, but must start with a letter or emoji. Variables can be used in expressions and statements after they have been assigned.

Expressions

Many statements can be used as expressions within other statements. 🫸 and 🫷 can be used to group expressions and control the order of evaluation. For example, you can use a function call as part of an if statement condition or as part of a variable assignment.

Operators

The language supports basic operators for logical and arithmetic operations. These can be used between two values to perform calculations.

  • ➕: Addition
  • ➖: Subtraction
  • ✖️: Multiplication
  • ➗: Division
  • 🟰: Equal
  • 🆚: Not equal
  • 🤜: Greater than
  • 🤛: Less than
  • 🤝: Logical AND
  • 🤲: Logical OR
  • 🙅: Logical NOT

Strings

Strings are sequences of characters enclosed in 🔤 on each side. They can contain any characters, including emojis. Strings can be used in variable assignments, printed to the console, and concatenated using the ➕ operator.

Values directly before or after a string will also be concatenated with that string.

Built-ins

The language includes several built-in functions and values for common operations, such as:

  • 💬: Print output to a new line in the console
  • 💭: Print output to the console
  • ⌨️: Get user input from the console
  • ⏳: Wait for a specified number of seconds
  • 🔢: Convert input to a number, return ⚠️ if the conversion fails
  • 🎲: Get a random integer between 2 numbers
  • 🛑: Stop the program
  • ✅: A special value representing true
  • ❌: A special value representing false
  • 🫥: A special value representing null
  • ⚠️: A special value representing an error or undefined value
  • 🐍: Evaluate a Python expression

Credits

Thanks to Robert Nystrom for his book "Crafting Interpreters" which inspired the design of this language and provided guidance on how to implement it.

Also thanks to Hack Club for providing a supportive community and motivating me to work on this project.

This documentation was entirely written by hand. AI tools were used for assistance while writing the interpreter.

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

spamoji-0.1.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

spamoji-0.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file spamoji-0.1.0.tar.gz.

File metadata

  • Download URL: spamoji-0.1.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for spamoji-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b99000480a5023e6e8079ce7ecfe28d56bfe6e2f63bcd26e5ac5b165bdf1b849
MD5 cc46b059a004eaab2d760211e2cd5b54
BLAKE2b-256 bb2d236acaddaaeeda2b8268db2e8fefe604af35c54cc8e3f508b3912b13a616

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spamoji-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for spamoji-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7af5aac465e8f7a101e853b80e88736e6211b4132bc0a104b88c9fc8a7cafe49
MD5 9714973a348da289c82c2b18bacc4758
BLAKE2b-256 efa78e6bbec5115c1df92390aaf3ece9064fc996804d79a941006de99103ff8f

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