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.
- package/dist/cli.js +13 -1
- package/lib/index.di +9 -0
- package/{examples/lib → lib}/math.di +3 -3
- package/package.json +13 -1
- package/.env.example +0 -8
- package/COMMUNITY.md +0 -465
- package/CONDITIONAL-TAGS.md +0 -172
- package/EXCEPTION-HANDLING.md +0 -156
- package/LIBRARIES.md +0 -172
- package/LLM-VALIDATION.md +0 -128
- package/NAMESPACES.md +0 -366
- package/PROMOTION.md +0 -257
- package/QUICKSTART-LIBRARY.md +0 -93
- package/TEST-COVERAGE.md +0 -113
- package/TESTING.md +0 -162
- package/config.test.yml +0 -5
- package/dirac-http/examples/demo.di +0 -9
- package/dirac-http/lib/index.di +0 -12
- package/examples/add-demo.di +0 -74
- package/examples/add.bk +0 -11
- package/examples/advanced-math-demo.di +0 -53
- package/examples/calculator.di +0 -32
- package/examples/compact-test.di +0 -6
- package/examples/comprehensive.bk +0 -29
- package/examples/defvar-variable-demo.di +0 -18
- package/examples/direct-call.di +0 -17
- package/examples/disk-analysis.di +0 -16
- package/examples/exception-demo.di +0 -82
- package/examples/executable-hello.di +0 -7
- package/examples/execute-demo.di +0 -38
- package/examples/file-manager.di +0 -77
- package/examples/file-stats.di +0 -18
- package/examples/hello.bk +0 -1
- package/examples/hello.di +0 -5
- package/examples/if-comparison.di +0 -91
- package/examples/if-cstyle-test.di +0 -149
- package/examples/if-vs-testif.di +0 -56
- package/examples/import-demo.di +0 -31
- package/examples/inline-test.bk +0 -7
- package/examples/llm-agent.di +0 -32
- package/examples/llm-basic.di +0 -12
- package/examples/llm-command-more.di +0 -6
- package/examples/llm-command-no-exec.di +0 -13
- package/examples/llm-command.di +0 -6
- package/examples/llm-complex.di +0 -141
- package/examples/llm-feedback-debug.di +0 -30
- package/examples/llm-feedback-demo.di +0 -19
- package/examples/llm-feedback-math.di +0 -22
- package/examples/llm-feedback-simple.di +0 -16
- package/examples/llm-feedback-sub.di +0 -22
- package/examples/llm-no-feedback.di +0 -10
- package/examples/llm-recursive.di +0 -31
- package/examples/llm-reflection-test.di +0 -19
- package/examples/llm-simple-test.di +0 -12
- package/examples/llm-subs.di +0 -132
- package/examples/llm-use-subs.di +0 -6
- package/examples/llm-validate-test.di +0 -18
- package/examples/loop.di +0 -12
- package/examples/math-test.di +0 -22
- package/examples/minimal-test.di +0 -13
- package/examples/mongodb-context-test.di +0 -27
- package/examples/mongodb-count-events.di +0 -8
- package/examples/mongodb-import-demo.di +0 -25
- package/examples/mongodb-simple-test.di +0 -18
- package/examples/nl-agent.di +0 -47
- package/examples/parameters-demo.di +0 -68
- package/examples/params-meta-test.di +0 -17
- package/examples/params-test.di +0 -10
- package/examples/recipe-chain.di +0 -38
- package/examples/recursive-llm.di +0 -44
- package/examples/sample-library/README.md +0 -152
- package/examples/sample-library/examples/demo.di +0 -34
- package/examples/sample-library/lib/index.di +0 -65
- package/examples/sample-library/package.json +0 -31
- package/examples/scope-test-nested.di +0 -60
- package/examples/scope-test.di +0 -55
- package/examples/seamless.di +0 -45
- package/examples/shell-test.bk +0 -10
- package/examples/simple-import.di +0 -13
- package/examples/simple-recursive.di +0 -26
- package/examples/story-builder.di +0 -45
- package/examples/subroutine.di +0 -23
- package/examples/system-llm.di +0 -21
- package/examples/system-simple.di +0 -3
- package/examples/system-test.di +0 -8
- package/examples/tag-check-test.di +0 -139
- package/examples/task-assistant.di +0 -27
- package/examples/test-if-demo.di +0 -110
- package/examples/test-parameters.di +0 -50
- package/examples/try-catch-test.di +0 -118
- package/examples/two-styles.di +0 -28
- package/examples/var-debug.di +0 -6
- package/examples/var-inline.di +0 -4
- package/examples/var-test2.di +0 -6
- package/examples/variable-replace.di +0 -25
- package/examples/variable-simple.di +0 -16
- package/examples/variable-test.di +0 -22
- package/examples/whitespace-test.di +0 -24
- package/filePath +0 -1
- package/greeting.txt +0 -1
- package/src/cli.ts +0 -140
- package/src/index.ts +0 -33
- package/src/llm/ollama.ts +0 -58
- package/src/runtime/braket-parser.ts +0 -234
- package/src/runtime/interpreter.ts +0 -203
- package/src/runtime/parser.ts +0 -155
- package/src/runtime/session.ts +0 -325
- package/src/tags/assign.ts +0 -37
- package/src/tags/attr.ts +0 -64
- package/src/tags/available-subroutines.ts +0 -70
- package/src/tags/call.ts +0 -259
- package/src/tags/catch.ts +0 -24
- package/src/tags/defvar.ts +0 -115
- package/src/tags/environment.ts +0 -21
- package/src/tags/eval.ts +0 -71
- package/src/tags/exception.ts +0 -20
- package/src/tags/execute.ts +0 -52
- package/src/tags/expr.ts +0 -128
- package/src/tags/foreach.ts +0 -170
- package/src/tags/if.ts +0 -191
- package/src/tags/import.ts +0 -135
- package/src/tags/index.ts +0 -41
- package/src/tags/input.ts +0 -182
- package/src/tags/llm.ts +0 -415
- package/src/tags/loop.ts +0 -43
- package/src/tags/mongodb.ts +0 -70
- package/src/tags/output.ts +0 -53
- package/src/tags/parameters.ts +0 -81
- package/src/tags/require_module.ts +0 -19
- package/src/tags/subroutine.ts +0 -75
- package/src/tags/system.ts +0 -93
- package/src/tags/tag-check.ts +0 -176
- package/src/tags/test-if.ts +0 -112
- package/src/tags/throw.ts +0 -26
- package/src/tags/try.ts +0 -19
- package/src/tags/variable.ts +0 -25
- package/src/test-runner.ts +0 -300
- package/src/types/index.ts +0 -128
- package/src/utils/llm-adapter.ts +0 -113
- package/src/utils/tag-validator.ts +0 -231
- package/test-available-extends.di +0 -28
- package/test-available-simple.di +0 -12
- package/test-available-subroutines.di +0 -16
- package/test-call.di +0 -9
- package/test-extend-basic.di +0 -17
- package/test-extend-chain.di +0 -26
- package/test-extend-debug.di +0 -17
- package/test-extend-debug2.di +0 -15
- package/test-extend-person.di +0 -17
- package/test-extend-simple.di +0 -11
- package/test-extend-zhi.di +0 -23
- package/test-extend.di +0 -19
- package/test-extend2.di +0 -26
- package/test-extend3-fixed.di +0 -23
- package/test-extend3-trouble.di +0 -23
- package/test-extend3.di +0 -21
- package/test-factorial.di +0 -19
- package/test-input-debug.di +0 -19
- package/test-nested-debug.di +0 -7
- package/test-nested-debug2.di +0 -8
- package/test-no-extend.di +0 -16
- package/test-simple-call.di +0 -7
- package/test-simple.di +0 -6
- package/tests/README.md +0 -69
- package/tests/assign-basic.test.di +0 -7
- package/tests/assign-from-eval.test.di +0 -7
- package/tests/available-subroutines-foreach.test.di +0 -32
- package/tests/basic-output.test.di +0 -5
- package/tests/call-basic.test.di +0 -11
- package/tests/call-with-output.test.di +0 -10
- package/tests/comments-before-content.test.di +0 -6
- package/tests/defvar-multiple.test.di +0 -8
- package/tests/environment-basic.test.di +0 -22
- package/tests/environment-nonexistent.test.di +0 -5
- package/tests/environment-with-defvar.test.di +0 -15
- package/tests/eval-basic.test.di +0 -6
- package/tests/eval-with-variables.test.di +0 -8
- package/tests/exception-basic.test.di +0 -10
- package/tests/expr-basic.test.di +0 -11
- package/tests/extend-basic.test.di +0 -19
- package/tests/extend-inheritance-chain.test.di +0 -26
- package/tests/extend-multiple-nested.test.di +0 -24
- package/tests/extend-self.test.di +0 -19
- package/tests/extend-with-parameters.test.di +0 -14
- package/tests/generate-dirac.test.di +0 -22
- package/tests/if-conditional.test.di +0 -17
- package/tests/if-else.test.di +0 -11
- package/tests/if-with-variables.test.di +0 -8
- package/tests/import-basic.test.di +0 -6
- package/tests/input-file-all.test.di +0 -5
- package/tests/input-file-line.test.di +0 -15
- package/tests/input-file-loop.test.di +0 -12
- package/tests/input-stdin-all.test.di +0 -8
- package/tests/input-stdin-all.txt +0 -1
- package/tests/llm-validate.test.di +0 -17
- package/tests/loop-basic.test.di +0 -9
- package/tests/loop-nested.test.di +0 -10
- package/tests/loop-with-eval.test.di +0 -8
- package/tests/no-root-element.test.di +0 -6
- package/tests/output-file.test.di +0 -19
- package/tests/output-multiple.test.di +0 -9
- package/tests/parameters-basic.test.di +0 -6
- package/tests/require-module-basic.test.di +0 -7
- package/tests/subroutine-basic.test.di +0 -9
- package/tests/subroutine-multiple-params.test.di +0 -10
- package/tests/subroutine-nested-calls.test.di +0 -32
- package/tests/subroutine-sequential-calls.test.di +0 -36
- package/tests/system-background.test.di +0 -39
- package/tests/system-basic.test.di +0 -5
- package/tests/tag-check.test.di +0 -27
- package/tests/test-if-basic.test.di +0 -8
- package/tests/test-input.txt +0 -3
- package/tests/try-catch-basic.test.di +0 -10
- package/tests/try-catch-eval-error.test.di +0 -10
- package/tests/variable-basic.test.di +0 -6
- package/tests/variable-interpolation.test.di +0 -7
- package/tools/create-library.sh +0 -175
- package/tsconfig.json +0 -19
- /package/{examples/lib → lib}/advanced-math.di +0 -0
- /package/{examples/lib → lib}/fileops.di +0 -0
- /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>
|
package/test-available-simple.di
DELETED
|
@@ -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
package/test-extend-basic.di
DELETED
|
@@ -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>
|
package/test-extend-chain.di
DELETED
|
@@ -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>
|
package/test-extend-debug.di
DELETED
|
@@ -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>
|
package/test-extend-debug2.di
DELETED
|
@@ -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>
|
package/test-extend-person.di
DELETED
|
@@ -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>
|
package/test-extend-simple.di
DELETED
package/test-extend-zhi.di
DELETED
|
@@ -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> </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>
|
package/test-extend3-fixed.di
DELETED
|
@@ -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-trouble.di
DELETED
|
@@ -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>
|
package/test-input-debug.di
DELETED
|
@@ -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>
|
package/test-nested-debug.di
DELETED
package/test-nested-debug2.di
DELETED
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>
|
package/test-simple-call.di
DELETED