tumorscript 1.0.0__tar.gz → 1.0.1__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.
- {tumorscript-1.0.0/tumorscript.egg-info → tumorscript-1.0.1}/PKG-INFO +5 -8
- {tumorscript-1.0.0 → tumorscript-1.0.1}/README.md +4 -7
- {tumorscript-1.0.0 → tumorscript-1.0.1}/pyproject.toml +1 -1
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/bin/tumorscript.exe +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/main.lua +2 -2
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/src/interpreter.lua +79 -30
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/src/json.lua +10 -6
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/src/repl.lua +1 -1
- {tumorscript-1.0.0 → tumorscript-1.0.1/tumorscript.egg-info}/PKG-INFO +5 -8
- {tumorscript-1.0.0 → tumorscript-1.0.1}/LICENSE +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/setup.cfg +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/__init__.py +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/cli.py +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/src/capsid.lua +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/src/lexer.lua +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/src/memory.lua +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript/src/parser.lua +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript.egg-info/SOURCES.txt +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript.egg-info/dependency_links.txt +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript.egg-info/entry_points.txt +0 -0
- {tumorscript-1.0.0 → tumorscript-1.0.1}/tumorscript.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tumorscript
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: A biomorphic and entropic esoteric programming language runtime
|
|
5
5
|
Author: TumorScript Contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -135,11 +135,7 @@ Every time a CPU instruction observes a piece of DNA data, $\delta$ climbs from
|
|
|
135
135
|
|
|
136
136
|
### File Extension
|
|
137
137
|
|
|
138
|
-
TumorScript
|
|
139
|
-
|
|
140
|
-
| Extension | Name | Biosafety Level | Purpose |
|
|
141
|
-
|---|---|---|---|
|
|
142
|
-
| `.tmq` | Tumor Quarantine | Level 4 (Primary) | Official executable files containing quarantine chambers and program logic. |
|
|
138
|
+
TumorScript uses exclusively the `.tmq` (Tumor Quarantine) file extension for executable source files. All interpreters and compilers require this extension to execute program logic and quarantine chambers.
|
|
143
139
|
|
|
144
140
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
145
141
|
|
|
@@ -172,6 +168,7 @@ TumorScript programs use the official `.tmq` (Tumor Quarantine) file extension:
|
|
|
172
168
|
| **I/O** | | |
|
|
173
169
|
| `input(prompt?)` | `absorb(prompt?)` | Read a line from standard input (user absorption). |
|
|
174
170
|
| `read_file(path)` | `ingest(path)` | Ingest file contents into a string. |
|
|
171
|
+
| `read_bytes(path, offset?, length?)` | `ingest_binary(path, offset?, length?)` | Read a raw binary file or byte range. |
|
|
175
172
|
| `write_file(path, data)` | `secrete(path, data)` | Secrete data into a file (overwrite). |
|
|
176
173
|
| `append_file(path, data)` | `infiltrate(path, data)` | Infiltrate additional data into an existing file. |
|
|
177
174
|
| `file_exists(path)` | `file_exists(path)` | Check if a file path exists. |
|
|
@@ -293,7 +290,7 @@ Running `tumorscript` with no arguments opens the real-time biomorphic REPL. You
|
|
|
293
290
|
```text
|
|
294
291
|
$ tumorscript
|
|
295
292
|
======================================================================
|
|
296
|
-
TumorScript Interactive Malignancy Shell (REPL) v1.0.
|
|
293
|
+
TumorScript Interactive Malignancy Shell (REPL) v1.0.1
|
|
297
294
|
Type expressions to evaluate or statements to execute.
|
|
298
295
|
Type ':help' for clinical commands, ':exit' to quit.
|
|
299
296
|
======================================================================
|
|
@@ -538,7 +535,7 @@ Wiki Documentation: [https://github.com/yamanist0/Tumor-Script/wiki](https://git
|
|
|
538
535
|
[issues-url]: https://github.com/yamanist0/Tumor-Script/issues
|
|
539
536
|
[license-shield]: https://img.shields.io/badge/license-MIT-green.svg?style=for-the-badge
|
|
540
537
|
[license-url]: https://github.com/yamanist0/Tumor-Script/blob/main/LICENSE
|
|
541
|
-
[version-shield]: https://img.shields.io/badge/version-1.0.
|
|
538
|
+
[version-shield]: https://img.shields.io/badge/version-1.0.1-rose.svg?style=for-the-badge
|
|
542
539
|
[version-url]: https://github.com/yamanist0/Tumor-Script/releases
|
|
543
540
|
[product-screenshot]: https://raw.githubusercontent.com/yamanist0/Tumor-Script/main/icon.svg
|
|
544
541
|
[Rust-badge]: https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white
|
|
@@ -116,11 +116,7 @@ Every time a CPU instruction observes a piece of DNA data, $\delta$ climbs from
|
|
|
116
116
|
|
|
117
117
|
### File Extension
|
|
118
118
|
|
|
119
|
-
TumorScript
|
|
120
|
-
|
|
121
|
-
| Extension | Name | Biosafety Level | Purpose |
|
|
122
|
-
|---|---|---|---|
|
|
123
|
-
| `.tmq` | Tumor Quarantine | Level 4 (Primary) | Official executable files containing quarantine chambers and program logic. |
|
|
119
|
+
TumorScript uses exclusively the `.tmq` (Tumor Quarantine) file extension for executable source files. All interpreters and compilers require this extension to execute program logic and quarantine chambers.
|
|
124
120
|
|
|
125
121
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
126
122
|
|
|
@@ -153,6 +149,7 @@ TumorScript programs use the official `.tmq` (Tumor Quarantine) file extension:
|
|
|
153
149
|
| **I/O** | | |
|
|
154
150
|
| `input(prompt?)` | `absorb(prompt?)` | Read a line from standard input (user absorption). |
|
|
155
151
|
| `read_file(path)` | `ingest(path)` | Ingest file contents into a string. |
|
|
152
|
+
| `read_bytes(path, offset?, length?)` | `ingest_binary(path, offset?, length?)` | Read a raw binary file or byte range. |
|
|
156
153
|
| `write_file(path, data)` | `secrete(path, data)` | Secrete data into a file (overwrite). |
|
|
157
154
|
| `append_file(path, data)` | `infiltrate(path, data)` | Infiltrate additional data into an existing file. |
|
|
158
155
|
| `file_exists(path)` | `file_exists(path)` | Check if a file path exists. |
|
|
@@ -274,7 +271,7 @@ Running `tumorscript` with no arguments opens the real-time biomorphic REPL. You
|
|
|
274
271
|
```text
|
|
275
272
|
$ tumorscript
|
|
276
273
|
======================================================================
|
|
277
|
-
TumorScript Interactive Malignancy Shell (REPL) v1.0.
|
|
274
|
+
TumorScript Interactive Malignancy Shell (REPL) v1.0.1
|
|
278
275
|
Type expressions to evaluate or statements to execute.
|
|
279
276
|
Type ':help' for clinical commands, ':exit' to quit.
|
|
280
277
|
======================================================================
|
|
@@ -519,7 +516,7 @@ Wiki Documentation: [https://github.com/yamanist0/Tumor-Script/wiki](https://git
|
|
|
519
516
|
[issues-url]: https://github.com/yamanist0/Tumor-Script/issues
|
|
520
517
|
[license-shield]: https://img.shields.io/badge/license-MIT-green.svg?style=for-the-badge
|
|
521
518
|
[license-url]: https://github.com/yamanist0/Tumor-Script/blob/main/LICENSE
|
|
522
|
-
[version-shield]: https://img.shields.io/badge/version-1.0.
|
|
519
|
+
[version-shield]: https://img.shields.io/badge/version-1.0.1-rose.svg?style=for-the-badge
|
|
523
520
|
[version-url]: https://github.com/yamanist0/Tumor-Script/releases
|
|
524
521
|
[product-screenshot]: https://raw.githubusercontent.com/yamanist0/Tumor-Script/main/icon.svg
|
|
525
522
|
[Rust-badge]: https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white
|
|
Binary file
|
|
@@ -17,7 +17,7 @@ local function read_file(path)
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
local function print_help(prog)
|
|
20
|
-
print("TumorScript Interpreter v1.0.
|
|
20
|
+
print("TumorScript Interpreter v1.0.1")
|
|
21
21
|
print("usage: " .. prog .. " [options] [file.tmq]")
|
|
22
22
|
print("\noptions:")
|
|
23
23
|
print(" -i, --repl launch interactive biomorphic shell")
|
|
@@ -40,7 +40,7 @@ local function main()
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
if filename == "--version" or filename == "-v" then
|
|
43
|
-
print("TumorScript v1.0.
|
|
43
|
+
print("TumorScript v1.0.1")
|
|
44
44
|
os.exit(0)
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -8,6 +8,21 @@ local capsid_mod = require("src.capsid")
|
|
|
8
8
|
local interpreter = {}
|
|
9
9
|
interpreter.__index = interpreter
|
|
10
10
|
|
|
11
|
+
-- Keep JSON null placeholders in collections, but expose them as nil.
|
|
12
|
+
local function unwrap_json_null(value)
|
|
13
|
+
if value == json_mod.null then return nil end
|
|
14
|
+
return value
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
local function nonnegative_integer(value, label)
|
|
18
|
+
local number = tonumber(value)
|
|
19
|
+
local integer = number and math.tointeger(number)
|
|
20
|
+
if not integer or integer < 0 then
|
|
21
|
+
error("IO_TUMOR: " .. label .. " must be a non-negative integer")
|
|
22
|
+
end
|
|
23
|
+
return integer
|
|
24
|
+
end
|
|
25
|
+
|
|
11
26
|
-- makes a new tumor array
|
|
12
27
|
local function make_tumor(elements)
|
|
13
28
|
local original = {}
|
|
@@ -108,7 +123,7 @@ end
|
|
|
108
123
|
|
|
109
124
|
-- pretty format values for printing
|
|
110
125
|
function interpreter:format_val(val)
|
|
111
|
-
if val == nil then return "nil" end
|
|
126
|
+
if val == nil or val == json_mod.null then return "nil" end
|
|
112
127
|
if type(val) == "table" then
|
|
113
128
|
if val.__type == "tumor" then
|
|
114
129
|
local items = {}
|
|
@@ -423,7 +438,7 @@ function interpreter:exec_assignment(stmt)
|
|
|
423
438
|
elseif target.node_type == "dot_access" then
|
|
424
439
|
local obj = self:eval_expression(target.object)
|
|
425
440
|
if type(obj) == "table" and obj.__type == "membrane" then
|
|
426
|
-
obj.receptors[target.field] = value
|
|
441
|
+
obj.receptors[target.field] = value == nil and json_mod.null or value
|
|
427
442
|
elseif type(obj) == "table" and obj.__cell_data then
|
|
428
443
|
local field_name = target.field
|
|
429
444
|
local field_var = obj.__cell_data[field_name]
|
|
@@ -447,12 +462,13 @@ function interpreter:exec_assignment(stmt)
|
|
|
447
462
|
if lua_idx < 1 or lua_idx > #obj.elements then
|
|
448
463
|
error("RUNTIME_TUMOR: tumor index out of bounds: " .. tostring(idx))
|
|
449
464
|
end
|
|
450
|
-
|
|
451
|
-
obj.
|
|
465
|
+
local element = value == nil and json_mod.null or value
|
|
466
|
+
obj.elements[lua_idx] = element
|
|
467
|
+
obj.original_elements[lua_idx] = element
|
|
452
468
|
obj.rates[lua_idx] = memory.INITIAL_MUTATION_RATE
|
|
453
469
|
obj.reads[lua_idx] = 0
|
|
454
470
|
elseif type(obj) == "table" and obj.__type == "membrane" then
|
|
455
|
-
obj.receptors[tostring(idx)] = value
|
|
471
|
+
obj.receptors[tostring(idx)] = value == nil and json_mod.null or value
|
|
456
472
|
elseif type(obj) == "table" then
|
|
457
473
|
obj[idx] = value
|
|
458
474
|
else
|
|
@@ -580,7 +596,7 @@ function interpreter:exec_for(stmt)
|
|
|
580
596
|
|
|
581
597
|
for _, val in ipairs(items) do
|
|
582
598
|
self.mem:push_scope()
|
|
583
|
-
self.mem:declare(stmt.var_name, val, "dna")
|
|
599
|
+
self.mem:declare(stmt.var_name, unwrap_json_null(val), "dna")
|
|
584
600
|
local result, signal = self:exec_block(stmt.body)
|
|
585
601
|
self.mem:pop_scope()
|
|
586
602
|
|
|
@@ -671,7 +687,8 @@ function interpreter:eval_expression(expr)
|
|
|
671
687
|
elseif t == "tumor_literal" then
|
|
672
688
|
local elems = {}
|
|
673
689
|
for _, el_expr in ipairs(expr.elements) do
|
|
674
|
-
|
|
690
|
+
local value = self:eval_expression(el_expr)
|
|
691
|
+
elems[#elems + 1] = value == nil and json_mod.null or value
|
|
675
692
|
end
|
|
676
693
|
return make_tumor(elems)
|
|
677
694
|
elseif t == "identifier" then
|
|
@@ -706,7 +723,7 @@ end
|
|
|
706
723
|
function interpreter:eval_dot_access(expr)
|
|
707
724
|
local obj = self:eval_expression(expr.object)
|
|
708
725
|
if type(obj) == "table" and obj.__type == "membrane" then
|
|
709
|
-
return obj.receptors[expr.field]
|
|
726
|
+
return unwrap_json_null(obj.receptors[expr.field])
|
|
710
727
|
end
|
|
711
728
|
if type(obj) == "table" and obj.__cell_data then
|
|
712
729
|
local field = obj.__cell_data[expr.field]
|
|
@@ -778,9 +795,9 @@ function interpreter:eval_index_get(obj, idx)
|
|
|
778
795
|
end
|
|
779
796
|
end
|
|
780
797
|
end
|
|
781
|
-
return obj.elements[lua_idx]
|
|
798
|
+
return unwrap_json_null(obj.elements[lua_idx])
|
|
782
799
|
elseif type(obj) == "table" and obj.__type == "membrane" then
|
|
783
|
-
return obj.receptors[tostring(idx)]
|
|
800
|
+
return unwrap_json_null(obj.receptors[tostring(idx)])
|
|
784
801
|
elseif type(obj) == "string" then
|
|
785
802
|
local raw_idx = math.floor(tonumber(idx) or 0)
|
|
786
803
|
local sidx = raw_idx < 0 and (#obj + raw_idx + 1) or (raw_idx + 1)
|
|
@@ -847,8 +864,9 @@ end
|
|
|
847
864
|
function interpreter:eval_call(expr)
|
|
848
865
|
local callee = expr.callee
|
|
849
866
|
local args = {}
|
|
850
|
-
|
|
851
|
-
|
|
867
|
+
local arg_count = #expr.arguments
|
|
868
|
+
for i, arg_expr in ipairs(expr.arguments) do
|
|
869
|
+
args[i] = self:eval_expression(arg_expr)
|
|
852
870
|
end
|
|
853
871
|
|
|
854
872
|
local gene_name = nil
|
|
@@ -864,8 +882,14 @@ function interpreter:eval_call(expr)
|
|
|
864
882
|
|
|
865
883
|
-- built in routines
|
|
866
884
|
if gene_name == "tumor" then
|
|
885
|
+
for i = 1, arg_count do
|
|
886
|
+
if args[i] == nil then args[i] = json_mod.null end
|
|
887
|
+
end
|
|
867
888
|
return make_tumor(args)
|
|
868
889
|
elseif gene_name == "membrane" then
|
|
890
|
+
for i = 2, arg_count, 2 do
|
|
891
|
+
if args[i] == nil then args[i] = json_mod.null end
|
|
892
|
+
end
|
|
869
893
|
return make_membrane(args)
|
|
870
894
|
elseif gene_name == "necrosis" then
|
|
871
895
|
return make_necrosis(args[1] or 1, args[2])
|
|
@@ -873,12 +897,12 @@ function interpreter:eval_call(expr)
|
|
|
873
897
|
local start = 0
|
|
874
898
|
local stop = 0
|
|
875
899
|
local step = 1
|
|
876
|
-
if
|
|
900
|
+
if arg_count == 1 then
|
|
877
901
|
stop = tonumber(args[1]) or 0
|
|
878
|
-
elseif
|
|
902
|
+
elseif arg_count == 2 then
|
|
879
903
|
start = tonumber(args[1]) or 0
|
|
880
904
|
stop = tonumber(args[2]) or 0
|
|
881
|
-
elseif
|
|
905
|
+
elseif arg_count >= 3 then
|
|
882
906
|
start = tonumber(args[1]) or 0
|
|
883
907
|
stop = tonumber(args[2]) or 0
|
|
884
908
|
step = tonumber(args[3]) or 1
|
|
@@ -903,12 +927,12 @@ function interpreter:eval_call(expr)
|
|
|
903
927
|
local raw_idx = math.floor(tonumber(args[2]) or 0)
|
|
904
928
|
if type(t) == "table" and t.__type == "tumor" then
|
|
905
929
|
local idx = raw_idx < 0 and (#t.elements + raw_idx + 1) or (raw_idx + 1)
|
|
906
|
-
return t.elements[idx]
|
|
930
|
+
return unwrap_json_null(t.elements[idx])
|
|
907
931
|
end
|
|
908
932
|
error("RUNTIME_TUMOR: biopsy expects a tumor object")
|
|
909
933
|
elseif gene_name == "spread" then
|
|
910
934
|
local t = args[1]
|
|
911
|
-
local val = args[2]
|
|
935
|
+
local val = args[2] == nil and json_mod.null or args[2]
|
|
912
936
|
if type(t) == "table" and t.__type == "tumor" then
|
|
913
937
|
t.elements[#t.elements + 1] = val
|
|
914
938
|
t.original_elements[#t.original_elements + 1] = val
|
|
@@ -929,7 +953,7 @@ function interpreter:eval_call(expr)
|
|
|
929
953
|
table.remove(t.original_elements, idx)
|
|
930
954
|
table.remove(t.rates, idx)
|
|
931
955
|
table.remove(t.reads, idx)
|
|
932
|
-
return excised
|
|
956
|
+
return unwrap_json_null(excised)
|
|
933
957
|
end
|
|
934
958
|
error("RUNTIME_TUMOR: excise expects a tumor object")
|
|
935
959
|
elseif gene_name == "mass" or gene_name == "len" then
|
|
@@ -971,7 +995,7 @@ function interpreter:eval_call(expr)
|
|
|
971
995
|
elseif gene_name == "bind" then
|
|
972
996
|
local m = args[1]
|
|
973
997
|
local key = tostring(args[2])
|
|
974
|
-
local val = args[3]
|
|
998
|
+
local val = args[3] == nil and json_mod.null or args[3]
|
|
975
999
|
if type(m) == "table" and m.__type == "membrane" then
|
|
976
1000
|
m.receptors[key] = val
|
|
977
1001
|
return m
|
|
@@ -983,7 +1007,7 @@ function interpreter:eval_call(expr)
|
|
|
983
1007
|
if type(m) == "table" and m.__type == "membrane" then
|
|
984
1008
|
local old = m.receptors[key]
|
|
985
1009
|
m.receptors[key] = nil
|
|
986
|
-
return old
|
|
1010
|
+
return unwrap_json_null(old)
|
|
987
1011
|
end
|
|
988
1012
|
error("RUNTIME_TUMOR: unbind expects a membrane object")
|
|
989
1013
|
elseif gene_name == "receptors" then
|
|
@@ -1006,6 +1030,29 @@ function interpreter:eval_call(expr)
|
|
|
1006
1030
|
end
|
|
1007
1031
|
local line = io.read("*l")
|
|
1008
1032
|
return line or ""
|
|
1033
|
+
elseif gene_name == "ingest_binary" or gene_name == "read_binary" or gene_name == "read_bytes" then
|
|
1034
|
+
local path = tostring(args[1] or "")
|
|
1035
|
+
local offset = args[2] == nil and 0 or nonnegative_integer(args[2], "offset")
|
|
1036
|
+
local length
|
|
1037
|
+
if args[3] ~= nil then length = nonnegative_integer(args[3], "length") end
|
|
1038
|
+
local f = io.open(path, "rb")
|
|
1039
|
+
if not f then return nil end
|
|
1040
|
+
local position, seek_err = f:seek("set", offset)
|
|
1041
|
+
if position == nil then
|
|
1042
|
+
f:close()
|
|
1043
|
+
error("IO_TUMOR: failed to seek binary file: " .. tostring(seek_err))
|
|
1044
|
+
end
|
|
1045
|
+
local content, read_err
|
|
1046
|
+
if length == 0 then
|
|
1047
|
+
content = ""
|
|
1048
|
+
elseif length == nil then
|
|
1049
|
+
content, read_err = f:read("*a")
|
|
1050
|
+
else
|
|
1051
|
+
content, read_err = f:read(length)
|
|
1052
|
+
end
|
|
1053
|
+
f:close()
|
|
1054
|
+
if read_err then error("IO_TUMOR: failed to read binary file: " .. tostring(read_err)) end
|
|
1055
|
+
return content or ""
|
|
1009
1056
|
elseif gene_name == "read_file" or gene_name == "ingest"
|
|
1010
1057
|
or ((module_name == "fs" or module_name == "io") and gene_name == "read_file") then
|
|
1011
1058
|
local path = tostring(args[1] or "")
|
|
@@ -1051,7 +1098,7 @@ function interpreter:eval_call(expr)
|
|
|
1051
1098
|
local raw = {}
|
|
1052
1099
|
if type(col) == "table" and col.__type == "tumor" then
|
|
1053
1100
|
for _, el in ipairs(col.elements) do
|
|
1054
|
-
raw[#raw + 1] = tostring(el)
|
|
1101
|
+
raw[#raw + 1] = tostring(unwrap_json_null(el))
|
|
1055
1102
|
end
|
|
1056
1103
|
elseif type(col) == "table" then
|
|
1057
1104
|
for _, el in ipairs(col) do
|
|
@@ -1076,7 +1123,7 @@ function interpreter:eval_call(expr)
|
|
|
1076
1123
|
return string.find(col, tostring(target), 1, true) ~= nil
|
|
1077
1124
|
elseif type(col) == "table" and col.__type == "tumor" then
|
|
1078
1125
|
for _, v in ipairs(col.elements) do
|
|
1079
|
-
if v == target then return true end
|
|
1126
|
+
if unwrap_json_null(v) == target then return true end
|
|
1080
1127
|
end
|
|
1081
1128
|
return false
|
|
1082
1129
|
elseif type(col) == "table" and col.__type == "membrane" then
|
|
@@ -1107,9 +1154,9 @@ function interpreter:eval_call(expr)
|
|
|
1107
1154
|
|
|
1108
1155
|
-- math routines
|
|
1109
1156
|
elseif gene_name == "random" or (module_name == "math" and gene_name == "random") then
|
|
1110
|
-
if
|
|
1157
|
+
if arg_count == 0 then
|
|
1111
1158
|
return math.random()
|
|
1112
|
-
elseif
|
|
1159
|
+
elseif arg_count == 1 then
|
|
1113
1160
|
local max_val = tonumber(args[1]) or 1
|
|
1114
1161
|
if max_val <= 1 then return math.random() * max_val end
|
|
1115
1162
|
return math.random(1, math.floor(max_val))
|
|
@@ -1143,14 +1190,16 @@ function interpreter:eval_call(expr)
|
|
|
1143
1190
|
return math.abs(tonumber(args[1]) or 0)
|
|
1144
1191
|
elseif gene_name == "min" or (module_name == "math" and gene_name == "min") then
|
|
1145
1192
|
local m = nil
|
|
1146
|
-
for
|
|
1193
|
+
for i = 1, arg_count do
|
|
1194
|
+
local v = args[i]
|
|
1147
1195
|
local num = tonumber(v)
|
|
1148
1196
|
if num and (m == nil or num < m) then m = num end
|
|
1149
1197
|
end
|
|
1150
1198
|
return m
|
|
1151
1199
|
elseif gene_name == "max" or (module_name == "math" and gene_name == "max") then
|
|
1152
1200
|
local m = nil
|
|
1153
|
-
for
|
|
1201
|
+
for i = 1, arg_count do
|
|
1202
|
+
local v = args[i]
|
|
1154
1203
|
local num = tonumber(v)
|
|
1155
1204
|
if num and (m == nil or num > m) then m = num end
|
|
1156
1205
|
end
|
|
@@ -1213,7 +1262,7 @@ function interpreter:eval_call(expr)
|
|
|
1213
1262
|
if val == nil and err then
|
|
1214
1263
|
error("GENOMIC_CORRUPTION: failed to express json payload: " .. tostring(err))
|
|
1215
1264
|
end
|
|
1216
|
-
return val
|
|
1265
|
+
return unwrap_json_null(val)
|
|
1217
1266
|
elseif gene_name == "karyotype"
|
|
1218
1267
|
or ((module_name == "json" or module_name == "genome") and (gene_name == "karyotype" or gene_name == "diagnose")) then
|
|
1219
1268
|
return json_mod.karyotype(args[1])
|
|
@@ -1237,14 +1286,14 @@ function interpreter:eval_call(expr)
|
|
|
1237
1286
|
if val == nil and err then
|
|
1238
1287
|
error("GENOMIC_CORRUPTION: failed to ingest json: " .. tostring(err))
|
|
1239
1288
|
end
|
|
1240
|
-
return val
|
|
1289
|
+
return unwrap_json_null(val)
|
|
1241
1290
|
|
|
1242
1291
|
-- binary capsid routines
|
|
1243
1292
|
elseif gene_name == "condense"
|
|
1244
1293
|
or ((module_name == "capsid" or module_name == "histone" or module_name == "binary" or module_name == "struct") and (gene_name == "condense" or gene_name == "pack" or gene_name == "capsulate")) then
|
|
1245
1294
|
local fmt = tostring(args[1] or "")
|
|
1246
1295
|
local pack_args = {}
|
|
1247
|
-
for i = 2,
|
|
1296
|
+
for i = 2, arg_count do
|
|
1248
1297
|
pack_args[#pack_args + 1] = args[i]
|
|
1249
1298
|
end
|
|
1250
1299
|
return capsid_mod.condense(fmt, table.unpack(pack_args))
|
|
@@ -1264,7 +1313,7 @@ function interpreter:eval_call(expr)
|
|
|
1264
1313
|
local buf = tostring(args[2] or "")
|
|
1265
1314
|
local off = tonumber(args[3]) or 0
|
|
1266
1315
|
local pack_args = {}
|
|
1267
|
-
for i = 4,
|
|
1316
|
+
for i = 4, arg_count do
|
|
1268
1317
|
pack_args[#pack_args + 1] = args[i]
|
|
1269
1318
|
end
|
|
1270
1319
|
return capsid_mod.splice_into(fmt, buf, off, table.unpack(pack_args))
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
local json = {}
|
|
5
5
|
|
|
6
|
+
-- Lua nil cannot occupy an array slot or a map value, so retain JSON null
|
|
7
|
+
-- internally until a value is returned to TumorScript.
|
|
8
|
+
json.null = {}
|
|
9
|
+
|
|
6
10
|
-- helper to make tumor arrays
|
|
7
11
|
local function make_tumor(elements)
|
|
8
12
|
local original = {}
|
|
@@ -67,7 +71,7 @@ function json.transcribe(val, indent_opt, entropy_rate)
|
|
|
67
71
|
local rate = tonumber(entropy_rate) or 0
|
|
68
72
|
|
|
69
73
|
local function encode_internal(v, level)
|
|
70
|
-
if v == nil then
|
|
74
|
+
if v == nil or v == json.null then
|
|
71
75
|
return "null"
|
|
72
76
|
end
|
|
73
77
|
|
|
@@ -381,7 +385,7 @@ function json.express(str)
|
|
|
381
385
|
return false
|
|
382
386
|
elseif str:sub(pos, pos + 3) == "null" then
|
|
383
387
|
pos = pos + 4
|
|
384
|
-
return
|
|
388
|
+
return json.null
|
|
385
389
|
else
|
|
386
390
|
error(syntax_error("unexpected character '" .. c .. "'"))
|
|
387
391
|
end
|
|
@@ -411,7 +415,7 @@ function json.karyotype(target)
|
|
|
411
415
|
local is_text = false
|
|
412
416
|
if type(target) == "string" then
|
|
413
417
|
local parsed, err = json.express(target)
|
|
414
|
-
if
|
|
418
|
+
if err then
|
|
415
419
|
return make_membrane({
|
|
416
420
|
"valid", false,
|
|
417
421
|
"error", tostring(err),
|
|
@@ -429,7 +433,7 @@ function json.karyotype(target)
|
|
|
429
433
|
local tumor_cells = 0
|
|
430
434
|
|
|
431
435
|
local function inspect_depth(v, current_depth)
|
|
432
|
-
if type(v) ~= "table" then
|
|
436
|
+
if v == json.null or type(v) ~= "table" then
|
|
433
437
|
total_mass = total_mass + 1
|
|
434
438
|
return current_depth
|
|
435
439
|
end
|
|
@@ -461,7 +465,7 @@ function json.karyotype(target)
|
|
|
461
465
|
|
|
462
466
|
local depth = inspect_depth(val, 1)
|
|
463
467
|
local primary_strain = "primitive"
|
|
464
|
-
if type(val) == "table" and val.__type then
|
|
468
|
+
if val ~= json.null and type(val) == "table" and val.__type then
|
|
465
469
|
primary_strain = val.__type
|
|
466
470
|
end
|
|
467
471
|
|
|
@@ -482,7 +486,7 @@ function json.transduce(target, source)
|
|
|
482
486
|
local payload = source
|
|
483
487
|
if type(source) == "string" then
|
|
484
488
|
local p, err = json.express(source)
|
|
485
|
-
if
|
|
489
|
+
if err then return nil, err end
|
|
486
490
|
payload = p
|
|
487
491
|
end
|
|
488
492
|
|
|
@@ -29,7 +29,7 @@ local c = {
|
|
|
29
29
|
-- prints the interactive shell banner
|
|
30
30
|
local function print_banner()
|
|
31
31
|
print(c.b_cyan .. "====================================================================" .. c.reset)
|
|
32
|
-
print(c.b_cyan .. " TumorScript v1.0.
|
|
32
|
+
print(c.b_cyan .. " TumorScript v1.0.1 " .. c.yellow .. "- Biomorphic Interactive Shell (Petri Dish)" .. c.reset)
|
|
33
33
|
print(c.cyan .. " Type " .. c.b_yel .. ":help" .. c.cyan .. " for commands, " .. c.b_yel .. ":vitals" .. c.cyan .. " for telemetry, " .. c.b_red .. ":exit" .. c.cyan .. " to quit." .. c.reset)
|
|
34
34
|
print(c.dim .. " Variables decay live upon observation. Handle specimens carefully." .. c.reset)
|
|
35
35
|
print(c.b_cyan .. "====================================================================" .. c.reset)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tumorscript
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: A biomorphic and entropic esoteric programming language runtime
|
|
5
5
|
Author: TumorScript Contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -135,11 +135,7 @@ Every time a CPU instruction observes a piece of DNA data, $\delta$ climbs from
|
|
|
135
135
|
|
|
136
136
|
### File Extension
|
|
137
137
|
|
|
138
|
-
TumorScript
|
|
139
|
-
|
|
140
|
-
| Extension | Name | Biosafety Level | Purpose |
|
|
141
|
-
|---|---|---|---|
|
|
142
|
-
| `.tmq` | Tumor Quarantine | Level 4 (Primary) | Official executable files containing quarantine chambers and program logic. |
|
|
138
|
+
TumorScript uses exclusively the `.tmq` (Tumor Quarantine) file extension for executable source files. All interpreters and compilers require this extension to execute program logic and quarantine chambers.
|
|
143
139
|
|
|
144
140
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
145
141
|
|
|
@@ -172,6 +168,7 @@ TumorScript programs use the official `.tmq` (Tumor Quarantine) file extension:
|
|
|
172
168
|
| **I/O** | | |
|
|
173
169
|
| `input(prompt?)` | `absorb(prompt?)` | Read a line from standard input (user absorption). |
|
|
174
170
|
| `read_file(path)` | `ingest(path)` | Ingest file contents into a string. |
|
|
171
|
+
| `read_bytes(path, offset?, length?)` | `ingest_binary(path, offset?, length?)` | Read a raw binary file or byte range. |
|
|
175
172
|
| `write_file(path, data)` | `secrete(path, data)` | Secrete data into a file (overwrite). |
|
|
176
173
|
| `append_file(path, data)` | `infiltrate(path, data)` | Infiltrate additional data into an existing file. |
|
|
177
174
|
| `file_exists(path)` | `file_exists(path)` | Check if a file path exists. |
|
|
@@ -293,7 +290,7 @@ Running `tumorscript` with no arguments opens the real-time biomorphic REPL. You
|
|
|
293
290
|
```text
|
|
294
291
|
$ tumorscript
|
|
295
292
|
======================================================================
|
|
296
|
-
TumorScript Interactive Malignancy Shell (REPL) v1.0.
|
|
293
|
+
TumorScript Interactive Malignancy Shell (REPL) v1.0.1
|
|
297
294
|
Type expressions to evaluate or statements to execute.
|
|
298
295
|
Type ':help' for clinical commands, ':exit' to quit.
|
|
299
296
|
======================================================================
|
|
@@ -538,7 +535,7 @@ Wiki Documentation: [https://github.com/yamanist0/Tumor-Script/wiki](https://git
|
|
|
538
535
|
[issues-url]: https://github.com/yamanist0/Tumor-Script/issues
|
|
539
536
|
[license-shield]: https://img.shields.io/badge/license-MIT-green.svg?style=for-the-badge
|
|
540
537
|
[license-url]: https://github.com/yamanist0/Tumor-Script/blob/main/LICENSE
|
|
541
|
-
[version-shield]: https://img.shields.io/badge/version-1.0.
|
|
538
|
+
[version-shield]: https://img.shields.io/badge/version-1.0.1-rose.svg?style=for-the-badge
|
|
542
539
|
[version-url]: https://github.com/yamanist0/Tumor-Script/releases
|
|
543
540
|
[product-screenshot]: https://raw.githubusercontent.com/yamanist0/Tumor-Script/main/icon.svg
|
|
544
541
|
[Rust-badge]: https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|