starlight-cli 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/index.js +265 -112
- package/package.json +3 -2
- package/src/evaluator.js +131 -79
- package/src/lexer.js +1 -1
- package/src/parser.js +57 -31
- package/src/starlight.js +1 -1
- package/src/program.sl +0 -2
package/README.md
CHANGED
|
@@ -237,7 +237,53 @@ server()
|
|
|
237
237
|
```
|
|
238
238
|
|
|
239
239
|
---
|
|
240
|
+
## Start & Race Statements
|
|
240
241
|
|
|
242
|
+
Starlight includes a **`start` / `race`** control structure similar to JavaScript `switch`, with **fall-through behavior**. The `start` statement evaluates a discriminant expression and executes all `race` clauses **starting from the first match** until the end, unless a `break` is used.
|
|
243
|
+
|
|
244
|
+
### Syntax
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
start (<discriminant>) {
|
|
248
|
+
race (<value>) {
|
|
249
|
+
# body
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
race (<value>) {
|
|
253
|
+
# body
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
- `start` – evaluates the discriminant expression.
|
|
261
|
+
- `race` – each clause is checked; execution starts at the first matching `race` and continues to subsequent races (fall-through).
|
|
262
|
+
- Optional `break` can stop execution early (if implemented).
|
|
263
|
+
|
|
264
|
+
### Example
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
define x = 2;
|
|
268
|
+
|
|
269
|
+
start (x) {
|
|
270
|
+
race (1) { sldeploy("Race 1 executed"); }
|
|
271
|
+
race (2) { sldeploy("Race 2 executed"); }
|
|
272
|
+
race (3) { sldeploy("Race 3 executed"); }
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
sldeploy("Done with start statement");
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Expected Output:**
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
Race 2 executed
|
|
283
|
+
Race 3 executed
|
|
284
|
+
Done with start statement
|
|
285
|
+
|
|
286
|
+
```
|
|
241
287
|
## Why Starlight?
|
|
242
288
|
|
|
243
289
|
Starlight is designed for developers who want:
|