inscript-lang 0.6.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ ๏ปฟMIT License
2
+
3
+ Copyright (c) 2026 authorss81
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,450 @@
1
+ Metadata-Version: 2.4
2
+ Name: inscript-lang
3
+ Version: 0.6.0
4
+ Summary: InScript - A modern scripting language with generics, ADT enums, coroutines, and more
5
+ Home-page: https://github.com/authorss81/inscript
6
+ Author: authorss81
7
+ License: MIT
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Software Development :: Interpreters
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: author
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ <div align="center">
27
+
28
+ # ๐ŸŽฎ InScript
29
+
30
+ **A modern programming language designed for games โ€” clean syntax, powerful type system, batteries included.**
31
+
32
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
34
+ [![Tests](https://img.shields.io/badge/tests-122%20passing-brightgreen.svg)](#testing)
35
+ [![Version](https://img.shields.io/badge/version-0.6.0-blue.svg)](#)
36
+
37
+ </div>
38
+
39
+ ---
40
+
41
+ ## What is InScript?
42
+
43
+ InScript is a statically-typed, dynamically-executed scripting language built specifically for game development. It brings Rust-style safety (pattern matching, ADT enums, Result types, generics) with Python-like readability โ€” and runs right out of the box with a single Python file.
44
+
45
+ ```inscript
46
+ // Structs with inheritance and operator overloading
47
+ struct Ship {
48
+ x: float y: float hp: int
49
+
50
+ fn take_damage(amount: int) { self.hp -= amount }
51
+ }
52
+
53
+ struct PlayerShip extends Ship {
54
+ shots: int
55
+ fn fire() -> string {
56
+ self.shots += 1
57
+ return f"๐Ÿ’ฅ Shot #{self.shots}!"
58
+ }
59
+ }
60
+
61
+ // ADT enums with pattern matching
62
+ enum Asteroid {
63
+ Small(x: float, y: float)
64
+ Large(x: float, y: float)
65
+ }
66
+
67
+ fn points(a: Asteroid) -> int {
68
+ match a {
69
+ case Small(x, y) { return 30 }
70
+ case Large(x, y) { return 10 }
71
+ }
72
+ }
73
+
74
+ // Generic data structures
75
+ struct Stack<T> {
76
+ items: T[]
77
+ fn push(item: T) { self.items.push(item) }
78
+ fn pop() -> T { return self.items.pop() }
79
+ }
80
+
81
+ // Error propagation
82
+ fn accuracy(hits: int, shots: int) -> Result {
83
+ let r = safe_divide(float(hits), float(shots))?
84
+ return Ok(r * 100.0)
85
+ }
86
+
87
+ // Coroutines
88
+ fn* spawn_wave(n: int) {
89
+ let i = 0
90
+ while i < n { yield Asteroid.Large(random_int(0,800), 0.0); i += 1 }
91
+ }
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Feature Overview
97
+
98
+ | Feature | Status | Notes |
99
+ |---|---|---|
100
+ | Variables (`let`, `const`) with type annotations | โœ… | Type inference supported |
101
+ | Structs with methods | โœ… | Full OOP |
102
+ | **Struct inheritance** (`extends`) | โœ… | Method dispatch + field inheritance |
103
+ | **Interface / Trait** system | โœ… | `interface` + `implements` |
104
+ | **Operator overloading** (`fn +()`) | โœ… | All arithmetic + comparison ops |
105
+ | **Mixins** (`with` keyword) | โœ… | Horizontal code reuse |
106
+ | **Properties** (`get`/`set`) | โœ… | Computed + validated fields |
107
+ | **Static methods** | โœ… | `static fn` on structs |
108
+ | **Generics** (`struct Stack<T>`) | โœ… | Type-erased, multi-param |
109
+ | **ADT Enums** with data fields | โœ… | `Circle(radius: float)` |
110
+ | **Pattern matching** + guards | โœ… | `case v if v < 10` |
111
+ | **ADT destructuring** | โœ… | `case Circle(r)` binds `r` |
112
+ | **Error propagation** `?` | โœ… | `Ok(v)` / `Err(e)` / `Result?` |
113
+ | **Coroutines / generators** | โœ… | `fn*` + `yield` + `.next()` |
114
+ | **Comptime evaluation** | โœ… | `comptime { 1024 * 4 }` |
115
+ | **Pipe operator** `\|>` (chainable) | โœ… | `x \|> double \|> add1` |
116
+ | **Destructuring** | โœ… | `let [a,b] = arr` / `let {x,y} = p` |
117
+ | **Spread operator** | โœ… | `fn sum(...args)` / `call(...arr)` |
118
+ | **Optional chaining** | โœ… | `obj?.field?.method()` |
119
+ | **Nullish coalescing** | โœ… | `value ?? "default"` |
120
+ | F-strings | โœ… | `f"Hello {name}!"` |
121
+ | Multi-line strings | โœ… | `"""..."""` |
122
+ | Closures / lambdas | โœ… | `\|x\| x * 2` |
123
+ | Async/await syntax | โœ… | |
124
+ | Labeled break/continue | โœ… | `outer: for ... { break outer }` |
125
+ | Built-in math, Vec2, Vec3, Color | โœ… | Game-ready primitives |
126
+ | REPL | โœ… | Interactive shell |
127
+
128
+ ---
129
+
130
+ ## Quick Start
131
+
132
+ ### 1. Clone and run (no install needed)
133
+
134
+ ```bash
135
+ git clone https://github.com/YOUR_USERNAME/inscript.git
136
+ cd inscript
137
+ python inscript.py examples/asteroid_blaster.ins
138
+ ```
139
+
140
+ ### 2. Try the REPL
141
+
142
+ ```bash
143
+ python inscript.py --repl
144
+ ```
145
+
146
+ ```
147
+ InScript 0.6.0 REPL โ€” type 'exit' or Ctrl+C to quit
148
+ >> let x = 42
149
+ >> print(f"The answer is {x}")
150
+ The answer is 42
151
+ >> struct Point { x: float y: float }
152
+ >> let p = Point { x: 3.0, y: 4.0 }
153
+ >> print(p.x)
154
+ 3.0
155
+ ```
156
+
157
+ ### 3. Run any `.ins` file
158
+
159
+ ```bash
160
+ python inscript.py mygame.ins
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Running in VS Code
166
+
167
+ ### Prerequisites
168
+
169
+ - [VS Code](https://code.visualstudio.com/) installed
170
+ - [Python extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python) installed
171
+ - Python 3.10+ on your system (`python --version`)
172
+
173
+ ### Step-by-step
174
+
175
+ **1. Clone the repo and open in VS Code**
176
+ ```bash
177
+ git clone https://github.com/YOUR_USERNAME/inscript.git
178
+ cd inscript
179
+ code .
180
+ ```
181
+
182
+ **2. Set Python interpreter**
183
+
184
+ Press `Ctrl+Shift+P` โ†’ type `Python: Select Interpreter` โ†’ choose Python 3.10+
185
+
186
+ **3. Open the example program**
187
+
188
+ In the Explorer panel, open `examples/asteroid_blaster.ins` to browse the code.
189
+
190
+ **4. Create a run task** โ€” create `.vscode/tasks.json`:
191
+
192
+ ```json
193
+ {
194
+ "version": "2.0.0",
195
+ "tasks": [
196
+ {
197
+ "label": "Run InScript file",
198
+ "type": "shell",
199
+ "command": "python",
200
+ "args": ["${workspaceFolder}/inscript.py", "${file}"],
201
+ "group": {
202
+ "kind": "build",
203
+ "isDefault": true
204
+ },
205
+ "presentation": {
206
+ "reveal": "always",
207
+ "panel": "shared"
208
+ },
209
+ "problemMatcher": []
210
+ },
211
+ {
212
+ "label": "Run example: Asteroid Blaster",
213
+ "type": "shell",
214
+ "command": "python",
215
+ "args": ["${workspaceFolder}/inscript.py", "examples/asteroid_blaster.ins"],
216
+ "group": "build",
217
+ "presentation": {
218
+ "reveal": "always",
219
+ "panel": "shared"
220
+ },
221
+ "problemMatcher": []
222
+ },
223
+ {
224
+ "label": "InScript REPL",
225
+ "type": "shell",
226
+ "command": "python",
227
+ "args": ["${workspaceFolder}/inscript.py", "--repl"],
228
+ "group": "build",
229
+ "presentation": {
230
+ "reveal": "always",
231
+ "panel": "dedicated"
232
+ },
233
+ "problemMatcher": []
234
+ }
235
+ ]
236
+ }
237
+ ```
238
+
239
+ **5. Run it!**
240
+
241
+ - Press `Ctrl+Shift+B` to run the currently open `.ins` file
242
+ - Or open Command Palette โ†’ `Tasks: Run Task` โ†’ choose any task above
243
+
244
+ **Tip:** Add this `launch.json` for F5 debugging too (`.vscode/launch.json`):
245
+
246
+ ```json
247
+ {
248
+ "version": "0.2.0",
249
+ "configurations": [
250
+ {
251
+ "name": "Run InScript (current file)",
252
+ "type": "debugpy",
253
+ "request": "launch",
254
+ "program": "${workspaceFolder}/inscript.py",
255
+ "args": ["${file}"],
256
+ "console": "integratedTerminal"
257
+ }
258
+ ]
259
+ }
260
+ ```
261
+
262
+ Now pressing **F5** while editing any `.ins` file will run it through InScript.
263
+
264
+ ---
265
+
266
+ ## Language Tour
267
+
268
+ ### Variables & Types
269
+
270
+ ```inscript
271
+ let x: int = 42
272
+ let name = "Ada" // type inferred
273
+ const MAX = comptime { 1024 * 4 } // compile-time constant = 4096
274
+ ```
275
+
276
+ ### Functions
277
+
278
+ ```inscript
279
+ fn lerp(a: float, b: float, t: float) -> float {
280
+ return a + (b - a) * t
281
+ }
282
+
283
+ // Closures
284
+ let doubled = [1, 2, 3].map(|x| x * 2)
285
+ ```
286
+
287
+ ### Structs
288
+
289
+ ```inscript
290
+ struct Bullet extends Entity {
291
+ dmg: int = 10
292
+ speed: float = 600.0
293
+
294
+ fn update(dt: float) {
295
+ self.pos += Vec2(0.0, -self.speed * dt)
296
+ }
297
+ }
298
+ ```
299
+
300
+ ### Generics
301
+
302
+ ```inscript
303
+ struct Pair<A, B> {
304
+ first: A
305
+ second: B
306
+ }
307
+
308
+ let p = Pair<int, string> { first: 1, second: "one" }
309
+ ```
310
+
311
+ ### ADT Enums + Pattern Matching
312
+
313
+ ```inscript
314
+ enum Shape {
315
+ Circle(radius: float)
316
+ Rectangle(w: float, h: float)
317
+ }
318
+
319
+ fn area(s: Shape) -> float {
320
+ match s {
321
+ case Circle(r) { return 3.14159 * r * r }
322
+ case Rectangle(w, h) { return w * h }
323
+ }
324
+ }
325
+ ```
326
+
327
+ ### Error Handling
328
+
329
+ ```inscript
330
+ fn load(path: string) -> Result {
331
+ let data = read_file(path)? // propagates Err upward
332
+ return Ok(data)
333
+ }
334
+
335
+ let result = load("level.json")
336
+ let data = unwrap_or(result, "{}")
337
+ ```
338
+
339
+ ### Coroutines
340
+
341
+ ```inscript
342
+ fn* enemy_spawner() {
343
+ while true {
344
+ yield Enemy { x: random_int(0, 800), y: -20 }
345
+ }
346
+ }
347
+
348
+ let spawner = enemy_spawner()
349
+ let enemy = spawner.next()
350
+ ```
351
+
352
+ ### Pipe Operator
353
+
354
+ ```inscript
355
+ fn clamp01(v: float) -> float { return clamp(v, 0.0, 1.0) }
356
+ fn to_pct(v: float) -> string { return f"{v * 100.0}%" }
357
+
358
+ let display = raw_value |> clamp01 |> to_pct
359
+ // โ†’ "73.5%"
360
+ ```
361
+
362
+ ---
363
+
364
+ ## Project Structure
365
+
366
+ ```
367
+ inscript/
368
+ โ”œโ”€โ”€ inscript.py โ† Entry point (run files, REPL, flags)
369
+ โ”œโ”€โ”€ lexer.py โ† Tokenizer
370
+ โ”œโ”€โ”€ parser.py โ† Recursive-descent parser โ†’ AST
371
+ โ”œโ”€โ”€ ast_nodes.py โ† All AST node dataclasses
372
+ โ”œโ”€โ”€ interpreter.py โ† Tree-walk interpreter (122 tests)
373
+ โ”œโ”€โ”€ analyzer.py โ† Static type analyzer
374
+ โ”œโ”€โ”€ environment.py โ† Scope / variable resolution
375
+ โ”œโ”€โ”€ errors.py โ† Error + signal classes
376
+ โ”œโ”€โ”€ stdlib.py โ† Standard library
377
+ โ”œโ”€โ”€ stdlib_values.py โ† Runtime value types (InScriptRange, etc.)
378
+ โ”œโ”€โ”€ repl.py โ† Interactive REPL
379
+ โ”œโ”€โ”€ setup.py โ† PyPI packaging
380
+ โ”œโ”€โ”€ examples/
381
+ โ”‚ โ””โ”€โ”€ asteroid_blaster.ins โ† Full demo program
382
+ โ””โ”€โ”€ tests/
383
+ โ”œโ”€โ”€ test_interpreter.py โ† 122 runtime tests
384
+ โ”œโ”€โ”€ test_parser.py
385
+ โ”œโ”€โ”€ test_lexer.py
386
+ โ”œโ”€โ”€ test_analyzer.py
387
+ โ””โ”€โ”€ test_stdlib.py
388
+ ```
389
+
390
+ ---
391
+
392
+ ## Testing
393
+
394
+ ```bash
395
+ # Run all interpreter tests (122 tests)
396
+ python test_interpreter.py
397
+
398
+ # Run parser tests
399
+ python test_parser.py
400
+
401
+ # Run lexer tests
402
+ python test_lexer.py
403
+ ```
404
+
405
+ Expected output:
406
+ ```
407
+ =================================================================
408
+ Phase 4 Final Results
409
+ =================================================================
410
+ 122 passed, 0 failed out of 122 tests
411
+ =================================================================
412
+ ```
413
+
414
+ ---
415
+
416
+ ## CLI Reference
417
+
418
+ ```bash
419
+ python inscript.py <file.ins> # Run a file
420
+ python inscript.py --repl # Interactive REPL
421
+ python inscript.py --check <file.ins> # Type-check only (no run)
422
+ python inscript.py --tokens <file.ins># Print lexer tokens
423
+ python inscript.py --ast <file.ins> # Print the AST
424
+ python inscript.py --version # Print version
425
+ ```
426
+
427
+ ---
428
+
429
+ ## Roadmap
430
+
431
+ - [ ] Union / intersection types (`Shape = Circle | Rectangle`)
432
+ - [ ] Abstract methods (`abstract fn update()`)
433
+ - [ ] Macro / metaprogramming system
434
+ - [ ] SIMD vector types (`float32x4`)
435
+ - [ ] LSP VS Code extension (syntax highlighting + completions)
436
+ - [ ] PyPI package (`pip install inscript-lang`)
437
+
438
+ ---
439
+
440
+ ## License
441
+
442
+ MIT โ€” see [LICENSE](LICENSE)
443
+
444
+ ---
445
+
446
+ <div align="center">
447
+
448
+ Built with โค๏ธ and Python ยท InScript 0.6.0
449
+
450
+ </div>