diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-30 16:14:45 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-30 16:14:45 +0100 |
| commit | 8d853a3235d37b746508d178b6128380b07ceb57 (patch) | |
| tree | ba26d4b7e9ff1056b11cc83a27e992bc6da3a7d2 | |
| parent | a99c37b0bfba6e820b3cf47593e045123288e15c (diff) | |
feat: Add SPEC.md, working on tests for NeLaunch.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | src/launch/doc/spec/SPEC.md | 83 | ||||
| -rw-r--r-- | src/launch/src/test/iterators.l | 11 |
2 files changed, 94 insertions, 0 deletions
diff --git a/src/launch/doc/spec/SPEC.md b/src/launch/doc/spec/SPEC.md new file mode 100644 index 00000000..2bb919f5 --- /dev/null +++ b/src/launch/doc/spec/SPEC.md @@ -0,0 +1,83 @@ +----------------------------- + +# 0: Basic DSL Rules. + +----------------------------- + +## Comments and Pragmas + +- **Comments**: Lines starting with `#` followed by text are treated as comments or pragmas + ```lcp + # This is a comment + ``` + +- **Pragma directives**: Lines starting with `# --` are pragma directives + ```lcp + # --pragma-test # Marks file as test + # --test-list-apps # Defines a test case + # --test-start # Defines a start test case + ``` + +## Iteration + +- **For loops**: Iterate over collections using begin/end iterator pairs + ```lcp + for <iterator>: (<begin>, <end>) { + <body> + } + ``` + Example: + ```lcp + for it: (apps.begin, apps.end) { + it.print(); + } + ``` + +- **Iterator methods**: Iterators support method calls using dot notation + ```lcp + it.print(); # Call print method on iterator + ``` + +## Event Handlers + +- **When statements**: Define event handlers triggered by specific events + ```lcp + when <event>: (<arguments>) { + <body> + } + ``` + Example: + ```lcp + when start: (apps) { + it (apps); + } + ``` + +## Collections + +- **Collection access**: Collections provide `.begin` and `.end` properties for iteration + ```lcp + apps.begin # Start iterator + apps.end # End iterator + ``` + +## Syntax Rules + +- **Whitespace**: Indentation is used for readability but not syntactically significant +- **Blocks**: Code blocks are delimited by curly braces `{ }` +- **Statements**: End with semicolon `;` or newline +- **Parentheses**: Used for grouping arguments and parameters +- **Colon**: Separates declaration from parameters in control structures + +## Identifiers + +- **Naming**: Identifiers can contain letters, numbers, and underscores +- **Case sensitivity**: Identifiers are case-sensitive +- **Reserved keywords**: `for`, `when`, `it` + +## Types + +- **Collections**: `apps` (application collection) +- **Iterators**: Created via `for` loops or explicit `it()` constructor +- **Events**: `start` (startup event) + diff --git a/src/launch/src/test/iterators.l b/src/launch/src/test/iterators.l new file mode 100644 index 00000000..02edbd54 --- /dev/null +++ b/src/launch/src/test/iterators.l @@ -0,0 +1,11 @@ +# --pragma-test + +# --test-list-apps +for it: (apps.begin, apps.end) { + it.print(); +} + +# --test-start +when start: (apps) { + it (apps); +} |
