starlight-cli 1.1.19 → 1.1.20

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.
Files changed (2) hide show
  1. package/README.md +280 -66
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,125 +1,339 @@
1
+ # Starlight Language Guide
1
2
 
2
- # Starlight Programming Language
3
+ Welcome to **Starlight Language**, a simple and expressive server-side scripting programming language designed for clarity and flexibility.
3
4
 
4
- Starlight is a lightweight, developer-oriented programming language designed for **server-side scripting, automation, and general-purpose programming**. It combines a clean, readable syntax inspired by JavaScript and Python with powerful runtime features such as async/await, modules, and interactive I/O.
5
+ This guide introduces the core concepts and syntax to help you start writing programs quickly.
5
6
 
6
- **Official Reference:**
7
- https://starlight-programming-language.pages.dev/tutorials
8
7
  ---
9
- ## Error Handling in Starlight
10
8
 
11
- Starlight is designed with **modern, developer-friendly error handling** that clearly explains what went wrong, where it happened, and how to fix it.
9
+ ## 1. Hello World
12
10
 
13
- ### Modern Diagnostic Style
11
+ ```sl
12
+ sldeploy "Hello, world!"
13
+ ```
14
14
 
15
- Starlight errors follow the same diagnostic standards used by modern languages such as JavaScript, Rust, and Python:
15
+ ---
16
16
 
17
- - Clear error message
18
- - Exact **line and column number**
19
- - Source code preview
20
- - Visual caret (`^`) pointing to the error location
21
- - Helpful suggestions when possible
17
+ ## 2. Variables
22
18
 
23
- Example:
19
+ Variables are declared using the `define` keyword.
24
20
 
21
+ ```sl
22
+ define name = "Alice"
23
+ define age = 20
25
24
  ```
26
25
 
27
- Unterminated block
28
- Did you forget to close the block with '}'?
29
- at line 5, column 0
26
+ ### Supported Value Types
27
+
28
+ | Type | Example |
29
+ | ------- | -------------------- |
30
+ | Number | `10`, `3.14` |
31
+ | String | `"hello"` |
32
+ | Boolean | `true`, `false` |
33
+ | Array | `[1, 2, 3]` |
34
+ | Object | `{ "a": 1, "b": 2 }` |
35
+ | Null | `null` |
36
+
37
+ ---
38
+
39
+ ## 3. Output
40
+
41
+ Use `sldeploy` to print values:
30
42
 
43
+ ```sl
44
+ sldeploy name
45
+ sldeploy age
31
46
  ```
32
- ^
47
+
48
+ ---
49
+
50
+ ## 4. Input
51
+
52
+ Use `ask` to read user input:
53
+
54
+ ```sl
55
+ define name = ask("Enter your name:")
56
+ sldeploy "Hello " + name
33
57
  ```
34
58
 
35
- ````
59
+ ---
60
+
61
+ ## 5. Operators
62
+
63
+ ### Arithmetic Operators
36
64
 
37
- This format makes debugging fast and intuitive, even for beginners.
65
+ | Operator | Description |
66
+ | -------- | -------------- |
67
+ | `+` | Addition |
68
+ | `-` | Subtraction |
69
+ | `*` | Multiplication |
70
+ | `/` | Division |
71
+ | `%` | Modulus |
72
+
73
+ Example:
74
+
75
+ ```sl
76
+ define result = 10 + 5 * 2
77
+ ```
38
78
 
39
79
  ---
40
80
 
41
- ### 🧠 Syntax Errors (Parser Errors)
81
+ ### Comparison Operators
82
+
83
+ | Operator | Description |
84
+ | -------- | --------------------- |
85
+ | `==` | Equal |
86
+ | `!=` | Not equal |
87
+ | `<` | Less than |
88
+ | `<=` | Less than or equal |
89
+ | `>` | Greater than |
90
+ | `>=` | Greater than or equal |
91
+
92
+ ---
42
93
 
