lumos-language 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ name: Deploy To Glitch
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ jobs:
7
+ deploy:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - name: Deploy To Glitch
11
+ uses: kanadgupta/glitch-sync@main
12
+ with:
13
+ project-id: '${{ secrets.PROJECT_ID }}'
14
+ auth-token: '${{ secrets.AUTH_TOKEN }}'
package/.glitch-assets ADDED
@@ -0,0 +1,22 @@
1
+ {"name":"drag-in-files.svg","date":"2016-10-22T16:17:49.954Z","url":"https://cdn.hyperdev.com/drag-in-files.svg","type":"image/svg","size":7646,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/drag-in-files.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(102, 153, 205)","uuid":"adSBq97hhhpFNUna"}
2
+ {"name":"click-me.svg","date":"2016-10-23T16:17:49.954Z","url":"https://cdn.hyperdev.com/click-me.svg","type":"image/svg","size":7116,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/click-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(243, 185, 186)","uuid":"adSBq97hhhpFNUnb"}
3
+ {"name":"paste-me.svg","date":"2016-10-24T16:17:49.954Z","url":"https://cdn.hyperdev.com/paste-me.svg","type":"image/svg","size":7242,"imageWidth":276,"imageHeight":276,"thumbnail":"https://cdn.hyperdev.com/paste-me.svg","thumbnailWidth":276,"thumbnailHeight":276,"dominantColor":"rgb(42, 179, 185)","uuid":"adSBq97hhhpFNUnc"}
4
+ {"uuid":"adSBq97hhhpFNUna","deleted":true}
5
+ {"uuid":"adSBq97hhhpFNUnb","deleted":true}
6
+ {"uuid":"adSBq97hhhpFNUnc","deleted":true}
7
+ {"name":"Logo_Color.svg","date":"2020-10-15T17:02:08.576Z","url":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FLogo_Color.svg","type":"image/svg+xml","size":25537,"imageWidth":19,"imageHeight":14,"thumbnail":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FLogo_Color.svg","thumbnailWidth":19,"thumbnailHeight":14,"uuid":"XPQ2UUJettC9yQ6L"}
8
+ {"name":"HKGrotesk-Medium.otf","date":"2020-10-15T17:19:39.944Z","url":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FHKGrotesk-Medium.otf","type":"","size":69888,"thumbnail":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2Fthumbnails%2FHKGrotesk-Medium.otf","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"mSnvx5eJut7fimxB"}
9
+ {"name":"HKGrotesk-Regular.otf","date":"2020-10-15T17:19:40.076Z","url":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FHKGrotesk-Regular.otf","type":"","size":67768,"thumbnail":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2Fthumbnails%2FHKGrotesk-Regular.otf","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"VY2dLeOvcf8ffuEw"}
10
+ {"name":"HKGrotesk-SemiBold.otf","date":"2020-10-15T17:20:42.442Z","url":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FHKGrotesk-SemiBold.otf","type":"","size":69948,"thumbnail":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2Fthumbnails%2FHKGrotesk-SemiBold.otf","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"yEDZsSX7I7P2NlF1"}
11
+ {"name":"HKGrotesk-Bold.otf","date":"2020-10-15T17:21:24.249Z","url":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2FHKGrotesk-Bold.otf","type":"","size":68144,"thumbnail":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2Fthumbnails%2FHKGrotesk-Bold.otf","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"aHiG7zYivg7tnSDH"}
12
+ {"name":"illustration.svg","date":"2021-04-11T21:42:24.016Z","url":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2Fillustration.svg","type":"image/svg+xml","size":21272,"imageWidth":658,"imageHeight":682,"thumbnail":"https://cdn.glitch.com/a9975ea6-8949-4bab-addb-8a95021dc2da%2Fthumbnails%2Fillustration.svg","thumbnailWidth":319,"thumbnailHeight":330,"uuid":"WlqPAPkJzcjf2thL"}
13
+ {"uuid":"aHiG7zYivg7tnSDH","deleted":true}
14
+ {"uuid":"mSnvx5eJut7fimxB","deleted":true}
15
+ {"uuid":"yEDZsSX7I7P2NlF1","deleted":true}
16
+ {"uuid":"VY2dLeOvcf8ffuEw","deleted":true}
17
+ {"uuid":"XPQ2UUJettC9yQ6L","deleted":true}
18
+ {"name":"Lumos.png","date":"2025-06-02T12:06:37.035Z","url":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.png","type":"image/png","size":1430547,"imageWidth":1024,"imageHeight":1024,"thumbnail":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/thumbnails%2FLumos.png","thumbnailWidth":330,"thumbnailHeight":330,"uuid":"otRzyz9AwxB92Q2q"}
19
+ {"name":"Lumos.pdf","date":"2025-06-02T12:11:04.315Z","url":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.pdf","type":"application/pdf","size":3417,"thumbnail":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/thumbnails%2FLumos.pdf","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"pd82XvWhn2fgAzqF"}
20
+ {"name":"Lumos.ico","date":"2025-06-02T12:37:32.729Z","url":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.ico","type":"image/vnd.microsoft.icon","size":32707,"imageWidth":256,"imageHeight":256,"thumbnail":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.ico","thumbnailWidth":256,"thumbnailHeight":256,"uuid":"h7bKnov5lHcMrv6G"}
21
+ {"uuid":"pd82XvWhn2fgAzqF","deleted":true}
22
+ {"name":"Lumos.pdf","date":"2025-06-02T12:57:08.196Z","url":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.pdf","type":"application/pdf","size":4108,"thumbnail":"https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/thumbnails%2FLumos.pdf","thumbnailWidth":210,"thumbnailHeight":210,"uuid":"cM6oZCeYkVeeTwV6"}
package/LICENSE ADDED
@@ -0,0 +1,54 @@
1
+ The LICENSE file for any project gives credit to the creator/author of the
2
+ project, copyright information for the project, and the legal terms under
3
+ which it's being shared. In other words, this is us using an MIT license to
4
+ say "we wrote this and you can do whatever you want with it."
5
+
6
+ ******************************************************************************
7
+ ~glitch-hello-website
8
+ ******************************************************************************
9
+ MIT License
10
+
11
+ Copyright (c) 2021, Glitch, Inc.
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+
31
+
32
+
33
+
34
+ ******************************************************************************
35
+
36
+ THIRD-PARTY SOFTWARE
37
+ This is all the software we used to build this starter project. All of these
38
+ licenses are compatible with the license above. We've included links so you
39
+ can learn more if you want.
40
+
41
+ 1. HK Grotesk: The font we're using.
42
+
43
+
44
+ ******************************************************************************
45
+ 1. HK Grotesk
46
+ URL: https://hanken.co/products/hk-grotesk
47
+ ******************************************************************************
48
+ HK Grotesk was designed by Hanken Design Co. It is shared using a SIL OFL
49
+ license. Full license text can be found at:
50
+
51
+ https://hanken.co/pages/web-fonts-eula
52
+ ******************************************************************************
53
+ END, HK Grotesk
54
+ ******************************************************************************
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Lumos
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/lumos-language.svg)](https://www.npmjs.com/package/lumos-language)
4
+
3
5
  <img src="https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.png?v=1748865997035" />
4
6
 
5
7
  Lumos is a lightweight, beginner-friendly interpreted programming language designed for learning, experimentation, and scripting.
package/index.html ADDED
@@ -0,0 +1,271 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="UTF-8" />
4
+ <title>Lumos</title>
5
+ <link rel="apple-touch-icon" sizes="180x180" href="https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.png" />
6
+ <link rel="icon" type="image/x-icon" href="https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.ico" />
7
+ <style>
8
+ body {
9
+ font-family: monospace;
10
+ background: #1e1e1e;
11
+ color: #d4d4d4;
12
+ padding: 1em;
13
+ }
14
+ .header {
15
+ display: flex;
16
+ }
17
+ h1 {
18
+ font-size: 4em;
19
+ display: inline-block;
20
+ vertical-align: middle;
21
+ }
22
+ h3 {
23
+ font-size: 2em;
24
+ }
25
+ iframe {
26
+ display: block;
27
+ margin: 0 auto;
28
+ }
29
+ img {
30
+ width: 10%;
31
+ height: 10%;
32
+ }
33
+ #output {
34
+ white-space: pre-wrap;
35
+ margin-top: 1em;
36
+ }
37
+ input[type="text"] {
38
+ width: 100%;
39
+ padding: 0.5em;
40
+ background: #2e2e2e;
41
+ color: white;
42
+ border: none;
43
+ }
44
+ .history-item {
45
+ cursor: pointer;
46
+ color: #9cdcfe;
47
+ }
48
+ #compileButton {
49
+ margin-top: 1em;
50
+ background: #007acc;
51
+ color: white;
52
+ border: none;
53
+ padding: 0.5em 1em;
54
+ cursor: pointer;
55
+ font-weight: bold;
56
+ }
57
+ #compileButton:hover {
58
+ background: #005f9e;
59
+ }
60
+ h5 {
61
+ text-align: center;
62
+ }
63
+ </style>
64
+ </head>
65
+ <body>
66
+ <div class="header">
67
+ <img src="https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.png?v=1748865997035" />
68
+ <h1>Lumos</h1>
69
+ </div>
70
+ <input type="text" id="input" placeholder="Enter command..." />
71
+ <button id="compileButton">Compile</button>
72
+ <br />
73
+ <h3>Usage</h3>
74
+ <iframe src="https://cdn.glitch.global/a6e15949-0cae-4ce8-a653-5883a6d0adc5/Lumos.pdf?v=1748869028196" width="80%" height="50%"></iframe>
75
+ <div id="output"></div>
76
+ <script>
77
+ class BreakException {}
78
+ class ContinueException {}
79
+
80
+ const vars = {};
81
+ const functions = {};
82
+ const history = [];
83
+
84
+ function evaluateExpression(expr) {
85
+ try {
86
+ return Function(...Object.keys(vars), `return (${expr})`)(...Object.values(vars));
87
+ } catch (e) {
88
+ throw new Error("Invalid expression: " + expr);
89
+ }
90
+ }
91
+
92
+ function preprocessCommand(command) {
93
+ command = command.replace(/\r\n/g, "\n");
94
+
95
+ const timesRegex = /^(\d+)\.times\s+do\s+\|([a-zA-Z_][a-zA-Z0-9_]*)\|([\s\S]+?)end$/;
96
+ const timesMatch = command.match(timesRegex);
97
+ if (timesMatch) {
98
+ const count = parseInt(timesMatch[1]);
99
+ const varName = timesMatch[2];
100
+ const body = timesMatch[3].trim();
101
+ let result = "";
102
+ for (let i = 0; i < count; i++) {
103
+ vars[varName] = i;
104
+ result += interpret(body) + "\n";
105
+ }
106
+ return result.trim();
107
+ }
108
+
109
+ const ifElseRegex = /^if\s*\((.+?)\)\s*\{([\s\S]+?)\}(?:\s*elsif\s*\((.+?)\)\s*\{([\s\S]+?)\})?(?:\s*else\s*\{([\s\S]+?)\})?$/;
110
+ const ifElseMatch = command.match(ifElseRegex);
111
+ if (ifElseMatch) {
112
+ const [, cond1, body1, cond2, body2, body3] = ifElseMatch;
113
+ if (evaluateExpression(cond1)) return interpret(body1.trim());
114
+ if (cond2 && evaluateExpression(cond2)) return interpret(body2.trim());
115
+ if (body3) return interpret(body3.trim());
116
+ return "If condition was false.";
117
+ }
118
+
119
+ return null;
120
+ }
121
+
122
+ function interpret(command) {
123
+ const preprocessed = preprocessCommand(command);
124
+ if (preprocessed !== null) return preprocessed;
125
+
126
+ command = command.trim();
127
+
128
+ if (/^let\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$/.test(command)) {
129
+ const [, name, value] = command.match(/^let\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$/);
130
+ vars[name] = evaluateExpression(value);
131
+ return `${name} = ${vars[name]}`;
132
+ }
133
+
134
+ if (/^def\s+([a-zA-Z_][a-zA-Z0-9_]*)\(([^)]*)\)\s*\{([\s\S]*)\}$/.test(command)) {
135
+ const [, name, args, body] = command.match(/^def\s+([a-zA-Z_][a-zA-Z0-9_]*)\(([^)]*)\)\s*\{([\s\S]*)\}$/);
136
+ functions[name] = {
137
+ args: args.split(",").map((s) => s.trim()).filter((s) => s),
138
+ body: body.trim(),
139
+ };
140
+ return `Function ${name} defined.`;
141
+ }
142
+
143
+ if (/^([a-zA-Z_][a-zA-Z0-9_]*)\((.*)\)$/.test(command)) {
144
+ const [, name, argstr] = command.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\((.*)\)$/);
145
+ if (!functions[name]) throw new Error("Undefined function: " + name);
146
+ const func = functions[name];
147
+ const argValues = argstr.split(",").map((s) => evaluateExpression(s.trim()));
148
+ const localVars = {};
149
+ func.args.forEach((arg, i) => (localVars[arg] = argValues[i]));
150
+
151
+ const prevVars = Object.assign({}, vars);
152
+ Object.assign(vars, localVars);
153
+
154
+ let result;
155
+ try {
156
+ result = interpret(func.body);
157
+ } finally {
158
+ Object.assign(vars, prevVars);
159
+ }
160
+ return result;
161
+ }
162
+
163
+ let loopMatch = command.match(/^for\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+?)\s+to\s+(.+?)\s*\{([\s\S]+)\}$/);
164
+ if (loopMatch) {
165
+ const vname = loopMatch[1];
166
+ const start = evaluateExpression(loopMatch[2]);
167
+ const end = evaluateExpression(loopMatch[3]);
168
+ const body = loopMatch[4];
169
+
170
+ for (let i = start; i <= end; i++) {
171
+ vars[vname] = i;
172
+ try {
173
+ interpret(body.trim());
174
+ } catch (e) {
175
+ if (e instanceof BreakException) break;
176
+ if (e instanceof ContinueException) continue;
177
+ throw e;
178
+ }
179
+ }
180
+ return `Looped ${vname} from ${start} to ${end}`;
181
+ }
182
+
183
+ let whileMatch = command.match(/^while\s*\((.+?)\)\s*\{([\s\S]+)\}$/);
184
+ if (whileMatch) {
185
+ const condition = whileMatch[1];
186
+ const body = whileMatch[2];
187
+
188
+ while (evaluateExpression(condition)) {
189
+ try {
190
+ interpret(body.trim());
191
+ } catch (e) {
192
+ if (e instanceof BreakException) break;
193
+ if (e instanceof ContinueException) continue;
194
+ throw e;
195
+ }
196
+ }
197
+ return "While loop executed.";
198
+ }
199
+
200
+ if (command === "break") throw new BreakException();
201
+ if (command === "continue") throw new ContinueException();
202
+
203
+ return evaluateExpression(command);
204
+ }
205
+
206
+ const input = document.getElementById("input");
207
+ const output = document.getElementById("output");
208
+
209
+ input.addEventListener("keydown", function (e) {
210
+ if (e.key === "Enter") {
211
+ const command = input.value.trim();
212
+ if (command === "") return;
213
+
214
+ history.push(command);
215
+
216
+ const historyItem = document.createElement("div");
217
+ historyItem.className = "history-item";
218
+ historyItem.textContent = command;
219
+ historyItem.onclick = () => {
220
+ input.value = command;
221
+ input.focus();
222
+ };
223
+ output.appendChild(historyItem);
224
+
225
+ try {
226
+ const result = interpret(command);
227
+ const resultDiv = document.createElement("div");
228
+ resultDiv.textContent = `> ${result}`;
229
+ output.appendChild(resultDiv);
230
+ } catch (err) {
231
+ const errorDiv = document.createElement("div");
232
+ errorDiv.textContent = `! ${err.message}`;
233
+ errorDiv.style.color = "red";
234
+ output.appendChild(errorDiv);
235
+ }
236
+
237
+ input.value = "";
238
+ }
239
+ });
240
+
241
+ document.getElementById("compileButton").addEventListener("click", () => {
242
+ output.appendChild(document.createElement("hr"));
243
+
244
+ for (let i = 0; i < history.length; i++) {
245
+ const command = history[i];
246
+ const lineHeader = `Line ${i + 1}: `;
247
+
248
+ const historyLine = document.createElement("div");
249
+ historyLine.className = "history-item";
250
+ historyLine.textContent = lineHeader + command;
251
+ output.appendChild(historyLine);
252
+
253
+ try {
254
+ const result = interpret(command);
255
+ const resultDiv = document.createElement("div");
256
+ resultDiv.textContent = `> ${result}`;
257
+ output.appendChild(resultDiv);
258
+ } catch (err) {
259
+ const errorDiv = document.createElement("div");
260
+ errorDiv.textContent = `! ${err.message}`;
261
+ errorDiv.style.color = "red";
262
+ output.appendChild(errorDiv);
263
+ }
264
+ }
265
+ });
266
+ </script>
267
+ <footer>
268
+ <h5>2025 © Hirotoshi Uchida</h5>
269
+ </footer>
270
+ </body>
271
+ </html>
package/package.json CHANGED
@@ -1,13 +1,26 @@
1
1
  {
2
2
  "name": "lumos-language",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Lumos - Interactive CLI",
5
5
  "main": "index.js",
6
6
  "bin": {
7
- "lumos": "./index.js"
7
+ "lumos": "index.js"
8
8
  },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Uchida16104/Lumos.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/Uchida16104/Lumos/issues"
15
+ },
16
+ "homepage": "https://lumos-language.glitch.me",
9
17
  "author": "Hirotoshi Uchida",
10
18
  "license": "MIT",
11
- "type": "module"
19
+ "type": "module",
20
+ "scripts": {
21
+ "test": "lumos"
22
+ },
23
+ "keywords": [
24
+ "programming-language"
25
+ ]
12
26
  }
13
-