Soplang Syntax Basics

Understanding the basic syntax elements of Soplang is the first step to becoming proficient with the language. This guide covers the fundamental building blocks of Soplang code.

Comments

Comments allow you to add notes to your code that are ignored by the interpreter. Soplang supports single-line and multi-line comments:

comments.sop
// This is a single-line comment

/* This is a multi-line comment
   that spans several lines
   and is useful for longer explanations */

qor("Soplang") // You can also place comments at the end of a line

Statements and Blocks

A statement in Soplang is a complete instruction. Statements are typically separated by newlines or semicolons. Blocks of code are enclosed in curly braces :

statements.sop
// Single statements
door magac = "Soplang"
qor(magac)

// Multiple statements on one line (separated by semicolons)
door a = 5; door b = 10; qor(a + b)

// Code blocks
haddii (a > b) {
    qor("A waa ka weyn yahay B")
    a = a - b
} haddii_kalena {
    qor("B waa ka weyn yahay A")
    b = b - a
}

Identifiers and Naming Conventions

Identifiers are names used for variables, functions, classes, etc. In Soplang:

  • Identifiers can contain letters, digits, and underscores
  • Identifiers cannot start with a digit
  • Identifiers are case-sensitive (magac and Magac are different)
  • Reserved keywords (like door, haddii, etc.) cannot be used as identifiers
identifiers.sop
// Valid identifiers
door magac = "Cabdi"
door magac_dheer = "Cabdiraxmaan"
door magac1 = "Caasha"

// Invalid identifiers (would cause errors)
// door 1magac = "Xasan"     // Cannot start with a digit
// door door = "Fadumo"      // Cannot use a reserved keyword

Basic Operators

Soplang provides a variety of operators for performing operations on values:

Arithmetic Operators

arithmetic.sop
door a = 10
door b = 3

qor(a + b)    // Addition: 13
qor(a - b)    // Subtraction: 7
qor(a * b)    // Multiplication: 30
qor(a / b)    // Division: 3.333...
qor(a % b)    // Modulus (remainder): 1
qor(a ^ b)    // Exponentiation: 1000

Comparison Operators

comparison.sop
door a = 10
door b = 3

qor(a == b)    // Equal to: false
qor(a != b)    // Not equal to: true
qor(a > b)     // Greater than: true
qor(a < b)     // Less than: false
qor(a >= b)    // Greater than or equal to: true
qor(a <= b)    // Less than or equal to: false

Logical Operators

logical.sop
door run = true
door been = false

qor(run && run)     // Logical AND: true
qor(run && been)    // Logical AND: false
qor(run || been)    // Logical OR: true
qor(been || been)   // Logical OR: false
qor(!run)           // Logical NOT: false
qor(!been)          // Logical NOT: true

Assignment Operators

assignment.sop
door a = 10     // Basic assignment

a += 5         // Add and assign: a = a + 5
qor(a)         // 15

a -= 3         // Subtract and assign: a = a - 3
qor(a)         // 12

a *= 2         // Multiply and assign: a = a * 2
qor(a)         // 24

a /= 4         // Divide and assign: a = a / 4
qor(a)         // 6

a %= 4         // Modulus and assign: a = a % 4
qor(a)         // 2

Reserved Keywords

Soplang has several reserved keywords that have special meaning in the language:

door
tiro
qoraal
labadaran
haddii
haddii_kale
haddii_kalena
ku_celi
inta_ay
jooji
sii_wad
min
ilaa
howl
soo_celi
isku_day
qabo
fasalka
nafta
ka_dhaxal
cusub
qor
akhri
shey
liis
run
been
waxba

Semicolons

In Soplang, semicolons are optional at the end of statements but required when placing multiple statements on a single line:

semicolons.sop
// Semicolons are optional at the end of a line
door a = 5
door b = 10
qor(a + b)

// Semicolons are required for multiple statements on one line
door x = 1; door y = 2; qor(x + y)

Case Sensitivity

Soplang is a case-sensitive language, which means identifiers with different casing are treated as distinct:

case-sensitivity.sop
door magac = "Aaden"
door Magac = "Hodan"

qor(magac)  // Outputs: Aaden
qor(Magac)  // Outputs: Hodan

// Keywords must be lowercase
// DOOR x = 5   // This will cause an error
// HadDii (true) { }  // This will cause an error