Soplang Syntax Basics
Understanding the basic syntax elements of Soplang is the first step to becoming proficient with this Programming 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:
// 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 :
// 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 abn da = 17 haddii (da >= 20) { qor("Waxaad tahay dhallinyaro") } haddii_kale (da >= 18) { qor("Waad qaan gaadhay") } ugudambeyn { qor("Waad yar tahay") }
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
andMagac
are different) - Reserved keywords (like
door
,haddii
, etc.) cannot be used as identifiers
// 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
Reserved Keywords
Soplang has several reserved keywords that have special meaning in the language:
Semicolons
In Soplang, semicolons are optional at the end of statements but required when placing multiple statements on a single line:
// 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:
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