43
- Syntax errors are detected during parsing and reported before execution begins.
94
+ ### Logical Operators
44
95
 
45
- Features:
46
- - Precise location tracking
47
- - Friendly suggestions
48
- - No Node.js stack traces
49
- - Clean termination
96
+ | Operator | Description |
97
+ | -------- | --------------- |
98
+ | `AND` | Logical AND |
99
+ | `OR` | Logical OR |
100
+ | `??` | Null coalescing |
50
101
 
51
102
  Example:
103
+
104
+ ```sl
105
+ define x = null ?? 10
106
+ ```
107
+
108
+ ---
109
+
110
+ ## 6. Conditional Statements
111
+
112
+ ```sl
113
+ if (age > 18) {
114
+ sldeploy "Adult"
115
+ } else {
116
+ sldeploy "Minor"
117
+ }
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 7. Loops
123
+
124
+ ### While Loop
125
+
126
+ ```sl
127
+ define i = 0
128
+
129
+ while (i < 5) {
130
+ sldeploy i
131
+ i = i + 1
132
+ }
133
+ ```
134
+
135
+ ---
136
+
137
+ ### For Loop
138
+
139
+ ```sl
140
+ for (define i = 0; i < 5; i = i + 1) {
141
+ sldeploy i
142
+ }
143
+ ```
144
+
145
+ ---
146
+
147
+ ### For-In Loop
148
+
149
+ ```sl
150
+ define arr = [10, 20, 30]
151
+
152
+ for x in arr {
153
+ sldeploy x
154
+ }
155
+ ```
156
+
157
+ ---
158
+
159
+ ## 8. Functions
160
+
161
+ ### Function Declaration
162
+
52
163
  ```sl
