dirac-lang 0.1.24 → 0.1.26

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 (221) hide show
  1. package/dist/cli.js +13 -1
  2. package/lib/index.di +9 -0
  3. package/{examples/lib → lib}/math.di +3 -3
  4. package/package.json +13 -1
  5. package/.env.example +0 -8
  6. package/COMMUNITY.md +0 -465
  7. package/CONDITIONAL-TAGS.md +0 -172
  8. package/EXCEPTION-HANDLING.md +0 -156
  9. package/LIBRARIES.md +0 -172
  10. package/LLM-VALIDATION.md +0 -128
  11. package/NAMESPACES.md +0 -366
  12. package/PROMOTION.md +0 -257
  13. package/QUICKSTART-LIBRARY.md +0 -93
  14. package/TEST-COVERAGE.md +0 -113
  15. package/TESTING.md +0 -162
  16. package/config.test.yml +0 -5
  17. package/dirac-http/examples/demo.di +0 -9
  18. package/dirac-http/lib/index.di +0 -12
  19. package/examples/add-demo.di +0 -74
  20. package/examples/add.bk +0 -11
  21. package/examples/advanced-math-demo.di +0 -53
  22. package/examples/calculator.di +0 -32
  23. package/examples/compact-test.di +0 -6
  24. package/examples/comprehensive.bk +0 -29
  25. package/examples/defvar-variable-demo.di +0 -18
  26. package/examples/direct-call.di +0 -17
  27. package/examples/disk-analysis.di +0 -16
  28. package/examples/exception-demo.di +0 -82
  29. package/examples/executable-hello.di +0 -7
  30. package/examples/execute-demo.di +0 -38
  31. package/examples/file-manager.di +0 -77
  32. package/examples/file-stats.di +0 -18
  33. package/examples/hello.bk +0 -1
  34. package/examples/hello.di +0 -5
  35. package/examples/if-comparison.di +0 -91
  36. package/examples/if-cstyle-test.di +0 -149
  37. package/examples/if-vs-testif.di +0 -56
  38. package/examples/import-demo.di +0 -31
  39. package/examples/inline-test.bk +0 -7
  40. package/examples/llm-agent.di +0 -32
  41. package/examples/llm-basic.di +0 -12
  42. package/examples/llm-command-more.di +0 -6
  43. package/examples/llm-command-no-exec.di +0 -13
  44. package/examples/llm-command.di +0 -6
  45. package/examples/llm-complex.di +0 -141
  46. package/examples/llm-feedback-debug.di +0 -30
  47. package/examples/llm-feedback-demo.di +0 -19
  48. package/examples/llm-feedback-math.di +0 -22
  49. package/examples/llm-feedback-simple.di +0 -16
  50. package/examples/llm-feedback-sub.di +0 -22
  51. package/examples/llm-no-feedback.di +0 -10
  52. package/examples/llm-recursive.di +0 -31
  53. package/examples/llm-reflection-test.di +0 -19
  54. package/examples/llm-simple-test.di +0 -12
  55. package/examples/llm-subs.di +0 -132
  56. package/examples/llm-use-subs.di +0 -6
  57. package/examples/llm-validate-test.di +0 -18
  58. package/examples/loop.di +0 -12
  59. package/examples/math-test.di +0 -22
  60. package/examples/minimal-test.di +0 -13
  61. package/examples/mongodb-context-test.di +0 -27
  62. package/examples/mongodb-count-events.di +0 -8
  63. package/examples/mongodb-import-demo.di +0 -25
  64. package/examples/mongodb-simple-test.di +0 -18
  65. package/examples/nl-agent.di +0 -47
  66. package/examples/parameters-demo.di +0 -68
  67. package/examples/params-meta-test.di +0 -17
  68. package/examples/params-test.di +0 -10
  69. package/examples/recipe-chain.di +0 -38
  70. package/examples/recursive-llm.di +0 -44
  71. package/examples/sample-library/README.md +0 -152
  72. package/examples/sample-library/examples/demo.di +0 -34
  73. package/examples/sample-library/lib/index.di +0 -65
  74. package/examples/sample-library/package.json +0 -31
  75. package/examples/scope-test-nested.di +0 -60
  76. package/examples/scope-test.di +0 -55
  77. package/examples/seamless.di +0 -45
  78. package/examples/shell-test.bk +0 -10
  79. package/examples/simple-import.di +0 -13
  80. package/examples/simple-recursive.di +0 -26
  81. package/examples/story-builder.di +0 -45
  82. package/examples/subroutine.di +0 -23
  83. package/examples/system-llm.di +0 -21
  84. package/examples/system-simple.di +0 -3
  85. package/examples/system-test.di +0 -8
  86. package/examples/tag-check-test.di +0 -139
  87. package/examples/task-assistant.di +0 -27
  88. package/examples/test-if-demo.di +0 -110
  89. package/examples/test-parameters.di +0 -50
  90. package/examples/try-catch-test.di +0 -118
  91. package/examples/two-styles.di +0 -28
  92. package/examples/var-debug.di +0 -6
  93. package/examples/var-inline.di +0 -4
  94. package/examples/var-test2.di +0 -6
  95. package/examples/variable-replace.di +0 -25
  96. package/examples/variable-simple.di +0 -16
  97. package/examples/variable-test.di +0 -22
  98. package/examples/whitespace-test.di +0 -24
  99. package/filePath +0 -1
  100. package/greeting.txt +0 -1
  101. package/src/cli.ts +0 -140
  102. package/src/index.ts +0 -33
  103. package/src/llm/ollama.ts +0 -58
  104. package/src/runtime/braket-parser.ts +0 -234
  105. package/src/runtime/interpreter.ts +0 -203
  106. package/src/runtime/parser.ts +0 -155
  107. package/src/runtime/session.ts +0 -325
  108. package/src/tags/assign.ts +0 -37
  109. package/src/tags/attr.ts +0 -64
  110. package/src/tags/available-subroutines.ts +0 -70
  111. package/src/tags/call.ts +0 -259
  112. package/src/tags/catch.ts +0 -24
  113. package/src/tags/defvar.ts +0 -115
  114. package/src/tags/environment.ts +0 -21
  115. package/src/tags/eval.ts +0 -71
  116. package/src/tags/exception.ts +0 -20
  117. package/src/tags/execute.ts +0 -52
  118. package/src/tags/expr.ts +0 -128
  119. package/src/tags/foreach.ts +0 -170
  120. package/src/tags/if.ts +0 -191
  121. package/src/tags/import.ts +0 -135
  122. package/src/tags/index.ts +0 -41
  123. package/src/tags/input.ts +0 -182
  124. package/src/tags/llm.ts +0 -415
  125. package/src/tags/loop.ts +0 -43
  126. package/src/tags/mongodb.ts +0 -70
  127. package/src/tags/output.ts +0 -53
  128. package/src/tags/parameters.ts +0 -81
  129. package/src/tags/require_module.ts +0 -19
  130. package/src/tags/subroutine.ts +0 -75
  131. package/src/tags/system.ts +0 -93
  132. package/src/tags/tag-check.ts +0 -176
  133. package/src/tags/test-if.ts +0 -112
  134. package/src/tags/throw.ts +0 -26
  135. package/src/tags/try.ts +0 -19
  136. package/src/tags/variable.ts +0 -25
  137. package/src/test-runner.ts +0 -300
  138. package/src/types/index.ts +0 -128
  139. package/src/utils/llm-adapter.ts +0 -113
  140. package/src/utils/tag-validator.ts +0 -231
  141. package/test-available-extends.di +0 -28
  142. package/test-available-simple.di +0 -12
  143. package/test-available-subroutines.di +0 -16
  144. package/test-call.di +0 -9
  145. package/test-extend-basic.di +0 -17
  146. package/test-extend-chain.di +0 -26
  147. package/test-extend-debug.di +0 -17
  148. package/test-extend-debug2.di +0 -15
  149. package/test-extend-person.di +0 -17
  150. package/test-extend-simple.di +0 -11
  151. package/test-extend-zhi.di +0 -23
  152. package/test-extend.di +0 -19
  153. package/test-extend2.di +0 -26
  154. package/test-extend3-fixed.di +0 -23
  155. package/test-extend3-trouble.di +0 -23
  156. package/test-extend3.di +0 -21
  157. package/test-factorial.di +0 -19
  158. package/test-input-debug.di +0 -19
  159. package/test-nested-debug.di +0 -7
  160. package/test-nested-debug2.di +0 -8
  161. package/test-no-extend.di +0 -16
  162. package/test-simple-call.di +0 -7
  163. package/test-simple.di +0 -6
  164. package/tests/README.md +0 -69
  165. package/tests/assign-basic.test.di +0 -7
  166. package/tests/assign-from-eval.test.di +0 -7
  167. package/tests/available-subroutines-foreach.test.di +0 -32
  168. package/tests/basic-output.test.di +0 -5
  169. package/tests/call-basic.test.di +0 -11
  170. package/tests/call-with-output.test.di +0 -10
  171. package/tests/comments-before-content.test.di +0 -6
  172. package/tests/defvar-multiple.test.di +0 -8
  173. package/tests/environment-basic.test.di +0 -22
  174. package/tests/environment-nonexistent.test.di +0 -5
  175. package/tests/environment-with-defvar.test.di +0 -15
  176. package/tests/eval-basic.test.di +0 -6
  177. package/tests/eval-with-variables.test.di +0 -8
  178. package/tests/exception-basic.test.di +0 -10
  179. package/tests/expr-basic.test.di +0 -11
  180. package/tests/extend-basic.test.di +0 -19
  181. package/tests/extend-inheritance-chain.test.di +0 -26
  182. package/tests/extend-multiple-nested.test.di +0 -24
  183. package/tests/extend-self.test.di +0 -19
  184. package/tests/extend-with-parameters.test.di +0 -14
  185. package/tests/generate-dirac.test.di +0 -22
  186. package/tests/if-conditional.test.di +0 -17
  187. package/tests/if-else.test.di +0 -11
  188. package/tests/if-with-variables.test.di +0 -8
  189. package/tests/import-basic.test.di +0 -6
  190. package/tests/input-file-all.test.di +0 -5
  191. package/tests/input-file-line.test.di +0 -15
  192. package/tests/input-file-loop.test.di +0 -12
  193. package/tests/input-stdin-all.test.di +0 -8
  194. package/tests/input-stdin-all.txt +0 -1
  195. package/tests/llm-validate.test.di +0 -17
  196. package/tests/loop-basic.test.di +0 -9
  197. package/tests/loop-nested.test.di +0 -10
  198. package/tests/loop-with-eval.test.di +0 -8
  199. package/tests/no-root-element.test.di +0 -6
  200. package/tests/output-file.test.di +0 -19
  201. package/tests/output-multiple.test.di +0 -9
  202. package/tests/parameters-basic.test.di +0 -6
  203. package/tests/require-module-basic.test.di +0 -7
  204. package/tests/subroutine-basic.test.di +0 -9
  205. package/tests/subroutine-multiple-params.test.di +0 -10
  206. package/tests/subroutine-nested-calls.test.di +0 -32
  207. package/tests/subroutine-sequential-calls.test.di +0 -36
  208. package/tests/system-background.test.di +0 -39
  209. package/tests/system-basic.test.di +0 -5
  210. package/tests/tag-check.test.di +0 -27
  211. package/tests/test-if-basic.test.di +0 -8
  212. package/tests/test-input.txt +0 -3
  213. package/tests/try-catch-basic.test.di +0 -10
  214. package/tests/try-catch-eval-error.test.di +0 -10
  215. package/tests/variable-basic.test.di +0 -6
  216. package/tests/variable-interpolation.test.di +0 -7
  217. package/tools/create-library.sh +0 -175
  218. package/tsconfig.json +0 -19
  219. /package/{examples/lib → lib}/advanced-math.di +0 -0
  220. /package/{examples/lib → lib}/fileops.di +0 -0
  221. /package/{examples/lib → lib}/mongodb.di +0 -0
