mycelium-ei-language 0.2.2__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.
Files changed (48) hide show
  1. mycelium_ei_language-0.2.2/CHANGELOG.md +125 -0
  2. mycelium_ei_language-0.2.2/LICENSE +57 -0
  3. mycelium_ei_language-0.2.2/MANIFEST.in +7 -0
  4. mycelium_ei_language-0.2.2/PKG-INFO +134 -0
  5. mycelium_ei_language-0.2.2/README.md +103 -0
  6. mycelium_ei_language-0.2.2/docs/reference.md +235 -0
  7. mycelium_ei_language-0.2.2/examples/bio_ml_demo.myc +60 -0
  8. mycelium_ei_language-0.2.2/examples/bio_optimization_demo.myc +119 -0
  9. mycelium_ei_language-0.2.2/examples/bio_simple_demo.myc +34 -0
  10. mycelium_ei_language-0.2.2/examples/cultivation.myc +95 -0
  11. mycelium_ei_language-0.2.2/examples/cultivation_platform_demo.myc +142 -0
  12. mycelium_ei_language-0.2.2/examples/cultivation_simple_demo.myc +66 -0
  13. mycelium_ei_language-0.2.2/examples/debug_test.myc +19 -0
  14. mycelium_ei_language-0.2.2/examples/hello_world.myc +20 -0
  15. mycelium_ei_language-0.2.2/examples/network_demo.myc +95 -0
  16. mycelium_ei_language-0.2.2/examples/network_simple.myc +34 -0
  17. mycelium_ei_language-0.2.2/examples/neural_network.myc +157 -0
  18. mycelium_ei_language-0.2.2/examples/simple_cultivation.myc +63 -0
  19. mycelium_ei_language-0.2.2/mycelium_ei/__init__.py +38 -0
  20. mycelium_ei_language-0.2.2/mycelium_ei/__main__.py +8 -0
  21. mycelium_ei_language-0.2.2/mycelium_ei/bio/__init__.py +4 -0
  22. mycelium_ei_language-0.2.2/mycelium_ei/bio/algorithms.py +564 -0
  23. mycelium_ei_language-0.2.2/mycelium_ei/bio/cultivation.py +643 -0
  24. mycelium_ei_language-0.2.2/mycelium_ei/bio/ml.py +390 -0
  25. mycelium_ei_language-0.2.2/mycelium_ei/builtins.py +706 -0
  26. mycelium_ei_language-0.2.2/mycelium_ei/cli.py +133 -0
  27. mycelium_ei_language-0.2.2/mycelium_ei/errors.py +51 -0
  28. mycelium_ei_language-0.2.2/mycelium_ei/interpreter.py +720 -0
  29. mycelium_ei_language-0.2.2/mycelium_ei/lexer.py +299 -0
  30. mycelium_ei_language-0.2.2/mycelium_ei/network.py +191 -0
  31. mycelium_ei_language-0.2.2/mycelium_ei/nodes.py +196 -0
  32. mycelium_ei_language-0.2.2/mycelium_ei/parser.py +455 -0
  33. mycelium_ei_language-0.2.2/mycelium_ei/values.py +136 -0
  34. mycelium_ei_language-0.2.2/mycelium_ei_language.egg-info/PKG-INFO +134 -0
  35. mycelium_ei_language-0.2.2/mycelium_ei_language.egg-info/SOURCES.txt +46 -0
  36. mycelium_ei_language-0.2.2/mycelium_ei_language.egg-info/dependency_links.txt +1 -0
  37. mycelium_ei_language-0.2.2/mycelium_ei_language.egg-info/entry_points.txt +3 -0
  38. mycelium_ei_language-0.2.2/mycelium_ei_language.egg-info/requires.txt +3 -0
  39. mycelium_ei_language-0.2.2/mycelium_ei_language.egg-info/top_level.txt +1 -0
  40. mycelium_ei_language-0.2.2/pyproject.toml +64 -0
  41. mycelium_ei_language-0.2.2/setup.cfg +4 -0
  42. mycelium_ei_language-0.2.2/tests/test_bio.py +80 -0
  43. mycelium_ei_language-0.2.2/tests/test_cli.py +110 -0
  44. mycelium_ei_language-0.2.2/tests/test_examples.py +54 -0
  45. mycelium_ei_language-0.2.2/tests/test_interpreter.py +408 -0
  46. mycelium_ei_language-0.2.2/tests/test_lexer.py +84 -0
  47. mycelium_ei_language-0.2.2/tests/test_no_dependencies.py +29 -0
  48. mycelium_ei_language-0.2.2/tests/test_parser.py +136 -0
