lny-interpreter 0.99.0
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.
Potentially problematic release.
This version of lny-interpreter might be problematic. Click here for more details.
- package/.vscode/launch.json +19 -0
- package/README.md +96 -0
- package/book_ALT/LennySmartIcon1.png +0 -0
- package/book_ALT/chapter01.md +141 -0
- package/book_ALT/chapter02.md +48 -0
- package/book_ALT/chapter03.md +28 -0
- package/book_ALT/chapter04.md +19 -0
- package/book_ALT/chapter05.md +21 -0
- package/book_ALT/chapter06.md +167 -0
- package/book_ALT/chapter07.md +232 -0
- package/book_ALT/chapter08.md +200 -0
- package/book_ALT/chapter09.md +175 -0
- package/book_ALT/chapter10.md +196 -0
- package/book_ALT/deckblatt.md +60 -0
- package/book_ALT/images/Lenny01.png +0 -0
- package/book_ALT/images/Lenny02.png +0 -0
- package/book_ALT/images/Lenny03.png +0 -0
- package/book_ALT/images/Lenny04.png +0 -0
- package/book_ALT/images/Lenny05.png +0 -0
- package/book_ALT/images/Lenny06.png +0 -0
- package/book_ALT/images/Lenny07.png +0 -0
- package/book_ALT/images/Lenny08.png +0 -0
- package/book_ALT/images/Lenny09.png +0 -0
- package/book_ALT/images/Lenny10.png +0 -0
- package/book_ALT/images/Lenny11.png +0 -0
- package/book_ALT/images/Lenny12.png +0 -0
- package/book_ALT/images/Lenny13.png +0 -0
- package/book_ALT/images/Lenny14.png +0 -0
- package/book_ALT/images/Lenny15.png +0 -0
- package/book_ALT/lehrerheft.md +255 -0
- package/dist/ast/ast.d.ts +126 -0
- package/dist/ast/ast.d.ts.map +1 -0
- package/dist/ast/ast.js +3 -0
- package/dist/ast/ast.js.map +1 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +1067 -0
- package/dist/browser.js.map +1 -0
- package/dist/examples.d.ts +11 -0
- package/dist/examples.d.ts.map +1 -0
- package/dist/examples.js +65 -0
- package/dist/examples.js.map +1 -0
- package/dist/i18n/i18n.d.ts +18 -0
- package/dist/i18n/i18n.d.ts.map +1 -0
- package/dist/i18n/i18n.js +505 -0
- package/dist/i18n/i18n.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/interpreter/interpreter.d.ts +40 -0
- package/dist/interpreter/interpreter.d.ts.map +1 -0
- package/dist/interpreter/interpreter.js +415 -0
- package/dist/interpreter/interpreter.js.map +1 -0
- package/dist/lexer/lexer.d.ts +87 -0
- package/dist/lexer/lexer.d.ts.map +1 -0
- package/dist/lexer/lexer.js +425 -0
- package/dist/lexer/lexer.js.map +1 -0
- package/dist/lny-config.yml +6 -0
- package/dist/parser/parser.d.ts +50 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +605 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/repl.d.ts +3 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +472 -0
- package/dist/repl.js.map +1 -0
- package/dist/run-file.d.ts +2 -0
- package/dist/run-file.d.ts.map +1 -0
- package/dist/run-file.js +140 -0
- package/dist/run-file.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +72 -0
- package/dist/test.js.map +1 -0
- package/dist/world/world.d.ts +103 -0
- package/dist/world/world.d.ts.map +1 -0
- package/dist/world/world.js +416 -0
- package/dist/world/world.js.map +1 -0
- package/docs/About.md +19 -0
- package/docs/INTERPRETER.md +240 -0
- package/docs/README.md +68 -0
- package/docs/i18n/README.md +20 -0
- package/docs/lny-referenz.md +161 -0
- package/docs/lny_ueberblick.md +33 -0
- package/examples/00-demo.lny +3 -0
- package/examples/01-variable-assignment.lny +4 -0
- package/examples/02-conditional.lny +7 -0
- package/examples/03-while-loop.lny +6 -0
- package/examples/04-for-loop.lny +5 -0
- package/examples/05-lenny-movement.lny +10 -0
- package/examples/06-procedure.lny +6 -0
- package/examples/fuer-range-1.lny +4 -0
- package/examples/fuer-range-2.lny +6 -0
- package/examples/fuer-range-3.lny +6 -0
- package/examples/fuer-range-4.lny +4 -0
- package/examples/fuer-range-5.lny +6 -0
- package/examples/solange-verschachtelt.lny +12 -0
- package/favicon.ico +0 -0
- package/index.html +108 -0
- package/jest.config.js +7 -0
- package/lny-config.yml +6 -0
- package/package.json +37 -0
- package/settings.json +4 -0
- package/src/ast/ast.ts +182 -0
- package/src/browser.ts +1274 -0
- package/src/examples.ts +68 -0
- package/src/i18n/i18n.ts +537 -0
- package/src/index.ts +6 -0
- package/src/interpreter/interpreter.ts +453 -0
- package/src/lexer/lexer.ts +493 -0
- package/src/parser/parser.ts +711 -0
- package/src/repl.ts +496 -0
- package/src/test.ts +71 -0
- package/src/world/world.ts +512 -0
- package/style.css +315 -0
- package/test1.lny +2 -0
- package/tests/interpreter.test.ts +42 -0
- package/tests/parser.test.ts +18 -0
- package/tsconfig.json +19 -0
- package/vercel.json +7 -0
- package/vscode-lny/.vscode/launch.json +13 -0
- package/vscode-lny/.vscodeignore +3 -0
- package/vscode-lny/README.md +83 -0
- package/vscode-lny/language-configuration.json +19 -0
- package/vscode-lny/license.txt +21 -0
- package/vscode-lny/lny-language-0.1.0.vsix +0 -0
- package/vscode-lny/package.json +41 -0
- package/vscode-lny/snippets/lny.json +136 -0
- package/vscode-lny/syntaxes/lny.tmLanguage.json +85 -0
package/index.html
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="de">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Lny 1.0 Interpreter - Browser REPL</title>
|
|
7
|
+
<link rel="icon" type="image/x-icon" href="./favicon.ico">
|
|
8
|
+
<link rel="stylesheet" href="./style.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div class="container">
|
|
12
|
+
<div class="sidebar">
|
|
13
|
+
<div class="sidebar-scroll">
|
|
14
|
+
<details class="sidebar-group">
|
|
15
|
+
<summary>Kernbefehle</summary>
|
|
16
|
+
<ul id="kernCommandsList"></ul>
|
|
17
|
+
</details>
|
|
18
|
+
|
|
19
|
+
<details class="sidebar-group">
|
|
20
|
+
<summary>Weltbefehle</summary>
|
|
21
|
+
<ul id="worldCommandsList"></ul>
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<details class="sidebar-group">
|
|
25
|
+
<summary>Operatoren</summary>
|
|
26
|
+
<ul id="operatorsList"></ul>
|
|
27
|
+
</details>
|
|
28
|
+
|
|
29
|
+
<details class="sidebar-group" open>
|
|
30
|
+
<summary>Examples</summary>
|
|
31
|
+
<ul id="exampleScriptsList"></ul>
|
|
32
|
+
</details>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div class="state-panel">
|
|
36
|
+
<h3>Lenny State</h3>
|
|
37
|
+
<div id="lennyState"></div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="main">
|
|
42
|
+
<div class="header">
|
|
43
|
+
<h1>Lny 1.0 Interpreter</h1>
|
|
44
|
+
<div style="display: flex; align-items: center; gap: 10px;">
|
|
45
|
+
<div class="language-selector">
|
|
46
|
+
<button class="lang-btn active" data-lang="de">Deutsch</button>
|
|
47
|
+
<button class="lang-btn" data-lang="en">English</button>
|
|
48
|
+
<button class="lang-btn" data-lang="fr">Français</button>
|
|
49
|
+
<button class="lang-btn" data-lang="es">Español</button>
|
|
50
|
+
<button class="lang-btn" data-lang="it">Italiano</button>
|
|
51
|
+
</div>
|
|
52
|
+
<button id="themeToggleBtn" title="Dark/Light Mode umschalten" style="padding: 5px 12px; font-size: 15px; border-radius: 4px; border: 1px solid var(--color-border); background: var(--color-btn-bg); color: var(--color-btn-text); cursor: pointer;">🌙</button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div class="split">
|
|
57
|
+
<div>
|
|
58
|
+
<div class="editor-label">Code Editor</div>
|
|
59
|
+
<div class="editor">
|
|
60
|
+
<textarea id="codeEditor" placeholder="Schreib hier deinen Lny-Code..."></textarea>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div>
|
|
65
|
+
<div class="console-header">
|
|
66
|
+
<span>Output</span>
|
|
67
|
+
<button id="clearConsoleBtn" class="console-clear-btn">Clear Console</button>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="console" id="console"></div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<div class="controls">
|
|
74
|
+
<button id="runBtn">▶ Run</button>
|
|
75
|
+
<button id="clearBtn">Clear</button>
|
|
76
|
+
<button id="saveBtn">💾 Save</button>
|
|
77
|
+
<button id="loadBtn">📂 Load</button>
|
|
78
|
+
<button id="helpBtn">Help</button>
|
|
79
|
+
<button id="aboutBtn">About</button>
|
|
80
|
+
<input type="file" id="fileInput" accept=".lny,text/plain" style="display:none">
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<div id="helpModal" class="help-modal" role="dialog" aria-modal="true" aria-hidden="true" aria-labelledby="helpModalTitle">
|
|
86
|
+
<!-- About Modal (hidden by default, shown via JS) -->
|
|
87
|
+
<div id="aboutModal" class="help-modal" role="dialog" aria-modal="true" aria-hidden="true" aria-labelledby="aboutModalTitle" style="display:none;">
|
|
88
|
+
<div class="help-panel">
|
|
89
|
+
<div class="help-header">
|
|
90
|
+
<h2 id="aboutModalTitle">About</h2>
|
|
91
|
+
<button id="closeAboutBtn" class="help-close-btn">Schliessen</button>
|
|
92
|
+
</div>
|
|
93
|
+
<div id="aboutContent" class="help-content"></div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="help-panel">
|
|
97
|
+
<div class="help-header">
|
|
98
|
+
<h2 id="helpModalTitle">Vollstaendige Dokumentation</h2>
|
|
99
|
+
<button id="closeHelpBtn" class="help-close-btn">Schliessen</button>
|
|
100
|
+
</div>
|
|
101
|
+
<div id="helpContent" class="help-content"></div>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
<!-- Die Modale für About und Lny-Book werden dynamisch per JS erzeugt -->
|
|
105
|
+
|
|
106
|
+
<script src="./app.js"></script>
|
|
107
|
+
</body>
|
|
108
|
+
</html>
|
package/jest.config.js
ADDED
package/lny-config.yml
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lny-interpreter",
|
|
3
|
+
"version": "0.99.0",
|
|
4
|
+
"description": "Interpreter for the lny programming language with multilingual support",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc && npm run build:web && npm run copy-config",
|
|
8
|
+
"copy-config": "copy lny-config.yml dist/lny-config.yml",
|
|
9
|
+
"build:web": "esbuild src/browser.ts --bundle --format=iife --platform=browser --outfile=app.js",
|
|
10
|
+
"start:repl": "node dist/repl.js",
|
|
11
|
+
"dev": "tsc --watch",
|
|
12
|
+
"test": "tsc && node dist/test.js"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"interpreter",
|
|
16
|
+
"lny",
|
|
17
|
+
"programming-language"
|
|
18
|
+
],
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/jest": "^29.0.0",
|
|
23
|
+
"@types/js-yaml": "^4.0.9",
|
|
24
|
+
"@types/node": "^20.0.0",
|
|
25
|
+
"esbuild": "^0.25.0",
|
|
26
|
+
"jest": "^29.0.0",
|
|
27
|
+
"readline": "^1.3.0",
|
|
28
|
+
"ts-jest": "^29.0.0",
|
|
29
|
+
"typescript": "^5.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"js-yaml": "^4.1.0"
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"lny": "dist/repl.js"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/settings.json
ADDED
package/src/ast/ast.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
export interface RangeLiteral extends ASTNode {
|
|
2
|
+
type: 'RangeLiteral';
|
|
3
|
+
start: Expression;
|
|
4
|
+
end: Expression;
|
|
5
|
+
}
|
|
6
|
+
// AST Node Types for Lny 1.0
|
|
7
|
+
|
|
8
|
+
export interface ASTNode {
|
|
9
|
+
type: string;
|
|
10
|
+
line?: number;
|
|
11
|
+
column?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Literals
|
|
15
|
+
export interface NumberLiteral extends ASTNode {
|
|
16
|
+
type: 'NumberLiteral';
|
|
17
|
+
value: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface StringLiteral extends ASTNode {
|
|
21
|
+
type: 'StringLiteral';
|
|
22
|
+
value: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BooleanLiteral extends ASTNode {
|
|
26
|
+
type: 'BooleanLiteral';
|
|
27
|
+
value: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface NothingLiteral extends ASTNode {
|
|
31
|
+
type: 'NothingLiteral';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ListLiteral extends ASTNode {
|
|
35
|
+
type: 'ListLiteral';
|
|
36
|
+
elements: Expression[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Variables and Identifiers
|
|
40
|
+
export interface Identifier extends ASTNode {
|
|
41
|
+
type: 'Identifier';
|
|
42
|
+
name: string;
|
|
43
|
+
line?: number;
|
|
44
|
+
column?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface VariableDeclaration extends ASTNode {
|
|
48
|
+
type: 'VariableDeclaration';
|
|
49
|
+
name: string;
|
|
50
|
+
initialValue?: Expression;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Expressions
|
|
54
|
+
export type Expression =
|
|
55
|
+
| NumberLiteral
|
|
56
|
+
| StringLiteral
|
|
57
|
+
| BooleanLiteral
|
|
58
|
+
| NothingLiteral
|
|
59
|
+
| ListLiteral
|
|
60
|
+
| RangeLiteral
|
|
61
|
+
| Identifier
|
|
62
|
+
| BinaryExpression
|
|
63
|
+
| UnaryExpression
|
|
64
|
+
| CallExpression
|
|
65
|
+
| ParenthesizedExpression
|
|
66
|
+
| PrivateAttribute
|
|
67
|
+
| GlobalAttribute;
|
|
68
|
+
|
|
69
|
+
export interface BinaryExpression extends ASTNode {
|
|
70
|
+
type: 'BinaryExpression';
|
|
71
|
+
left: Expression;
|
|
72
|
+
operator: string;
|
|
73
|
+
right: Expression;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface UnaryExpression extends ASTNode {
|
|
77
|
+
type: 'UnaryExpression';
|
|
78
|
+
operator: string;
|
|
79
|
+
argument: Expression;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface CallExpression extends ASTNode {
|
|
83
|
+
type: 'CallExpression';
|
|
84
|
+
callee: Identifier;
|
|
85
|
+
arguments: Expression[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ParenthesizedExpression extends ASTNode {
|
|
89
|
+
type: 'ParenthesizedExpression';
|
|
90
|
+
expression: Expression;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface PrivateAttribute extends ASTNode {
|
|
94
|
+
type: 'PrivateAttribute';
|
|
95
|
+
name: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface GlobalAttribute extends ASTNode {
|
|
99
|
+
type: 'GlobalAttribute';
|
|
100
|
+
name: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Statements
|
|
104
|
+
export type Statement =
|
|
105
|
+
| ExpressionStatement
|
|
106
|
+
| VariableDeclaration
|
|
107
|
+
| VariableAssignment
|
|
108
|
+
| IfStatement
|
|
109
|
+
| WhileStatement
|
|
110
|
+
| ForStatement
|
|
111
|
+
| ProcedureDeclaration
|
|
112
|
+
| ReturnStatement
|
|
113
|
+
| Block
|
|
114
|
+
| LogStatement
|
|
115
|
+
| CommentStatement;
|
|
116
|
+
|
|
117
|
+
export interface ExpressionStatement extends ASTNode {
|
|
118
|
+
type: 'ExpressionStatement';
|
|
119
|
+
expression: Expression;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface VariableAssignment extends ASTNode {
|
|
123
|
+
type: 'VariableAssignment';
|
|
124
|
+
name: string;
|
|
125
|
+
operator: string; // <<, +=, -=, *=, /=
|
|
126
|
+
value: Expression;
|
|
127
|
+
line?: number;
|
|
128
|
+
column?: number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface IfStatement extends ASTNode {
|
|
132
|
+
type: 'IfStatement';
|
|
133
|
+
condition: Expression;
|
|
134
|
+
consequent: Statement[];
|
|
135
|
+
alternate?: Statement[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface WhileStatement extends ASTNode {
|
|
139
|
+
type: 'WhileStatement';
|
|
140
|
+
condition: Expression;
|
|
141
|
+
body: Statement[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ForStatement extends ASTNode {
|
|
145
|
+
type: 'ForStatement';
|
|
146
|
+
variable: string;
|
|
147
|
+
iterable: Expression;
|
|
148
|
+
body: Statement[];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface ProcedureDeclaration extends ASTNode {
|
|
152
|
+
type: 'ProcedureDeclaration';
|
|
153
|
+
name: string;
|
|
154
|
+
parameters: string[];
|
|
155
|
+
body: Statement[];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface ReturnStatement extends ASTNode {
|
|
159
|
+
type: 'ReturnStatement';
|
|
160
|
+
argument?: Expression;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface Block extends ASTNode {
|
|
164
|
+
type: 'Block';
|
|
165
|
+
statements: Statement[];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface LogStatement extends ASTNode {
|
|
169
|
+
type: 'LogStatement';
|
|
170
|
+
expression: Expression;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface CommentStatement extends ASTNode {
|
|
174
|
+
type: 'CommentStatement';
|
|
175
|
+
text: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Program (root node)
|
|
179
|
+
export interface Program extends ASTNode {
|
|
180
|
+
type: 'Program';
|
|
181
|
+
body: Statement[];
|
|
182
|
+
}
|