From 8d853a3235d37b746508d178b6128380b07ceb57 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 30 Dec 2025 16:14:45 +0100 Subject: feat: Add SPEC.md, working on tests for NeLaunch. Signed-off-by: Amlal El Mahrouss --- src/launch/doc/spec/SPEC.md | 83 +++++++++++++++++++++++++++++++++++++++++ src/launch/src/test/iterators.l | 11 ++++++ 2 files changed, 94 insertions(+) create mode 100644 src/launch/doc/spec/SPEC.md create mode 100644 src/launch/src/test/iterators.l 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 : (, ) { + + } + ``` + 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 : () { + + } + ``` + 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); +} -- cgit v1.2.3