53
- if true {
54
- sldeploy("This block is never closed")
55
- ````
164
+ func add(a, b) {
165
+ return a + b
166
+ }
167
+ ```
56
168
 
57
- Output:
169
+ ### Function Usage
58
170
 
171
+ ```sl
172
+ define result = add(2, 3)
173
+ sldeploy result
59
174
  ```
60
- Unterminated block
61
- Did you forget to close the block with '}'?
62
- at line 2, column 0
63
175
 
64
- ^
176
+ ---
177
+
178
+ ### Arrow Functions
179
+
180
+ ```sl
181
+ define add = (a, b) => a + b
65
182
  ```
66
183
 
67
184
  ---
68
185
 
69
- ### ⚙️ Runtime Errors (Evaluator Errors)
186
+ ## 9. Arrays
70
187
 
71
- Runtime errors occur during execution and include:
188
+ ```sl
189
+ define arr = [1, 2, 3]
190
+
191
+ sldeploy arr[0]
192
+ ```
72
193
 
73
- * Undefined variables
74
- * Invalid operations
75
- * Logical mistakes
194
+ ### Common Array Operations
76
195
 
77
- Starlight also provides **intelligent name suggestions**:
196
+ | Function | Description |
197
+ | -------- | ------------------- |
198
+ | `push` | Add element |
199
+ | `pop` | Remove last element |
78
200
 
201
+ ```sl
202
+ push(arr, 4)
203
+ pop(arr)
79
204
  ```
80
- Undefined variable: "scroe"
81
- Did you mean "score"?
82
- at line 10, column 5
83
- ^
205
+
206
+ ---
207
+
208
+ ## 10. Objects
209
+
210
+ ```sl
211
+ define user = {
212
+ "name": "Alice",
213
+ "age": 20
214
+ }
215
+
216
+ sldeploy user.name
84
217
  ```
85
218
 
86
219
  ---
87
220
 
88
- ### 🎨 Color-Coded Errors
221
+ ## 11. Slicing
222
+
223
+ ```sl
224
+ define arr = [1, 2, 3, 4, 5]
89
225
 
90
- Errors are color-coded for clarity:
226
+ sldeploy arr[1:4]
227
+ sldeploy arr[0:5:2]
228
+ ```
91
229
 
92
- * **Red** – Fatal syntax or runtime errors
93
- * **Yellow** – Warnings or suggestions
94
- * **White** – Neutral information (source preview, pointers)
230
+ ### Slice Syntax
95
231
 
96
- This ensures errors are readable in all terminals.
232
+ | Format | Description |
233
+ | ------------------ | ------------------ |
234
+ | `[start:end]` | Basic slicing |
235
+ | `[start:end:step]` | Step-based slicing |
97
236
 
98
237
  ---
99
238
 
100
- ### Safe Execution Model
239
+ ## 12. Error Handling
101
240
 
102
- * Execution **stops immediately** on error
103
- * No uncaught exceptions
104
- * No JavaScript stack traces leaked
105
- * Clean exit behavior
241
+ ```sl
242
+ do {
243
+ define x = y
244
+ } track {
245
+ sldeploy "Error occurred"
246
+ }
247
+ ```
106
248
 
107
- This keeps Starlight predictable and safe for learning and production use.
249
+ ---
250
+
251
+ ## 13. Imports
252
+
253
+ ```sl
254
+ import math from "math"
255
+ ```
256
+
257
+ ### Supported Imports
258
+
259
+ | Type | Description |
260
+ | --------------- | --------------------- |
261
+ | `.sl` files | Local modules |
262
+ | Node.js modules | External dependencies |
108
263
 
109
264
  ---
110
265
 
111
- ### Summary
266
+ ## 14. Built-in Functions
112
267
 
113
- Starlight’s error handling is:
268
+ Examples:
114
269
 
115
- * Modern
116
- * Precise
117
- * Beginner-friendly
118
- * Professional-grade
270
+ ```sl
271
+ len([1,2,3])
272
+ upper("hello")
273
+ random(1, 10)
274
+ ```
275
+
276
+ ### Categories
277
+
278
+ | Category | Examples |
279
+ | -------- | ---------------- |
280
+ | String | `upper`, `lower` |
281
+ | Array | `push`, `pop` |
282
+ | Math | `random` |
283
+ | Utility | `len` |
284
+
285
+ ---
286
+
287
+ ## 15. Asynchronous Code
288
+
289
+ ```sl
290
+ define data = await get("https://api.example.com")
291
+ sldeploy data
292
+ ```
293
+
294
+ ---
295
+
296
+ ## 16. Object Construction
297
+
298
+ ```sl
299
+ func Person(name) {
300
+ this.name = name
301
+ }
302
+
303
+ define p = new Person("Alice")
304
+ sldeploy p.name
305
+ ```
306
+
307
+ ---
308
+
309
+ ## 17. Comments
119
310
 
120
- By using caret-based diagnostics and intelligent suggestions, Starlight provides a first-class developer experience from day one.
311
+ ```sl
312
+ # This is a comment
313
+ ```
314
+
315
+ ---
121
316
 
317
+ ## 18. Language Notes
318
+
319
+ | Behavior | Description |
320
+ | ---------------- | --------------------------------- |
321
+ | Undefined values | Treated as `null` |
322
+ | Function return | Defaults to `null` if unspecified |
323
+ | Data structures | Dynamic (arrays and objects) |
324
+ | Error reporting | Includes line and column details |
325
+
326
+ ---
327
+
328
+ ## 19. Next Steps
329
+
330
+ * Explore built-in functions
331
+ * Write small programs
332
+ * Review full syntax reference
333
+ * Experiment with custom scripts
334
+
335
+ ---
122
336
 
337
+ ## Keywords
123
338
 
124
- ## Author and Developer
125
- Dominex Macedon
339
+ starlight language, scripting language, programming language tutorial, interpreter language, CLI scripting, custom language design
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-cli",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "Starlight Programming Language CLI",
5
5
  "bin": {
6
6
  "starlight": "index.js"