@@ -0,0 +1,125 @@
1
+ # Changelog
2
+
3
+ ## 0.2.2 (2026-09-11)
4
+
5
+ First release on PyPI, published as `mycelium-ei-language`.
6
+
7
+ ### Changed
8
+
9
+ - The distribution is renamed from `mycelium-ei-lang` to `mycelium-ei-language`.
10
+ The PyPI project `mycelium-ei-lang` belongs to an account whose two-factor
11
+ device and email were lost with a laptop, so it cannot receive releases and
12
+ its 0.1.x uploads stay broken. The import name `mycelium_ei`, the `myc` and
13
+ `mycelium` commands and the repository name are unchanged. `myc --version`
14
+ prints the distribution name: `mycelium-ei-language 0.2.2`.
15
+
16
+ ## 0.2.1 (2026-09-11)
17
+
18
+ The license fix release, and the first version uploaded to PyPI. 0.2.0 was
19
+ published only as a GitHub release (tag v0.2.0) while the PyPI upload waited
20
+ on an account permission; it never reached PyPI.
21
+
22
+ ### Fixed
23
+
24
+ - Every surface now says proprietary. `compiler/Cargo.toml` claimed
25
+ Apache-2.0 and `vscode-extension/package.json` claimed MIT; both point at
26
+ the one `LICENSE` now. Two marketing drafts called the language open
27
+ source and the Solidity template header said MIT.
28
+ - `LICENSE` had a placeholder contact (`michael.benjamin.crowe@[domain]`) and
29
+ a support address on a domain that does not resolve. It now gives
30
+ michael@crowelogic.com and the GitHub issue tracker, and the copyright
31
+ year covers 2024-2026.
32
+
33
+ ## 0.2.0 (2026-09-11)
34
+
35
+ The first release whose `pip install` runs the documented language.
36
+
37
+ ### Fixed
38
+
39
+ - Releases 0.1.0 to 0.1.2 shipped a `mycelium_ei` module that parsed input with
40
+ Python's `ast` module, so every `.myc` program failed with `invalid syntax`,
41
+ and they declared no dependencies while importing numpy, so `import mycelium_ei`
42
+ failed on a clean install. 0.2.0 ships a lexer, parser and tree-walking
43
+ interpreter for the `.myc` grammar and has no runtime dependencies.
44
+ - `examples/cultivation.myc` called `adapt_environment()`, which did not exist.
45
+ It now calls the `adjust_to_environment()` adapt function it defines.
46
+ - `examples/neural_network.myc` called four functions that existed nowhere
47
+ (`create_signal`, `ecological_loss`, `update_mycelial_connections`,
48
+ `adapt_to_environment`). It is rewritten as a complete, smaller program that
49
+ uses the same constructs: a `network` record, a `signal` type, a `mycelium`
50
+ with methods and an `adapt function`, `new`, method calls and array methods.
51
+ - Version strings agreed nowhere (pyproject 0.1.0, package 0.1.1, PyPI 0.1.2).
52
+ The version now lives only in `mycelium_ei/__init__.py`; `setup.py` is gone.
53
+ - The Rust workspace listed members that were not in the repository, so
54
+ `cargo` could not start. The workspace now lists only `compiler`, which
55
+ builds and passes its one test after a logos 0.13 migration and a borrow fix.
56
+ It is still a library skeleton and the Python package does not use it.
57
+
58
+ ### Added
59
+
60
+ - Language: `else if` chains, `null`, `const` (assignment is an error), object
61
+ literals `{key: value}` with identifier or string keys, indexing `a[i]`,
62
+ property access `a.b` and assignment to indexed and property targets,
63
+ method calls on arrays (`append`, `pop`, `insert`, `remove`, `contains`,
64
+ `index_of`, `sort`, `reverse`, `join`, `slice`, `copy`, `length`), strings
65
+ (`upper`, `lower`, `trim`, `split`, `contains`, `starts_with`, `ends_with`,
66
+ `replace`, `index_of`, `length`) and objects (`keys`, `values`, `has`,
67
+ `remove`, `copy`, `length`), block comments `/* */`, string escapes,
68
+ exponent literals, `for` over arrays, objects, strings and ints.
69
+ - `mycelium` blocks are classes: `signal` fields with defaults or types,
70
+ inline or typed `network` fields, methods, an optional `init` method that
71
+ receives the `new` arguments, and `adapt function` methods. Inside a method
72
+ the fields and the other methods are reachable by bare name.
73
+ - Top-level `network Name { ... }` declares a named record and `signal Name
74
+ { field: type }` declares a record type; a typed field gets a copy of the
75
+ record or a zero-filled instance.
76
+ - `adapt` functions run once each time `set_env` or `update_global_env`
77
+ changes a parameter; an adapt function that itself calls `set_env` does not
78
+ retrigger the pass.
79
+ - Error messages carry `file:line:column`, and the `myc` command prints them
80
+ as `runtime error:` or `syntax error:` lines and exits 1.
81
+ - Runaway recursion is reported as `Maximum call depth (N) exceeded` instead
82
+ of crashing the process. The cap is 200 nested calls from Python and 2000
83
+ from the `myc` command, which runs the program on a thread with a 256 MB
84
+ stack (CPython 3.10 and older overflow the main thread's stack far earlier).
85
+ - `print` shows `true`, `false` and `null`, quotes strings inside arrays and
86
+ objects, and joins arguments with one space.
87
+ - New builtins: `sqrt`, `pow`, `exp`, `log`, `tan`, `floor`, `ceil`, `round`,
88
+ `sum`, `sorted`, `random`, `random_range`, `random_int`, `clock`, `bool`,
89
+ `type_of`, `keys`, `values`, `has`, `contains`, `join`, `split`, `env`.
90
+ - CLI: `--check`, `--tokens`, `--ast`, `--no-sleep` (or `MYCELIUM_NO_SLEEP=1`),
91
+ `--seed N`, `--traceback`, and `-` to read a program from standard input.
92
+ `--help` is plain text. Exit codes: 0 ran, 1 error, 2 no file given.
93
+ - Python API: `mycelium_ei.run_file`, `run_source`, `Interpreter(write=,
94
+ no_sleep=, seed=)`, `parse`, `tokenize`.
95
+ - A test suite (134 tests) covering the lexer, parser, interpreter, builtins,
96
+ the CLI, every example program, and the absence of third-party imports.
97
+
98
+ ### Changed
99
+
100
+ - The optimizers (`genetic_optimize`, `swarm_optimize`, `ant_optimize`,
101
+ `bio_compare`) are pure Python; particle swarm and ant colony no longer use
102
+ numpy. Results differ numerically from 0.1.x runs.
103
+ - A fitness function may take one array parameter or one parameter per
104
+ dimension; it must return a number.
105
+ - `add_node()` connects each new node to the previously added node, so
106
+ `broadcast_signal` reaches the nodes an example creates. Node ids are
107
+ `node_01`, `node_02`, ... instead of random UUID prefixes.
108
+ - `get_env` of an undeclared parameter is an error instead of returning 0.0.
109
+ - Assigning to a variable that was never declared with `let` is an error.
110
+ - Builtin output lines no longer contain emoji.
111
+ - `requires-python` is `>=3.9`. Tested on CPython 3.9 through 3.14 on macOS.
112
+ - `examples/network_demo.myc` prints the node and connection counts instead of
113
+ the whole statistics object.
114
+
115
+ ### Removed
116
+
117
+ - `mycelium_interpreter.py`, `bio_algorithms.py`, `bio_ml_integration.py`,
118
+ `cultivation_monitor.py` and `network_framework.py` at the repository root.
119
+ Their code moved into the `mycelium_ei` package.
120
+ - `setup.py`.
121
+
122
+ ## 0.1.2 (2025-09-14), 0.1.1 and 0.1.0 (2025-09-12)
123
+
124
+ First uploads. Broken as described under 0.2.0: the installed command could
125
+ not run any `.myc` file.
@@ -0,0 +1,57 @@
1
+ PROPRIETARY SOFTWARE LICENSE AGREEMENT
2
+
3
+ Copyright (c) 2024-2026 Michael Benjamin Crowe. All Rights Reserved.
4
+
5
+ This software and associated documentation files (the "Software") are the exclusive
6
+ property of Michael Benjamin Crowe ("Owner").
7
+
8
+ NOTICE: This is proprietary software. Unauthorized copying, modification, distribution,
9
+ or use of this Software is strictly prohibited and may result in severe civil and
10
+ criminal penalties, and will be prosecuted to the maximum extent possible under law.
11
+
12
+ LIMITED LICENSE GRANT:
13
+ Subject to the terms and conditions of this Agreement, the Owner grants you a limited,
14
+ non-exclusive, non-transferable, revocable license to:
15
+
16
+ 1. VIEW the source code for evaluation purposes only
17
+ 2. USE the Software for personal, non-commercial evaluation only
18
+ 3. PROVIDE feedback and suggestions to the Owner
19
+
20
+ RESTRICTIONS:
21
+ You may NOT:
22
+ - Copy, modify, or create derivative works of the Software
23
+ - Distribute, sublicense, lease, rent, or lend the Software
24
+ - Use the Software for commercial purposes without explicit written permission
25
+ - Reverse engineer, decompile, or disassemble the Software
26
+ - Remove or alter any proprietary notices or labels
27
+
28
+ COMMERCIAL LICENSING:
29
+ For commercial use, enterprise deployment, or custom licensing arrangements,
30
+ please contact: michael@crowelogic.com
31
+
32
+ INTELLECTUAL PROPERTY:
33
+ All intellectual property rights in and to the Software, including but not limited
34
+ to any images, photographs, animations, video, audio, music, text, and "applets"
35
+ incorporated into the Software, are owned by the Owner or its suppliers and are
36
+ protected by international copyright laws and treaties.
37
+
38
+ NO WARRANTIES:
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
40
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
41
+ PARTICULAR PURPOSE AND NONINFRINGEMENT.
42
+
43
+ LIMITATION OF LIABILITY:
44
+ IN NO EVENT SHALL THE OWNER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
45
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
46
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47
+
48
+ TERMINATION:
49
+ This license is effective until terminated. Your rights under this license will
50
+ terminate automatically without notice if you fail to comply with any of its terms.
51
+
52
+ GOVERNING LAW:
53
+ This Agreement shall be governed by and construed in accordance with the laws of
54
+ the jurisdiction in which the Owner resides.
55
+
56
+ For licensing inquiries: michael@crowelogic.com
57
+ For technical support: https://github.com/MichaelCrowe11/mycelium-ei-lang/issues
@@ -0,0 +1,7 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ recursive-include examples *.myc
5
+ recursive-include docs *.md
6
+ global-exclude *.pyc
7
+ global-exclude .DS_Store
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: mycelium-ei-language
3
+ Version: 0.2.2
4
+ Summary: A small interpreted language for cultivation models: environment parameters, adapt functions that fire when they change, and genetic, particle swarm and ant colony optimizers.
5
+ Author-email: Michael Benjamin Crowe <michael@crowelogic.com>
6
+ License-Expression: LicenseRef-Proprietary
7
+ Project-URL: Homepage, https://github.com/MichaelCrowe11/mycelium-ei-lang
8
+ Project-URL: Repository, https://github.com/MichaelCrowe11/mycelium-ei-lang
9
+ Project-URL: Issues, https://github.com/MichaelCrowe11/mycelium-ei-lang/issues
10
+ Project-URL: Changelog, https://github.com/MichaelCrowe11/mycelium-ei-lang/blob/master/CHANGELOG.md
11
+ Keywords: interpreter,scripting-language,cultivation,mycelium,genetic-algorithm,particle-swarm,ant-colony
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Topic :: Software Development :: Interpreters
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Operating System :: OS Independent
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # Mycelium-EI-Lang
33
+
34
+ Mycelium-EI-Lang is a small interpreted language for cultivation models: environment parameters, adapt functions that fire when they change, and genetic, particle swarm and ant colony optimizers.
35
+
36
+ ## Status
37
+
38
+ early stage
39
+
40
+ 0.2.2 is the first release on PyPI that runs `.myc` programs. It is published as **mycelium-ei-language**. The older PyPI project `mycelium-ei-lang` (0.1.0 to 0.1.2) belongs to an account whose two-factor device was lost with a laptop, so it cannot be updated; its interpreter parsed Python syntax and imported a dependency it did not declare, and `myc examples/hello_world.myc` fails on every install of it. Do not install `mycelium-ei-lang`.
41
+
42
+ What does not work yet:
43
+
44
+ - One file per program. There is no `import`, no module system and no standard library beyond the builtins listed in `docs/reference.md`.
45
+ - The interpreter walks the syntax tree in Python. Loops of a few hundred thousand iterations take seconds.
46
+ - The optimizers, the neural network and the cultivation monitor are demonstration models: small populations, a Hebbian toy network, readings drawn from `random.gauss`. None of it reads a sensor or controls equipment.
47
+ - The Rust crate under `compiler/` builds and passes its two tests, but it is a skeleton with no command-line tool. The Python package does not use it. Nothing here compiles to native code or WebAssembly.
48
+ - Run only on macOS (arm64). Linux and Windows have not been tried.
49
+
50
+ ## Install and first run
51
+
52
+ Run on 2026-09-11 with CPython 3.13.14 on macOS.
53
+
54
+ ```
55
+ python3 -m venv .venv
56
+ . .venv/bin/activate
57
+ pip install mycelium-ei-language
58
+ myc --version
59
+ ```
60
+
61
+ Output:
62
+
63
+ ```
64
+ mycelium-ei-language 0.2.2
65
+ ```
66
+
67
+ Save this as `hello.myc`:
68
+
69
+ ```
70
+ // Hello World in Mycelium-EI-Lang
71
+
72
+ environment {
73
+ temperature: 22.5,
74
+ humidity: 85.0
75
+ }
76
+
77
+ function main() {
78
+ print("Hello from the Mycelium Network!")
79
+
80
+ let greeting: string = "Welcome to ecological intelligence programming"
81
+ print(greeting)
82
+
83
+ let temp: float = get_env("temperature")
84
+ if temp > 20.0 {
85
+ print("Optimal growth conditions detected")
86
+ } else {
87
+ print("Adjusting environmental parameters...")
88
+ }
89
+ }
90
+ ```
91
+
92
+ Then run it:
93
+
94
+ ```
95
+ myc hello.myc
96
+ ```
97
+
98
+ Output:
99
+
100
+ ```
101
+ Hello from the Mycelium Network!
102
+ Welcome to ecological intelligence programming
103
+ Optimal growth conditions detected
104
+ ```
105
+
106
+ `mycelium` and `python -m mycelium_ei` are the same command as `myc`. The package has no dependencies. The twelve programs in `examples/` and the tests are in the repository: `git clone https://github.com/MichaelCrowe11/mycelium-ei-lang`, then `pip install -e . pytest` and `pytest` in the checkout.
107
+
108
+ ## What runs today
109
+
110
+ Each item is covered by a test in `tests/`; the suite (140 tests) passed on CPython 3.9, 3.10, 3.11, 3.12, 3.13 and 3.14 on macOS on 2026-09-11.
111
+
112
+ - The language in `docs/reference.md`: `environment` blocks, functions, `let` and `const`, `if`/`else if`/`else`, `while`, `for` over arrays, objects, strings and ints, arrays and objects with methods, string concatenation, `mycelium` declarations with fields, methods, `init` and `adapt` functions, `new`, and top-level `network` and `signal` declarations (`tests/test_interpreter.py`, `tests/test_parser.py`, `tests/test_lexer.py`).
113
+ - `adapt` functions run when `set_env` or `update_global_env` changes a parameter; `examples/cultivation.myc` and `examples/neural_network.myc` show it (`tests/test_examples.py`).
114
+ - All twelve programs in `examples/` run to completion under `myc --no-sleep --seed 1` (`tests/test_examples.py`).
115
+ - `genetic_optimize`, `swarm_optimize`, `ant_optimize` and `bio_compare` in pure Python; a fitness function takes one array or one argument per dimension (`tests/test_bio.py`, `examples/bio_optimization_demo.myc`).
116
+ - Network builtins: nodes, connections, broadcast signals that print as they arrive (`examples/network_demo.myc`).
117
+ - Toy neural network and simulated cultivation builtins (`examples/bio_ml_demo.myc`, `examples/cultivation_platform_demo.myc`).
118
+ - Command line: `--check`, `--tokens`, `--ast`, `--no-sleep`, `--seed`, `-` for standard input; errors print as `file:line:column: runtime error: ...` and exit 1; runaway recursion stops with a message instead of a crash (`tests/test_cli.py`).
119
+ - Importing the package pulls in no third-party module (`tests/test_no_dependencies.py`).
120
+ - `cargo build` and `cargo test` pass for `compiler/` (one unit test, one doc test).
121
+
122
+ ## Limits
123
+
124
+ - This is an interpreter for small models, not a numerical library. The optimizers search `[-1, 1]` per dimension with populations of tens; no speed or quality claim is made against established packages.
125
+ - `create_cultivation` and `monitor_cultivation` simulate a grow room. Do not use them to run one.
126
+ - `quantum_bio_computing.py` and `performance_optimizations.py` at the repository root are standalone experiments from 2025 that need numpy and numba. They are not part of the package and have no tests.
127
+ - The directories `crypto-payments/`, `npm-package/`, `vscode-extension/`, `wasm/`, `snap/`, `homebrew/`, `conda-recipe/` and the two Dockerfiles have not been run. The planning documents at the root (roadmaps, monetization, publishing) describe 2025 intentions and prices. They are not an offer.
128
+ - Syntax errors are reported one at a time, at the first token the parser cannot place.
129
+
130
+ ## License and contact
131
+
132
+ Proprietary. See `LICENSE`: viewing and personal non-commercial evaluation only; no copying, modification or redistribution.
133
+
134
+ Contact: michael@crowelogic.com
@@ -0,0 +1,103 @@
1
+ # Mycelium-EI-Lang
2
+
3
+ Mycelium-EI-Lang is a small interpreted language for cultivation models: environment parameters, adapt functions that fire when they change, and genetic, particle swarm and ant colony optimizers.
4
+
5
+ ## Status
6
+
7
+ early stage
8
+
9
+ 0.2.2 is the first release on PyPI that runs `.myc` programs. It is published as **mycelium-ei-language**. The older PyPI project `mycelium-ei-lang` (0.1.0 to 0.1.2) belongs to an account whose two-factor device was lost with a laptop, so it cannot be updated; its interpreter parsed Python syntax and imported a dependency it did not declare, and `myc examples/hello_world.myc` fails on every install of it. Do not install `mycelium-ei-lang`.
10
+
11
+ What does not work yet:
12
+
13
+ - One file per program. There is no `import`, no module system and no standard library beyond the builtins listed in `docs/reference.md`.
14
+ - The interpreter walks the syntax tree in Python. Loops of a few hundred thousand iterations take seconds.
15
+ - The optimizers, the neural network and the cultivation monitor are demonstration models: small populations, a Hebbian toy network, readings drawn from `random.gauss`. None of it reads a sensor or controls equipment.
16
+ - The Rust crate under `compiler/` builds and passes its two tests, but it is a skeleton with no command-line tool. The Python package does not use it. Nothing here compiles to native code or WebAssembly.
17
+ - Run only on macOS (arm64). Linux and Windows have not been tried.
18
+
19
+ ## Install and first run
20
+
21
+ Run on 2026-09-11 with CPython 3.13.14 on macOS.
22
+
23
+ ```
24
+ python3 -m venv .venv
25
+ . .venv/bin/activate
26
+ pip install mycelium-ei-language
27
+ myc --version
28
+ ```
29
+
30
+ Output:
31
+
32
+ ```
33
+ mycelium-ei-language 0.2.2
34
+ ```
35
+
36
+ Save this as `hello.myc`:
37
+
38
+ ```
39
+ // Hello World in Mycelium-EI-Lang
40
+
41
+ environment {
42
+ temperature: 22.5,
43
+ humidity: 85.0
44
+ }
45
+
46
+ function main() {
47
+ print("Hello from the Mycelium Network!")
48
+
49
+ let greeting: string = "Welcome to ecological intelligence programming"
50
+ print(greeting)
51
+
52
+ let temp: float = get_env("temperature")
53
+ if temp > 20.0 {
54
+ print("Optimal growth conditions detected")
55
+ } else {
56
+ print("Adjusting environmental parameters...")
57
+ }
58
+ }
59
+ ```
60
+
61
+ Then run it:
62
+
63
+ ```
64
+ myc hello.myc
65
+ ```
66
+
67
+ Output:
68
+
69
+ ```
70
+ Hello from the Mycelium Network!
71
+ Welcome to ecological intelligence programming
72
+ Optimal growth conditions detected
73
+ ```
74
+
75
+ `mycelium` and `python -m mycelium_ei` are the same command as `myc`. The package has no dependencies. The twelve programs in `examples/` and the tests are in the repository: `git clone https://github.com/MichaelCrowe11/mycelium-ei-lang`, then `pip install -e . pytest` and `pytest` in the checkout.
76
+
77
+ ## What runs today
78
+
79
+ Each item is covered by a test in `tests/`; the suite (140 tests) passed on CPython 3.9, 3.10, 3.11, 3.12, 3.13 and 3.14 on macOS on 2026-09-11.
80
+
81
+ - The language in `docs/reference.md`: `environment` blocks, functions, `let` and `const`, `if`/`else if`/`else`, `while`, `for` over arrays, objects, strings and ints, arrays and objects with methods, string concatenation, `mycelium` declarations with fields, methods, `init` and `adapt` functions, `new`, and top-level `network` and `signal` declarations (`tests/test_interpreter.py`, `tests/test_parser.py`, `tests/test_lexer.py`).
82
+ - `adapt` functions run when `set_env` or `update_global_env` changes a parameter; `examples/cultivation.myc` and `examples/neural_network.myc` show it (`tests/test_examples.py`).
83
+ - All twelve programs in `examples/` run to completion under `myc --no-sleep --seed 1` (`tests/test_examples.py`).
84
+ - `genetic_optimize`, `swarm_optimize`, `ant_optimize` and `bio_compare` in pure Python; a fitness function takes one array or one argument per dimension (`tests/test_bio.py`, `examples/bio_optimization_demo.myc`).
85
+ - Network builtins: nodes, connections, broadcast signals that print as they arrive (`examples/network_demo.myc`).
86
+ - Toy neural network and simulated cultivation builtins (`examples/bio_ml_demo.myc`, `examples/cultivation_platform_demo.myc`).
87
+ - Command line: `--check`, `--tokens`, `--ast`, `--no-sleep`, `--seed`, `-` for standard input; errors print as `file:line:column: runtime error: ...` and exit 1; runaway recursion stops with a message instead of a crash (`tests/test_cli.py`).
88
+ - Importing the package pulls in no third-party module (`tests/test_no_dependencies.py`).
89
+ - `cargo build` and `cargo test` pass for `compiler/` (one unit test, one doc test).
90
+
91
+ ## Limits
92
+
93
+ - This is an interpreter for small models, not a numerical library. The optimizers search `[-1, 1]` per dimension with populations of tens; no speed or quality claim is made against established packages.
94
+ - `create_cultivation` and `monitor_cultivation` simulate a grow room. Do not use them to run one.
95
+ - `quantum_bio_computing.py` and `performance_optimizations.py` at the repository root are standalone experiments from 2025 that need numpy and numba. They are not part of the package and have no tests.
96
+ - The directories `crypto-payments/`, `npm-package/`, `vscode-extension/`, `wasm/`, `snap/`, `homebrew/`, `conda-recipe/` and the two Dockerfiles have not been run. The planning documents at the root (roadmaps, monetization, publishing) describe 2025 intentions and prices. They are not an offer.
97
+ - Syntax errors are reported one at a time, at the first token the parser cannot place.
98
+
99
+ ## License and contact
100
+
101
+ Proprietary. See `LICENSE`: viewing and personal non-commercial evaluation only; no copying, modification or redistribution.
102
+
103
+ Contact: michael@crowelogic.com
@@ -0,0 +1,235 @@
1
+ # Mycelium-EI-Lang reference
2
+
3
+ This is the whole language as the interpreter in `mycelium_ei` runs it. Every
4
+ construct here is exercised by `tests/` or by a program in `examples/`.
5
+
6
+ ## Running programs
7
+
8
+ ```
9
+ myc program.myc run a program (main() runs last if it is defined)
10
+ myc --check program.myc parse only, report syntax errors
11
+ myc --tokens program.myc print the token stream
12
+ myc --ast program.myc print the syntax tree
13
+ myc --no-sleep ... sleep() returns at once (also MYCELIUM_NO_SLEEP=1)
14
+ myc --seed 1 ... seed the random number generator for repeatable runs
15
+ myc - read the program from standard input
16
+ ```
17
+
18
+ `mycelium` and `python -m mycelium_ei` are the same command. Exit code 0 means
19
+ the program ran to the end, 1 means a syntax or runtime error (printed to
20
+ standard error as `file:line:column: kind: message`), 2 means no file was given.
21
+
22
+ From Python:
23
+
24
+ ```python
25
+ from mycelium_ei import run_file, run_source, Interpreter
26
+
27
+ run_file("examples/hello_world.myc")
28
+ lines = []
29
+ interp = Interpreter("<inline>", write=lines.append, no_sleep=True, seed=1)
30
+ interp.run('print("hi", 1 + 1)')
31
+ assert lines == ["hi 2"]
32
+ ```
33
+
34
+ ## Lexical rules
35
+
36
+ - Comments: `// to end of line` and `/* block */`.
37
+ - Integers `42`, floats `1.5`, `2e-3`; strings in double quotes with the
38
+ escapes `\n \t \r \" \\ \0`; `true`, `false`, `null`.
39
+ - Identifiers: letters, digits and `_`, not starting with a digit.
40
+ - Keywords: `environment function mycelium network signal adapt if else while
41
+ for in return let const new true false null`. Keywords may be used as
42
+ object keys and after `.` (`stats.environment`).
43
+ - Statements end at the end of the expression; `;` is allowed and ignored.
44
+ A call or index must start on the same line as the expression it applies
45
+ to, so a line that starts with `(` or `[` begins a new statement.
46
+
47
+ ## Types and values
48
+
49
+ `int`, `float`, `string`, `bool`, `null`, `array` (`[1, 2]`), `object`
50
+ (`{key: value, "other key": 2}`), `function`, and instances of `mycelium`
51
+ declarations. `type_of(x)` returns the name. Type annotations (`let x: float`,
52
+ `function f(a: int) -> float`) are accepted and ignored.
53
+
54
+ Truthiness follows Python: `0`, `0.0`, `""`, `[]`, `{}` and `null` are false.
55
+
56
+ `print` shows booleans as `true`/`false`, `null` as `null`, floats with full
57
+ precision, and quotes strings inside arrays and objects.
58
+
59
+ ## Expressions
60
+
61
+ Precedence, lowest first: assignment `=`; `||`; `&&`; `==` `!=`; `<` `>` `<=`
62
+ `>=`; `+` `-`; `*` `/` `%`; unary `!` `-`; postfix call `f(x)`, index `a[i]`,
63
+ property `a.b`; primary.
64
+
65
+ - `+` on a string and anything concatenates (the other operand is formatted
66
+ as `print` would show it); on two arrays it concatenates them.
67
+ - `/` always gives a float; `%` follows Python. Division or modulo by zero is
68
+ a runtime error.
69
+ - `<` and friends compare numbers with numbers or strings with strings.
70
+ - `&&` and `||` short-circuit and return the deciding operand.
71
+ - Indexing an array out of range is an error; `object["missing"]` is an error;
72
+ `object.missing` is `null`.
73
+ - Assignment targets: a variable declared with `let`, `array[i]`,
74
+ `object.key`, `object[key]`, `instance.field`.
75
+
76
+ ## Statements
77
+
78
+ ```
79
+ let x: float = 1.0 // declare; type is optional and ignored
80
+ const limit = 10 // assigning to a const is an error
81
+ x = x + 1 // assignment needs a prior let
82
+ if a < b { ... } else if a == b { ... } else { ... }
83
+ while cond { ... }
84
+ for item in [1, 2, 3] { ... } // arrays: items; objects: keys; strings: characters
85
+ for i in 5 { ... } // an int iterates 0..4; range(a, b) builds an array
86
+ return expr // bare return at end of line returns null
87
+ ```
88
+
89
+ Blocks open a new scope: a `let` inside `if`, `while`, `for` or a function is
90
+ not visible outside it. Assignment finds the nearest enclosing declaration.
91
+
92
+ ## Functions
93
+
94
+ ```
95
+ function name(a, b: float) -> float {
96
+ return a * b
97
+ }
98
+ ```
99
+
100
+ Calls must pass exactly as many arguments as there are parameters. Functions
101
+ are values: `let f = name`. A user function with the same name as a builtin
102
+ replaces it. If `main` is defined it runs after all top-level statements.
103
+
104
+ Runaway recursion stops with `Maximum call depth (N) exceeded`. N is 2000 for
105
+ the `myc` command, which runs the program on a thread with a 256 MB stack, and
106
+ 200 for `Interpreter` used directly from Python (`max_call_depth=` changes it;
107
+ on CPython 3.10 and older, going higher needs `run_in_thread`).
108
+
109
+ ## Environment block and adapt functions
110
+
111
+ ```
112
+ environment {
113
+ temperature: 22.5,
114
+ humidity: 85.0
115
+ }
116
+
117
+ adapt function respond() {
118
+ if get_env("temperature") > 28.0 { print("too warm") }
119
+ }
120
+
121
+ set_env("temperature", 30.0) // prints "too warm"
122
+ ```
123
+
124
+ `get_env(name)` reads a declared parameter (an undeclared name is an error);
125
+ `set_env(name, value)` and `update_global_env(name, value)` set one and then
126
+ run every `adapt` function once: top-level `adapt function`s with no
127
+ parameters, then the `adapt function` methods of every live `mycelium`
128
+ instance. An adapt function that itself calls `set_env` does not restart the
129
+ pass. `env()` returns all parameters as an object.
130
+
131
+ ## mycelium, network and signal declarations
132
+
133
+ ```
134
+ network Substrate { nodes: 4, density: 0.75 } // a named record (an object)
135
+ signal Pulse { amplitude: float, speed: float } // a record type
136
+
137
+ mycelium Colony {
138
+ signal growth: float = 1.0 // field with a default
139
+ signal label: string // field with a typed zero value ("")
140
+ network links: Substrate // field: a copy of the Substrate record
141
+ network local { size: 2 } // field: an inline record
142
+ signal pulse: Pulse // field: {amplitude: 0.0, speed: 0.0}
143
+
144
+ function init(name) { label = name } // optional; receives the new arguments
145
+ function grow(by) { growth = growth + by; return describe() }
146
+ function describe() { return label + ": " + growth }
147
+ adapt function react() { growth = growth * 2.0 }
148
+ }
149
+
150
+ let c = new Colony("alpha")
151
+ c.grow(0.5) // method call
152
+ c.growth // field read
153
+ c.links.nodes = 8 // fields are ordinary values
154
+ ```
155
+
156
+ Inside a method, fields and the other methods are reachable by bare name and
157
+ assignment to a field name updates the instance. Zero values by type: `float`
158
+ 0.0, `int` 0, `string` "", `bool` false, `array` [], `object` {}, anything
159
+ else `null`. Each instance gets its own copy of record-typed fields.
160
+
161
+ ## Methods on arrays, strings and objects
162
+
163
+ Arrays: `append(x...)` (alias `push`), `pop([i])`, `insert(i, x)`,
164
+ `remove(x)`, `contains(x)`, `index_of(x)` (-1 if absent), `sort()`,
165
+ `reverse()`, `join(sep)`, `slice(start[, end])`, `copy()`, `length`.
166
+
167
+ Strings: `upper()`, `lower()`, `trim()`, `split([sep])`, `contains(s)`,
168
+ `starts_with(s)`, `ends_with(s)`, `replace(old, new)`, `index_of(s)`,
169
+ `length`. Strings are indexable: `s[0]`.
170
+
171
+ Objects: `keys()`, `values()`, `has(key)`, `remove(key)`, `copy()`, `length`.
172
+ A key that is also a method name is returned as the key's value.
173
+
174
+ ## Builtin functions
175
+
176
+ Output and collections: `print(values...)`, `len(x)`, `range(end)` /
177
+ `range(start, end[, step])`, `reverse(array)`, `sorted(array)`,
178
+ `sum(array)`, `keys(obj)`, `values(obj)`, `has(obj, key)`,
179
+ `contains(array_or_string, item)`, `join(array[, sep])`, `split(string[, sep])`.
180
+
181
+ Math: `abs`, `min(a, b, ...)` or `min(array)`, `max`, `sqrt`, `pow(x, y)`,
182
+ `exp`, `log(x[, base])`, `sin`, `cos`, `tan`, `floor`, `ceil`,
183
+ `round(x[, digits])`, `random()` in [0, 1), `random_range(low, high)`,
184
+ `random_int(low, high)`, `clock()` (seconds, monotonic).
185
+
186
+ Conversion: `int`, `float`, `str`, `bool`, `type_of`.
187
+
188
+ Environment: `get_env`, `set_env`, `env`, `sleep(milliseconds)`.
189
+
190
+ Cultivation helpers: `calculate_growth_factor(temp, humidity, co2)` (a 0..1
191
+ factor centred on 24 C, 85 percent humidity and 1000 ppm CO2),
192
+ `create_one_hot(index, size)`, `apply_activation(x, "relu" | "sigmoid" |
193
+ "tanh" | "linear")` or `apply_activation(array, "softmax")`,
194
+ `apply_signal_decay(x_or_array, distance)` (multiplies by `exp(-0.1 *
195
+ distance)`), `signal_alert(message)` and `signal_network(type, value)` (both
196
+ print one line).
197
+
198
+ Network: `create_network([name])`, `add_node([network])` (connects the new
199
+ node to the previous one; ids are `node_01`, `node_02`, ...),
200
+ `connect_nodes(a, b)`, `broadcast_signal(type, payload[, network])` with type
201
+ `growth`, `nutrient`, `stress`, `alert` or `data`, `update_global_env(name,
202
+ value[, network])`, `get_network_stats([network])` returning `{name, nodes,
203
+ connections, environment}`. Nodes print a line when they receive a signal.
204
+
205
+ Optimizers (pure Python, maximise the fitness, search space [-1, 1] per
206
+ dimension): `genetic_optimize(fitness, dimensions=6, population_size=50,
207
+ max_generations=100)`, `swarm_optimize(fitness, dimensions=6,
208
+ num_particles=30, max_iterations=100)`, `ant_optimize(fitness, dimensions=6,
209
+ num_ants=25, max_iterations=100)`, `bio_compare(fitness, dimensions=6)`. The
210
+ fitness is a function or a function name; it takes either one array or one
211
+ parameter per dimension and must return a number. Results are objects with
212
+ `solution`, `fitness`, `time` and `generations` or `iterations`; `bio_compare`
213
+ returns `{genetic: {...}, pso: {...}, aco: {...}}`. The optimizers print
214
+ progress lines.
215
+
216
+ Toy neural network (Hebbian-style adaptation, no gradient descent):
217
+ `create_bio_network(id, input_size=4, hidden_size=8, output_size=2)`,
218
+ `train_bio_network(id, data, epochs=50)` where data is `"growth_pattern"`
219
+ (20 generated samples) or an array of `[inputs, targets]` pairs,
220
+ `predict_bio_network(id, inputs)`, `compare_bio_ml([data])`.
221
+
222
+ Simulated cultivation (readings come from `random.gauss`, not sensors):
223
+ `create_cultivation(id)`, `monitor_cultivation(id)` returning `{temperature,
224
+ humidity, growth_rate, alerts, stage}`, `get_cultivation_health(id)` returning
225
+ `{health_score, predicted_growth, recommendations}`,
226
+ `optimize_cultivation(id)` returning `{fitness, optimal_temperature,
227
+ optimal_humidity, optimal_nutrients, time}`.
228
+
229
+ ## Errors
230
+
231
+ Syntax errors stop before anything runs. Runtime errors stop the program at
232
+ the failing line. Both print as `file:line:column: syntax error: ...` or
233
+ `file:line:column: runtime error: ...`. From Python they are
234
+ `mycelium_ei.MyceliumSyntaxError` and `mycelium_ei.MyceliumRuntimeError`
235
+ (both `MyceliumError`) with `line`, `column`, `filename` and `format()`.