Syntax Basics
Core PriyoScript syntax in a structured, beginner-friendly reference format.
Theory
Syntax is the formal grammar that tells PriyoScript how to read and execute your program. If syntax is valid, the interpreter can understand your intent and run statements in deterministic order. PriyoScript is designed to keep this grammar explicit and readable, so beginners can identify program structure quickly while still writing production-quality logic. In practical terms, syntax defines how you enter a program (monalisa { ... }), how you store data, how you branch and loop, how you define reusable functions, and how you organize code through modules and classes.
Why this matters
Good syntax habits reduce debugging time and make every advanced concept easier to learn.
Syntax Catalog
Basic Structure
| Syntax | Description |
|---|---|
monalisa { ... } | Program entry block. All executable statements start here. |
// comment | Single-line comment. |
/* comment */ | Multi-line comment block. |
Literals and Values
| Syntax | Description |
|---|---|
123, 3.14 | Number literals. |
"mona" | String literal. |
priyoTrue, priyoFalse | Boolean literals. |
priyoEmpty | Null-like empty value. |
Variables and Assignment
| Syntax | Description |
|---|---|
priyoKeep x = 1 | Function-scoped mutable declaration. |
priyoChange x = 1 | Block-scoped mutable declaration. |
priyoPromise x = 1 | Block-scoped immutable binding. |
x = x + 1 | Reassignment (not valid for priyoPromise). |
Expressions and Operators
| Syntax | Description |
|---|---|
a + b, a - b, a * b, a / b | Arithmetic expressions. |
a == b, a >= b, a != b | Comparison expressions. |
a && b, a || b, !a | Logical expressions. |
(a + b) * c | Grouping with precedence control. |
Control Flow
| Syntax | Description |
|---|---|
prakritiIf (...) { ... } | Conditional branch. |
prakritiElseIf (...) { ... } | Additional condition branch. |
prakritiElse { ... } | Fallback branch. |
prakritiCount (...) { ... } | Counted loop. |
prakritiAsLongAs (...) { ... } | While loop. |
prakritiStop, prakritiGoOn | Break/continue style flow control. |
prakritiThink("label") | Debug checkpoint marker for trace. |
Functions
| Syntax | Description |
|---|---|
lisaaTask name(...) { ... } | Function declaration. |
prakritiWait lisaaTask ... | Async function declaration (stage-1). |
priyoGiveBack value | Return from function. |
name(arg) | Function call. |
prakritiPause expr | Await value inside async functions (top-level await supported). |
Concurrency Runtime
| Syntax | Description |
|---|---|
priyoConcurrency.group("label") | Create a structured task group. |
group.run(task, arg1, arg2) | Start a task immediately inside the group. |
group.schedule(25, task, arg1) | Start a task after a delay in milliseconds. |
prakritiPause group.all() | Wait for all tasks in the group. |
group.token() | Get the shared cancellation token. |
token.throwIfCancelled() | Stop cooperatively if the token was cancelled. |
prakritiPause priyoConcurrency.after | Delay and resume later with a value or null. |
Arrays
| Syntax | Description |
|---|---|
[1, 2, 3] | Array literal. |
arr[0] | Index read. |
arr[1] = 9 | Index write. |
arr[1:3] | Slice (range extraction). |
OOP
| Syntax | Description |
|---|---|
lisaaFamily ClassName { ... } | Class declaration. |
priyoCreate ClassName(...) | Instance creation. |
priyoSelf | Current instance reference. |
lisaaInherit Parent | Inheritance from parent class. |
priyoParent(...) | Parent constructor call. |
Modules and Packages
| Syntax | Description |
|---|---|
lisaaBox { ... } | Module declaration boundary. |
lisaaShare symbol | Module export. |
lisaaBring "path": alias | Module import with alias. |
lisaaBring math | Built-in package import. |
Example Programs
Example 1: Basic Output + Variables
monalisa {
priyoKeep name = "mona"
priyoPromise version = "stable"
priyoTell("Hello " + name + " (" + version + ")")
}Expected output:
Hello mona (stable)Example 2: Condition + Loop
monalisa {
prakritiCount (priyoChange i = 1; i <= 3; i = i + 1) {
prakritiIf (i == 2) {
priyoTell("middle")
} prakritiElse {
priyoTell(i)
}
}
}Expected output:
1
middle
3Example 3: Function + Array
monalisa {
lisaaTask sum2(a, b) {
priyoGiveBack a + b
}
priyoKeep nums = [5, 7]
priyoTell(sum2(nums[0], nums[1]))
}Expected output:
12Common mistake
Do not use priyoGiveBack outside a function body.
Practice Check
Concept Check
- Which declaration should you choose for a value that must not be reassigned?
- What is the difference between
arr[1]andarr[1:3]? - Why must executable code be inside
monalisa { ... }?
Related Docs
Last updated on