Soplang Logo
Soplang

Soplang Syntax

Learn Soplang syntax, comments, declarations, blocks, strings, and the structure of a program.

Soplang Syntax

Soplang uses Somali words for familiar programming concepts. This guide introduces the syntax for declarations, functions, control flow, and other language features.

Hello World

This program uses the built-in qor() function to print a message.

hello-world.sop

hello-world.sop
qor("Hello, Adduun!")

Structure

Soplang programs use these building blocks:

  • Declarations – door, abn, jajab, qoraal, bool, teed, walax, and madoor
  • Functions – hawl and celi
  • Control flow – haddii, kale, dooro, kuceli, and intay
  • Classes – qaab, dhaxal, cusub, and nafta
  • Error handling and modules – tijaabi/qabo and keen
  • Built-ins – functions such as qor(), gelin(), and nooc()

Curly braces ({}) enclose blocks. Statements execute in sequence.

Comments

Comments are not executed. Soplang supports single-line comments (//) and multiline comments (/* ... */).

comments.sop
// A single-line comment

/*
 A multiline
 comment
*/

qor("Faallooyinka lama fuliyo")  // Comment: an end-of-line comment

Basic Rules

  • Statement separators: one statement per line is the usual style. Semicolons (;) are optional; door x = 1; qor(x); is also valid.
  • Blocks: {} enclose the bodies of conditionals, loops, functions, and classes. Indentation improves readability but does not define blocks.
  • Conditions: haddii, intay, and dooro require parentheses () around their condition or expression.
  • Case sensitivity: magac and Magac are different variable names.
  • Strings: use double quotes ("...") or single quotes ('...'). Plain strings preserve backslashes. Use e"..." for escapes such as \n, or f"...{name}..." for interpolation.
  • Concatenation with +: when either operand is a string, the other value is converted to text.
basic_rules.sop
door a = "Salaan"
door b = 'Salaan'
qor(a == b)                    // run

door Magac = "Ali"
door magac = "Xasan"
qor(Magac + " iyo " + magac)   // Ali iyo Xasan

qor("Tirada: " + 5)            // Tirada: 5

Example Program

This example reads a name and prints a greeting. It combines a function definition, a variable, and built-in functions.

example.sop

example.sop
hawl salaan(magac) {
  qor("Asalaamu calaykum, " + magac)
}

door magaca = gelin("Magacaaga qor: ")
salaan(magaca)

File Extension

Soplang source files use the .sop extension. Run a file from the command line, or experiment in the interactive REPL.

run.sh

soplang file.sop

On this page