@@ -1,231 +0,0 @@
1
- /**
2
- * Tag validation utilities
3
- * Provides reusable validation logic for tag-check and LLM execution
4
- */
5
-
6
- import type { DiracSession, DiracElement, Subroutine } from '../types/index.js';
7
- import fs from 'fs';
8
- import yaml from 'js-yaml';
9
-
10
- // Configurable similarity cutoff
11
- const SIMILARITY_CUTOFF = 0.75;
12
-
13
- export interface ValidationResult {
14
- valid: boolean;
15
- tagName: string;
16
- originalTag: string;
17
- corrected: boolean;
18
- errors: string[];
19
- warnings: string[];
20
- similarity?: number;
21
- }
22
-
23
- // Helper: get embedding server config from config.yml
24
- function getEmbeddingServerConfig() {
25
- try {
26
- const configPath = process.env.DIRAC_CONFIG || 'config.yml';
27
- const config = yaml.load(fs.readFileSync(configPath, 'utf8')) as any;
28
- const host = config.embeddingServer?.host || 'localhost';
29
- const port = config.embeddingServer?.port || 11434;
30
- const model = config.embeddingServer?.model || 'embeddinggemma';
31
- return { host, port, model };
32
- } catch (e) {
33
- // Fallback to defaults if config file not found
34
- return { host: 'localhost', port: 11434, model: 'embeddinggemma' };
35
- }
36
- }
37
-
38
- // Helper: call Ollama embedding API directly
39
- async function getEmbeddings(tags: string[]): Promise<number[][]> {
40
- const { host, port, model } = getEmbeddingServerConfig();
41
- return await Promise.all(tags.map(async tag => {
42
- const response = await fetch(`http://${host}:${port}/api/embeddings`, {
43
- method: 'POST',
44
- headers: { 'Content-Type': 'application/json' },
45
- body: JSON.stringify({ model, prompt: tag })
46
- });
47
- const data = await response.json();
48
- return data.embedding;
49
- }));
50
- }
51
-
52
- function cosine(a: number[], b: number[]): number {
53
- const dot = a.reduce((sum, v, i) => sum + v * b[i], 0);
54
- const normA = Math.sqrt(a.reduce((sum, v) => sum + v * v, 0));
55
- const normB = Math.sqrt(b.reduce((sum, v) => sum + v * v, 0));
56
- return dot / (normA * normB);
57
- }
58
-
59
- async function getBestTagMatch(candidate: string, allowed: string[]): Promise<{tag: string, score: number}> {
60
- const tags = [candidate, ...allowed];
61
- const embeddings = await getEmbeddings(tags);
62
- const candidateVec = embeddings[0];
63
- const allowedVecs = embeddings.slice(1);
64
- let bestIdx = 0, bestScore = -1;
65
- allowedVecs.forEach((vec, i) => {
66
- const score = cosine(candidateVec, vec);
67
- if (score > bestScore) { bestScore = score; bestIdx = i; }
68
- });
69
- return { tag: allowed[bestIdx], score: bestScore };
70
- }
71
-
72
- /**
73
- * Validate a single tag element against available subroutines
74
- */
75
- export async function validateTag(
76
- session: DiracSession,
77
- element: DiracElement,
78
- options: {
79
- autocorrect?: boolean;
80
- similarityCutoff?: number;
81
- } = {}
82
- ): Promise<ValidationResult> {
83
- const { autocorrect = false, similarityCutoff = SIMILARITY_CUTOFF } = options;
84
-
85
- // Get allowed subroutine names
86
- const { getAvailableSubroutines } = await import('../runtime/session.js');
87
- const subroutines = getAvailableSubroutines(session);
88
- const allowed = new Set(subroutines.map(s => s.name));
89
-
90
- const tagName = element.tag;
91
- const result: ValidationResult = {
92
- valid: false,
93
- tagName,
94
- originalTag: tagName,
95
- corrected: false,
96
- errors: [],
97
- warnings: [],
98
- };
99
-
100
- // Check if tag exists
101
- if (allowed.has(tagName)) {
102
- // Tag name is valid, now check required and unknown parameters
103
- const sub = subroutines.find(s => s.name === tagName);
104
- if (sub && Array.isArray(sub.parameters)) {
105
- const paramNames = sub.parameters.map(p => p.name);
106
-
107
- // Check for missing required parameters
108
- for (const param of sub.parameters) {
109
- if (param.required && !(param.name in element.attributes)) {
110
- result.errors.push(`Missing required parameter: ${param.name}`);
111
- }
112
- }
113
-
114
- // Check for unknown attributes
115
- for (const attr in element.attributes) {
116
- if (!paramNames.includes(attr)) {
117
- result.warnings.push(`Unknown attribute: ${attr}`);
118
- }
119
- }
120
- }
121
-
122
- result.valid = result.errors.length === 0;
123
- } else {
124
- // Tag doesn't exist, try to find semantic match
125
- const best = await getBestTagMatch(tagName, Array.from(allowed));
126
-
127
- if (best.score >= similarityCutoff) {
128
- result.similarity = best.score;
129
-
130
- if (autocorrect) {
131
- result.tagName = best.tag;
132
- result.corrected = true;
133
- result.warnings.push(`Auto-corrected from <${tagName}> to <${best.tag}> (similarity: ${best.score.toFixed(2)})`);
134
-
135
- // Validate parameters for corrected tag
136
- const sub = subroutines.find(s => s.name === best.tag);
137
- if (sub && Array.isArray(sub.parameters)) {
138
- const paramNames = sub.parameters.map(p => p.name);
139
-
140
- for (const param of sub.parameters) {
141
- if (param.required && !(param.name in element.attributes)) {
142
- result.errors.push(`Missing required parameter: ${param.name}`);
143
- }
144
- }
145
-
146
- for (const attr in element.attributes) {
147
- if (!paramNames.includes(attr)) {
148
- result.warnings.push(`Unknown attribute: ${attr}`);
149
- }
150
- }
151
- }
152
-
153
- result.valid = result.errors.length === 0;
154
- } else {
155
- result.errors.push(`Tag <${tagName}> does not exist. Did you mean <${best.tag}>? (similarity: ${best.score.toFixed(2)})`);
156
- }
157
- } else {
158
- result.errors.push(`Tag <${tagName}> does not exist and no similar tag was found.`);
159
- }
160
- }
161
-
162
- return result;
163
- }
164
-
165
- /**
166
- * Validate all child tags in a parsed Dirac AST
167
- */
168
- export async function validateDiracCode(
169
- session: DiracSession,
170
- ast: DiracElement,
171
- options: {
172
- autocorrect?: boolean;
173
- similarityCutoff?: number;
174
- } = {}
175
- ): Promise<{
176
- valid: boolean;
177
- results: ValidationResult[];
178
- errorMessages: string[];
179
- }> {
180
- const results: ValidationResult[] = [];
181
- const errorMessages: string[] = [];
182
-
183
- // Recursively validate all elements
184
- async function validateElement(element: DiracElement) {
185
- // Skip text nodes, whitespace-only tags, and root wrapper tags
186
- if (element.tag && element.tag !== 'dirac' && element.tag !== 'DIRAC-ROOT' && element.tag.trim() !== '') {
187
- const result = await validateTag(session, element, options);
188
- results.push(result);
189
-
190
- if (!result.valid) {
191
- errorMessages.push(`<${result.originalTag}>: ${result.errors.join(', ')}`);
192
- }
193
- }
194
-
195
- // Validate children
196
- for (const child of element.children) {
197
- await validateElement(child);
198
- }
199
- }
200
-
201
- await validateElement(ast);
202
-
203
- return {
204
- valid: errorMessages.length === 0,
205
- results,
206
- errorMessages,
207
- };
208
- }
209
-
210
- /**
211
- * Apply auto-corrections to a parsed Dirac AST
212
- */
213
- export function applyCorrectedTags(ast: DiracElement, results: ValidationResult[]): DiracElement {
214
- let resultIndex = 0;
215
-
216
- function correctElement(element: DiracElement): DiracElement {
217
- if (element.tag && element.tag !== 'dirac' && element.tag !== '') {
218
- const result = results[resultIndex++];
219
- if (result && result.corrected) {
220
- element = { ...element, tag: result.tagName };
221
- }
222
- }
223
-
224
- return {
225
- ...element,
226
- children: element.children.map(child => correctElement(child))
227
- };
228
- }
229
-
230
- return correctElement(ast);
231
- }
@@ -1,28 +0,0 @@
1
- <dirac>
2
- <subroutine name="Base">
3
- <subroutine name="method1" description="Base method 1">
4
- <output>Base 1</output>
5
- </subroutine>
6
- <subroutine name="method2" description="Base method 2">
7
- <output>Base 2</output>
8
- </subroutine>
9
- <output>In Base body, calling available-subroutines:</output>
10
- <output>
11
- </output>
12
- <available-subroutines />
13
- </subroutine>
14
-
15
- <subroutine name="Base" extends="">
16
- <subroutine name="method1" description="Override method 1">
17
- <output>Override 1</output>
18
- </subroutine>
19
- <subroutine name="method3" description="New method 3">
20
- <output>New 3</output>
21
- </subroutine>
22
- </subroutine>
23
-
24
- <output>Calling Base:</output>
25
- <output>
26
- </output>
27
- <Base />
28
- </dirac>
@@ -1,12 +0,0 @@
1
- <dirac>
2
- <subroutine name="Test">
3
- <subroutine name="nested1">
4
- <output>N1</output>
5
- </subroutine>
6
- <output>Boundary: <variable name="boundary" /></output>
7
- <output>, Stack size: <variable name="size" /></output>
8
- <available-subroutines />
9
- </subroutine>
10
-
11
- <Test />
12
- </dirac>
@@ -1,16 +0,0 @@
1
- <dirac>
2
- <subroutine name="Person" description="Represents a person with age and gender">
3
- <subroutine name="age" param-value="integer:required:Age of the person">
4
- <output><variable name="value" /></output>
5
- </subroutine>
6
- <subroutine name="gender" param-type="string:optional:Gender M/F">
7
- <output><variable name="type" /></output>
8
- </subroutine>
9
- <available-subroutines />
10
- </subroutine>
11
-
12
- <output>Available methods for Person:</output>
13
- <output>
14
- </output>
15
- <Person />
16
- </dirac>
package/test-call.di DELETED
@@ -1,9 +0,0 @@
1
- <dirac>
2
- <subroutine name="test" param-x="number">
3
- <output>In subroutine, x=<variable name="x" /></output>
4
- </subroutine>
5
-
6
- <output>Before call</output>
7
- <call name="test" x="5" />
8
- <output>After call</output>
9
- </dirac>
@@ -1,17 +0,0 @@
1
- <dirac>
2
- <subroutine name="parent">
3
- <subroutine name="nested">
4
- <output>Parent nested</output>
5
- </subroutine>
6
- <output>In parent, calling: </output>
7
- <call name="nested" />
8
- </subroutine>
9
-
10
- <subroutine name="child" extends="parent">
11
- <subroutine name="nested">
12
- <output>Child nested</output>
13
- </subroutine>
14
- </subroutine>
15
-
16
- <call name="child" />
17
- </dirac>
@@ -1,26 +0,0 @@
1
- <dirac>
2
- <!-- Base who subroutine -->
3
- <subroutine name="who">
4
- <subroutine name="_operation">
5
- <output>Base operation</output>
6
- </subroutine>
7
- <output>Who: </output>
8
- <call name="_operation" />
9
- </subroutine>
10
-
11
- <!-- First extension - self-extend -->
12
- <subroutine name="who" extend="">
13
- <subroutine name="_operation">
14
- <output>First extension</output>
15
- </subroutine>
16
- </subroutine>
17
-
18
- <!-- Second extension - self-extend -->
19
- <subroutine name="who" extend="">
20
- <subroutine name="_operation">
21
- <output>Second extension</output>
22
- </subroutine>
23
- </subroutine>
24
-
25
- <call name="who" />
26
- </dirac>
@@ -1,17 +0,0 @@
1
- <dirac>
2
- <!-- Define base age -->
3
- <subroutine name="age">
4
- <output>Base: 60</output>
5
- </subroutine>
6
-
7
- <!-- Call age - should show Base: 60 -->
8
- <call name="age" />
9
-
10
- <!-- Override age -->
11
- <subroutine name="age">
12
- <output>Override: 63</output>
13
- </subroutine>
14
-
15
- <!-- Call age again - should show Override: 63 -->
16
- <call name="age" />
17
- </dirac>
@@ -1,15 +0,0 @@
1
- <dirac>
2
- <!-- Simplified test -->
3
- <subroutine name="parent">
4
- <output>In parent, calling nested: </output>
5
- <call name="nested" />
6
- </subroutine>
7
-
8
- <subroutine name="child" extends="parent">
9
- <subroutine name="nested">
10
- <output>Child's nested</output>
11
- </subroutine>
12
- </subroutine>
13
-
14
- <call name="child" />
15
- </dirac>
@@ -1,17 +0,0 @@
1
- <dirac>
2
- <subroutine name="person">
3
- <subroutine name="age">
4
- <output>60</output>
5
- </subroutine>
6
- <output>Age: </output>
7
- <call name="age" />
8
- </subroutine>
9
-
10
- <subroutine name="person" extends="person">
11
- <subroutine name="age">
12
- <output>63</output>
13
- </subroutine>
14
- </subroutine>
15
-
16
- <call name="person" />
17
- </dirac>
@@ -1,11 +0,0 @@
1
- <dirac>
2
- <subroutine name="parent">
3
- <output>Parent body</output>
4
- </subroutine>
5
-
6
- <subroutine name="child" extends="parent">
7
- <output>Child body</output>
8
- </subroutine>
9
-
10
- <call name="child" />
11
- </dirac>
@@ -1,23 +0,0 @@
1
- <dirac>
2
- <subroutine name="Zhi">
3
- <subroutine name="age">
4
- <output>60</output>
5
- </subroutine>
6
- <subroutine name="gender">
7
- <output>M</output>
8
- </subroutine>
9
- <output>Age: </output>
10
- <call name="age" />
11
- <output>, Gender: </output>
12
- <call name="gender" />
13
- </subroutine>
14
-
15
- <!-- Extended Zhi with new age -->
16
- <subroutine name="Zhi" extends="Zhi">
17
- <subroutine name="age">
18
- <output>63</output>
19
- </subroutine>
20
- </subroutine>
21
-
22
- <call name="Zhi" />
23
- </dirac>
package/test-extend.di DELETED
@@ -1,19 +0,0 @@
1
- <dirac>
2
- <!-- Original Zhi subroutine -->
3
- <subroutine name="Zhi">
4
- <subroutine name="age">
5
- <output>60</output>
6
- </subroutine>
7
- <output>Name: Zhi, Age: </output>
8
- <call name="age" />
9
- </subroutine>
10
-
11
- <!-- Extended Zhi subroutine with updated age -->
12
- <subroutine name="Zhi" extends="Zhi">
13
- <subroutine name="age">
14
- <output>63</output>
15
- </subroutine>
16
- </subroutine>
17
-
18
- <call name="Zhi" />
19
- </dirac>
package/test-extend2.di DELETED
@@ -1,26 +0,0 @@
1
- <dirac>
2
- <!-- Original Zhi subroutine with nested age -->
3
- <subroutine name="Zhi">
4
- <subroutine name="age">
5
- <output>60</output>
6
- </subroutine>
7
- <output>Name: Zhi, Age: </output>
8
- <call name="age" />
9
- </subroutine>
10
-
11
- <!-- Test: call original -->
12
- <output>First call: </output>
13
- <call name="Zhi" />
14
- <output>&#10;</output>
15
-
16
- <!-- Extended Zhi with updated age -->
17
- <subroutine name="Zhi" extends="Zhi">
18
- <subroutine name="age">
19
- <output>63</output>
20
- </subroutine>
21
- </subroutine>
22
-
23
- <!-- Test: call extended -->
24
- <output>Second call: </output>
25
- <call name="Zhi" />
26
- </dirac>
@@ -1,23 +0,0 @@
1
- <dirac>
2
- <subroutine name="Zhi">
3
- <subroutine name="age">
4
- <output>60</output>
5
- </subroutine>
6
- <subroutine name="gender">
7
- <output>M</output>
8
- </subroutine>
9
- <parameters select="*" />
10
- </subroutine>
11
-
12
- <!-- Extended Zhi -->
13
- <subroutine name="Zhi" extends="Zhi">
14
- <subroutine name="age">
15
- <output>63</output>
16
- </subroutine>
17
- <parameters select="*" />
18
- </subroutine>
19
-
20
- <Zhi><age /></Zhi>
21
- <output> | </output>
22
- <Zhi><gender /></Zhi>
23
- </dirac>
@@ -1,23 +0,0 @@
1
- <dirac>
2
- <subroutine name="Zhi">
3
- <subroutine name="age">
4
- <output>60</output>
5
- </subroutine>
6
- <subroutine name="gender">
7
- <output>M</output>
8
- </subroutine>
9
- <parameters select="*" />
10
- </subroutine>
11
-
12
- <!-- Extended Zhi -->
13
- <subroutine name="Zhi" extends="Zhi" >
14
- <subroutine name="age">
15
- <output>63</output>
16
- </subroutine>
17
- <parameters select="*" />
18
- </subroutine>
19
-
20
- <Zhi><age /></Zhi>
21
- <output> | </output>
22
- <Zhi><gender /></Zhi>
23
- </dirac>
package/test-extend3.di DELETED
@@ -1,21 +0,0 @@
1
- <dirac>
2
- <!-- <subroutine name="Zhi" >
3
- <subroutine name="age">
4
- <output>60</output>
5
- </subroutine>
6
- <subroutine name="gender">
7
- <output>M</output>
8
- </subroutine>
9
- </subroutine> -->
10
-
11
- <!-- Extended Zhi -->
12
- <subroutine name="Zhi" >
13
- <subroutine name="age">
14
- <output>63</output>
15
- </subroutine>
16
- <parameters select="*" />
17
- </subroutine>
18
-
19
- <Zhi><age /></Zhi>
20
- <Zhi><gender /></Zhi>
21
- </dirac>
package/test-factorial.di DELETED
@@ -1,19 +0,0 @@
1
- <dirac>
2
- <subroutine name="factorial" param-num="number">
3
- <eval name="result">
4
- const n = parseInt(num);
5
- if (n <= 1) {
6
- return 1;
7
- } else {
8
- let fact = 1;
9
- for (let i = 2; i <= n; i++) {
10
- fact *= i;
11
- }
12
- return fact;
13
- }
14
- </eval>
15
- <output><variable name="result" /></output>
16
- </subroutine>
17
-
18
- <call name="factorial" num="5" />
19
- </dirac>
@@ -1,19 +0,0 @@
1
- <dirac>
2
- <defvar name="counter" value="0" />
3
-
4
- <loop count="4">
5
- <defvar name="line">
6
- <input source="file" path="tests/test-input.txt" mode="line" />
7
- </defvar>
8
-
9
- <test-if test="$line != ''">
10
- <assign name="counter">
11
- <eval><variable name="counter" /> + 1</eval>
12
- </assign>
13
- <variable name="counter" />
14
- <output>:</output>
15
- <variable name="line" />
16
- <output>|</output>
17
- </test-if>
18
- </loop>
19
- </dirac>
@@ -1,7 +0,0 @@
1
- <dirac>
2
- <loop count="2" var="i">
3
- <loop count="2" var="j">
4
- <output>[i=<variable name="i" /> j=<variable name="j" />] </output>
5
- </loop>
6
- </loop>
7
- </dirac>
@@ -1,8 +0,0 @@
1
- <dirac>
2
- <loop count="2" var="i">
3
- <loop count="2" var="j">
4
- <eval name="letter">return j === '0' ? 'A' : 'B';</eval>
5
- <output>[j=<variable name="j" /> letter=<variable name="letter" />] </output>
6
- </loop>
7
- </loop>
8
- </dirac>
package/test-no-extend.di DELETED
@@ -1,16 +0,0 @@
1
- <dirac>
2
- <!-- Just the extended Zhi without extends -->
3
- <subroutine name="Zhi">
4
- <subroutine name="age">
5
- <output>63</output>
6
- </subroutine>
7
- <subroutine name="gender">
8
- <output>F</output>
9
- </subroutine>
10
- <parameters select="*" />
11
- </subroutine>
12
-
13
- <Zhi><age /></Zhi>
14
- <output> | </output>
15
- <Zhi><gender /></Zhi>
16
- </dirac>
@@ -1,7 +0,0 @@
1
- <dirac>
2
- <subroutine name="Test">
3
- <output>In Test</output>
4
- </subroutine>
5
-
6
- <call name="Test" />
7
- </dirac>
package/test-simple.di DELETED
@@ -1,6 +0,0 @@
1
- <dirac>
2
- <defvar name="x" value="10" />
3
- <test-if test="$x" gt="5">
4
- <output>Greater!</output>
5
- </test-if>
6
- </dirac>