dirac-lang 0.1.23 → 0.1.25

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 (226) hide show
  1. package/dist/{chunk-APWJJXNI.js → chunk-7OUYWIZV.js} +55 -14
  2. package/dist/{chunk-RGS2XK6T.js → chunk-OUMUIBK3.js} +1 -1
  3. package/dist/cli.js +15 -3
  4. package/dist/index.js +2 -2
  5. package/dist/{interpreter-UZDVASAW.js → interpreter-MTIIHIIQ.js} +1 -1
  6. package/dist/test-runner.js +1 -1
  7. package/lib/index.di +9 -0
  8. package/package.json +13 -1
  9. package/.env.example +0 -8
  10. package/COMMUNITY.md +0 -465
  11. package/CONDITIONAL-TAGS.md +0 -172
  12. package/EXCEPTION-HANDLING.md +0 -156
  13. package/LIBRARIES.md +0 -172
  14. package/LLM-VALIDATION.md +0 -128
  15. package/NAMESPACES.md +0 -366
  16. package/PROMOTION.md +0 -257
  17. package/QUICKSTART-LIBRARY.md +0 -93
  18. package/TEST-COVERAGE.md +0 -113
  19. package/TESTING.md +0 -162
  20. package/config.test.yml +0 -5
  21. package/dirac-http/examples/demo.di +0 -9
  22. package/dirac-http/lib/index.di +0 -12
  23. package/examples/add-demo.di +0 -74
  24. package/examples/add.bk +0 -11
  25. package/examples/advanced-math-demo.di +0 -53
  26. package/examples/calculator.di +0 -32
  27. package/examples/compact-test.di +0 -6
  28. package/examples/comprehensive.bk +0 -29
  29. package/examples/defvar-variable-demo.di +0 -18
  30. package/examples/direct-call.di +0 -17
  31. package/examples/disk-analysis.di +0 -16
  32. package/examples/exception-demo.di +0 -82
  33. package/examples/executable-hello.di +0 -7
  34. package/examples/execute-demo.di +0 -38
  35. package/examples/file-manager.di +0 -77
  36. package/examples/file-stats.di +0 -18
  37. package/examples/hello.bk +0 -1
  38. package/examples/hello.di +0 -5
  39. package/examples/if-comparison.di +0 -91
  40. package/examples/if-cstyle-test.di +0 -149
  41. package/examples/if-vs-testif.di +0 -56
  42. package/examples/import-demo.di +0 -31
  43. package/examples/inline-test.bk +0 -7
  44. package/examples/llm-agent.di +0 -32
  45. package/examples/llm-basic.di +0 -12
  46. package/examples/llm-command-more.di +0 -6
  47. package/examples/llm-command-no-exec.di +0 -13
  48. package/examples/llm-command.di +0 -6
  49. package/examples/llm-complex.di +0 -141
  50. package/examples/llm-feedback-debug.di +0 -30
  51. package/examples/llm-feedback-demo.di +0 -19
  52. package/examples/llm-feedback-math.di +0 -22
  53. package/examples/llm-feedback-simple.di +0 -16
  54. package/examples/llm-feedback-sub.di +0 -22
  55. package/examples/llm-no-feedback.di +0 -10
  56. package/examples/llm-recursive.di +0 -31
  57. package/examples/llm-reflection-test.di +0 -19
  58. package/examples/llm-simple-test.di +0 -12
  59. package/examples/llm-subs.di +0 -132
  60. package/examples/llm-use-subs.di +0 -6
  61. package/examples/llm-validate-test.di +0 -18
  62. package/examples/loop.di +0 -12
  63. package/examples/math-test.di +0 -22
  64. package/examples/minimal-test.di +0 -13
  65. package/examples/mongodb-context-test.di +0 -27
  66. package/examples/mongodb-count-events.di +0 -8
  67. package/examples/mongodb-import-demo.di +0 -25
  68. package/examples/mongodb-simple-test.di +0 -18
  69. package/examples/nl-agent.di +0 -47
  70. package/examples/parameters-demo.di +0 -68
  71. package/examples/params-meta-test.di +0 -17
  72. package/examples/params-test.di +0 -10
  73. package/examples/recipe-chain.di +0 -38
  74. package/examples/recursive-llm.di +0 -44
  75. package/examples/sample-library/README.md +0 -152
  76. package/examples/sample-library/examples/demo.di +0 -34
  77. package/examples/sample-library/lib/index.di +0 -65
  78. package/examples/sample-library/package.json +0 -31
  79. package/examples/scope-test-nested.di +0 -60
  80. package/examples/scope-test.di +0 -55
  81. package/examples/seamless.di +0 -45
  82. package/examples/shell-test.bk +0 -10
  83. package/examples/simple-import.di +0 -13
  84. package/examples/simple-recursive.di +0 -26
  85. package/examples/story-builder.di +0 -45
  86. package/examples/subroutine.di +0 -23
  87. package/examples/system-llm.di +0 -21
  88. package/examples/system-simple.di +0 -3
  89. package/examples/system-test.di +0 -8
  90. package/examples/tag-check-test.di +0 -139
  91. package/examples/task-assistant.di +0 -27
  92. package/examples/test-if-demo.di +0 -110
  93. package/examples/test-parameters.di +0 -50
  94. package/examples/try-catch-test.di +0 -118
  95. package/examples/two-styles.di +0 -28
  96. package/examples/var-debug.di +0 -6
  97. package/examples/var-inline.di +0 -4
  98. package/examples/var-test2.di +0 -6
  99. package/examples/variable-replace.di +0 -25
  100. package/examples/variable-simple.di +0 -16
  101. package/examples/variable-test.di +0 -22
  102. package/examples/whitespace-test.di +0 -24
  103. package/filePath +0 -1
  104. package/greeting.txt +0 -1
  105. package/src/cli.ts +0 -140
  106. package/src/index.ts +0 -33
  107. package/src/llm/ollama.ts +0 -58
  108. package/src/runtime/braket-parser.ts +0 -234
  109. package/src/runtime/interpreter.ts +0 -203
  110. package/src/runtime/parser.ts +0 -155
  111. package/src/runtime/session.ts +0 -325
  112. package/src/tags/assign.ts +0 -37
  113. package/src/tags/attr.ts +0 -64
  114. package/src/tags/available-subroutines.ts +0 -70
  115. package/src/tags/call.ts +0 -259
  116. package/src/tags/catch.ts +0 -24
  117. package/src/tags/defvar.ts +0 -115
  118. package/src/tags/environment.ts +0 -21
  119. package/src/tags/eval.ts +0 -71
  120. package/src/tags/exception.ts +0 -20
  121. package/src/tags/execute.ts +0 -52
  122. package/src/tags/expr.ts +0 -128
  123. package/src/tags/foreach.ts +0 -170
  124. package/src/tags/if.ts +0 -191
  125. package/src/tags/import.ts +0 -66
  126. package/src/tags/index.ts +0 -41
  127. package/src/tags/input.ts +0 -182
  128. package/src/tags/llm.ts +0 -415
  129. package/src/tags/loop.ts +0 -43
  130. package/src/tags/mongodb.ts +0 -70
  131. package/src/tags/output.ts +0 -53
  132. package/src/tags/parameters.ts +0 -81
  133. package/src/tags/require_module.ts +0 -19
  134. package/src/tags/subroutine.ts +0 -75
  135. package/src/tags/system.ts +0 -93
  136. package/src/tags/tag-check.ts +0 -176
  137. package/src/tags/test-if.ts +0 -112
  138. package/src/tags/throw.ts +0 -26
  139. package/src/tags/try.ts +0 -19
  140. package/src/tags/variable.ts +0 -25
  141. package/src/test-runner.ts +0 -300
  142. package/src/types/index.ts +0 -128
  143. package/src/utils/llm-adapter.ts +0 -113
  144. package/src/utils/tag-validator.ts +0 -231
  145. package/test-available-extends.di +0 -28
  146. package/test-available-simple.di +0 -12
  147. package/test-available-subroutines.di +0 -16
  148. package/test-call.di +0 -9
  149. package/test-extend-basic.di +0 -17
  150. package/test-extend-chain.di +0 -26
  151. package/test-extend-debug.di +0 -17
  152. package/test-extend-debug2.di +0 -15
  153. package/test-extend-person.di +0 -17
  154. package/test-extend-simple.di +0 -11
  155. package/test-extend-zhi.di +0 -23
  156. package/test-extend.di +0 -19
  157. package/test-extend2.di +0 -26
  158. package/test-extend3-fixed.di +0 -23
  159. package/test-extend3-trouble.di +0 -23
  160. package/test-extend3.di +0 -21
  161. package/test-factorial.di +0 -19
  162. package/test-input-debug.di +0 -19
  163. package/test-nested-debug.di +0 -7
  164. package/test-nested-debug2.di +0 -8
  165. package/test-no-extend.di +0 -16
  166. package/test-simple-call.di +0 -7
  167. package/test-simple.di +0 -6
  168. package/tests/README.md +0 -69
  169. package/tests/assign-basic.test.di +0 -7
  170. package/tests/assign-from-eval.test.di +0 -7
  171. package/tests/available-subroutines-foreach.test.di +0 -32
  172. package/tests/basic-output.test.di +0 -5
  173. package/tests/call-basic.test.di +0 -11
  174. package/tests/call-with-output.test.di +0 -10
  175. package/tests/comments-before-content.test.di +0 -6
  176. package/tests/defvar-multiple.test.di +0 -8
  177. package/tests/environment-basic.test.di +0 -22
  178. package/tests/environment-nonexistent.test.di +0 -5
  179. package/tests/environment-with-defvar.test.di +0 -15
  180. package/tests/eval-basic.test.di +0 -6
  181. package/tests/eval-with-variables.test.di +0 -8
  182. package/tests/exception-basic.test.di +0 -10
  183. package/tests/expr-basic.test.di +0 -11
  184. package/tests/extend-basic.test.di +0 -19
  185. package/tests/extend-inheritance-chain.test.di +0 -26
  186. package/tests/extend-multiple-nested.test.di +0 -24
  187. package/tests/extend-self.test.di +0 -19
  188. package/tests/extend-with-parameters.test.di +0 -14
  189. package/tests/generate-dirac.test.di +0 -22
  190. package/tests/if-conditional.test.di +0 -17
  191. package/tests/if-else.test.di +0 -11
  192. package/tests/if-with-variables.test.di +0 -8
  193. package/tests/import-basic.test.di +0 -6
  194. package/tests/input-file-all.test.di +0 -5
  195. package/tests/input-file-line.test.di +0 -15
  196. package/tests/input-file-loop.test.di +0 -12
  197. package/tests/input-stdin-all.test.di +0 -8
  198. package/tests/input-stdin-all.txt +0 -1
  199. package/tests/llm-validate.test.di +0 -17
  200. package/tests/loop-basic.test.di +0 -9
  201. package/tests/loop-nested.test.di +0 -10
  202. package/tests/loop-with-eval.test.di +0 -8
  203. package/tests/no-root-element.test.di +0 -6
  204. package/tests/output-file.test.di +0 -19
  205. package/tests/output-multiple.test.di +0 -9
  206. package/tests/parameters-basic.test.di +0 -6
  207. package/tests/require-module-basic.test.di +0 -7
  208. package/tests/subroutine-basic.test.di +0 -9
  209. package/tests/subroutine-multiple-params.test.di +0 -10
  210. package/tests/subroutine-nested-calls.test.di +0 -32
  211. package/tests/subroutine-sequential-calls.test.di +0 -36
  212. package/tests/system-background.test.di +0 -39
  213. package/tests/system-basic.test.di +0 -5
  214. package/tests/tag-check.test.di +0 -27
  215. package/tests/test-if-basic.test.di +0 -8
  216. package/tests/test-input.txt +0 -3
  217. package/tests/try-catch-basic.test.di +0 -10
  218. package/tests/try-catch-eval-error.test.di +0 -10
  219. package/tests/variable-basic.test.di +0 -6
  220. package/tests/variable-interpolation.test.di +0 -7
  221. package/tools/create-library.sh +0 -175
  222. package/tsconfig.json +0 -19
  223. /package/{examples/lib → lib}/advanced-math.di +0 -0
  224. /package/{examples/lib → lib}/fileops.di +0 -0
  225. /package/{examples/lib → lib}/math.di +0 -0
  226. /package/{examples/lib → lib}/mongodb.di +0 -0
package/TEST-COVERAGE.md DELETED
@@ -1,113 +0,0 @@
1
- # Dirac Unit Test Coverage Report
2
-
3
- ## Summary
4
- - **Total Tests**: 32
5
- - **Passing**: 20 (62.5%)
6
- - **Failing**: 12 (37.5%)
7
-
8
- ## Test Status by Tag
9
-
10
- ### ✅ Fully Covered (Passing)
11
- - `<output>` - Basic output, multiple outputs
12
- - `<defvar>` - Variable definition, multiple variables
13
- - `<variable>` - Variable interpolation
14
- - `<assign>` - Basic assignment
15
- - `<eval>` - Basic eval, eval with variables, eval naming
16
- - `<loop>` - Basic loops
17
- - `<test-if>` - Attribute-based conditional testing
18
- - `<system>` - Basic system commands
19
- - `<require_module>` - Node.js module imports
20
- - `<subroutine>` - Basic subroutine calls
21
- - `<try>/<catch>` - Error handling, error expectations
22
- - `<exception>` - Exception handling
23
-
24
- ### ⚠️ Partially Covered (Has Issues)
25
- - `<expr>` - Syntax needs fixing (requires `eval` attribute)
26
- - `<call>` - Subroutine calls (parameter definition issues)
27
- - `<loop>` - Nested loops (logic issues)
28
- - `<import>` - Import functionality (needs investigation)
29
- - `<system>` - Output capture order
30
-
31
- ### ❌ Not Tested
32
- - `<llm>` - Requires LLM provider configuration
33
- - `<execute>` - Requires LLM provider configuration
34
- - `<mongodb>` - Requires MongoDB connection
35
- - `<if>` - Conditional expression evaluation (different from test-if)
36
- - `<parameters>` - HTTP parameter extraction
37
-
38
- ## Failing Tests Details
39
-
40
- ### 1. call_basic & call_with_output
41
- **Issue**: Subroutine parameter binding
42
- ```
43
- Error: Eval error: x is not defined
44
- ```
45
- **Fix Needed**: Verify param-* attribute syntax
46
-
47
- ### 2. expr_basic & expr_string_concat
48
- **Issue**: Missing `eval` attribute
49
- ```
50
- Error: <expr> requires eval or op attribute
51
- ```
52
- **Already Fixed**: Changed to `<expr eval="..." />`
53
-
54
- ### 3. if_else & if_with_variables
55
- **Issue**: test-if syntax
56
- ```
57
- Error: <test-if> requires test attribute
58
- ```
59
- **Fix Needed**: Use proper test-if syntax with `test="$var"` and comparison operators
60
-
61
- ### 4. import_basic
62
- **Issue**: Import not finding parameter
63
- ```
64
- Error: Eval error: x is not defined
65
- ```
66
- **Fix Needed**: Check import mechanism and subroutine parameter passing
67
-
68
- ### 5. loop_nested
69
- **Issue**: Logic error in nested loop test
70
- ```
71
- Expected: "0-A 0-B 1-A 1-B"
72
- Actual: "0-B 0-B 1-B 1-B"
73
- ```
74
- **Fix Needed**: Fix letter calculation logic
75
-
76
- ### 6. subroutine_multiple_params & subroutine_recursive
77
- **Issue**: Output variable not captured
78
- ```
79
- Expected: "Full name: John Doe"
80
- Actual: "Full name:"
81
- ```
82
- **Fix Needed**: Check param-output and eval output assignment
83
-
84
- ### 7. system_capture & system_with_trim
85
- **Issue**: Output order
86
- ```
87
- Expected: "hello Result: hello"
88
- Actual: "hello Result:"
89
- ```
90
- **Fix Needed**: System command output comes first, variable not captured
91
-
92
- ## Next Steps
93
-
94
- 1. **High Priority** - Fix subroutine parameter passing (4 tests)
95
- 2. **Medium Priority** - Fix expr and test-if syntax (4 tests)
96
- 3. **Low Priority** - Fix system output capture (2 tests), loop logic (1 test), import (1 test)
97
- 4. **Future** - Add LLM/MongoDB integration tests when services available
98
-
99
- ## Test Execution
100
-
101
- ```bash
102
- npm test
103
- ```
104
-
105
- All tests run automatically on build. Test files are in `/tests` directory with format:
106
- ```xml
107
- <!-- TEST: test_name -->
108
- <!-- EXPECT: expected output -->
109
- <!-- EXPECT_ERROR: expected error message -->
110
- <dirac>
111
- <!-- test code -->
112
- </dirac>
113
- ```
package/TESTING.md DELETED
@@ -1,162 +0,0 @@
1
- # Dirac Testing System
2
-
3
- A simple, lightweight testing framework for Dirac language files.
4
-
5
- ## Running Tests
6
-
7
- ```bash
8
- npm test
9
- ```
10
-
11
- This will:
12
- 1. Build the project
13
- 2. Run all `*.test.di` files in the `tests/` directory
14
- 3. Report results
15
-
16
- ## Writing Tests
17
-
18
- Tests are standard Dirac `.di` files with special comments that define expectations.
19
-
20
- ### Test File Format
21
-
22
- ```xml
23
- <!-- TEST: test_name -->
24
- <!-- EXPECT: expected output -->
25
- <dirac>
26
- <!-- your test code here -->
27
- </dirac>
28
- ```
29
-
30
- ### Test Metadata Comments
31
-
32
- - `<!-- TEST: name -->` - Name of the test (optional, defaults to filename)
33
- - `<!-- EXPECT: output -->` - Expected output (optional)
34
- - `<!-- EXPECT_ERROR: error message -->` - Expected error message (optional)
35
-
36
- ### Example Tests
37
-
38
- #### Basic Output Test
39
-
40
- ```xml
41
- <!-- TEST: hello_world -->
42
- <!-- EXPECT: Hello, World! -->
43
- <dirac>
44
- <output>Hello, World!</output>
45
- </dirac>
46
- ```
47
-
48
- #### Variable Test
49
-
50
- ```xml
51
- <!-- TEST: variables -->
52
- <!-- EXPECT: Value is: test123 -->
53
- <dirac>
54
- <defvar name="myvar" value="test123" />
55
- <output>Value is: <variable name="myvar" /></output>
56
- </dirac>
57
- ```
58
-
59
- #### Error Test
60
-
61
- ```xml
62
- <!-- TEST: missing_variable -->
63
- <!-- EXPECT_ERROR: Variable 'missing' not found -->
64
- <dirac>
65
- <variable name="missing" />
66
- </dirac>
67
- ```
68
-
69
- #### No Expectation (Just Run)
70
-
71
- ```xml
72
- <!-- TEST: runs_without_error -->
73
- <dirac>
74
- <defvar name="x" value="10" />
75
- <!-- Test passes if it runs without throwing an error -->
76
- </dirac>
77
- ```
78
-
79
- ## Test Organization
80
-
81
- Tests should be placed in the `tests/` directory with the `.test.di` extension:
82
-
83
- ```
84
- tests/
85
- ├── basic-output.test.di
86
- ├── variable-basic.test.di
87
- ├── subroutine-basic.test.di
88
- ├── if-conditional.test.di
89
- └── ...
90
- ```
91
-
92
- You can organize tests into subdirectories:
93
-
94
- ```
95
- tests/
96
- ├── core/
97
- │ ├── output.test.di
98
- │ └── variables.test.di
99
- ├── control-flow/
100
- │ ├── if.test.di
101
- │ └── loop.test.di
102
- └── llm/
103
- └── basic.test.di
104
- ```
105
-
106
- ## Output Matching
107
-
108
- The test runner normalizes whitespace when comparing output:
109
- - Multiple spaces/newlines are collapsed to single spaces
110
- - Leading/trailing whitespace is trimmed
111
- - This allows tests to ignore XML formatting whitespace
112
-
113
- For example, these are equivalent:
114
- - Expected: `Hello World`
115
- - Actual: ` Hello World ` → matches ✓
116
- - Actual: `Hello\n World` → matches ✓
117
-
118
- ## Exit Codes
119
-
120
- - `0` - All tests passed
121
- - `1` - One or more tests failed
122
-
123
- ## Continuous Integration
124
-
125
- Add to your CI pipeline:
126
-
127
- ```yaml
128
- # .github/workflows/test.yml
129
- - name: Run tests
130
- run: npm test
131
- ```
132
-
133
- ## Best Practices
134
-
135
- 1. **One concept per test** - Each test should verify one specific behavior
136
- 2. **Descriptive names** - Use clear test names that describe what's being tested
137
- 3. **Test edge cases** - Include tests for error conditions and boundary cases
138
- 4. **Keep tests fast** - Avoid LLM calls in unit tests (use mocks or separate integration tests)
139
- 5. **Test regressions** - When fixing bugs, add a test to prevent regression
140
-
141
- ## Example Test Suite
142
-
143
- ```
144
- tests/
145
- ├── basic-output.test.di # Basic output functionality
146
- ├── variable-basic.test.di # Variable definition and output
147
- ├── subroutine-basic.test.di # Subroutine calls
148
- ├── if-conditional.test.di # Conditional execution
149
- ├── loop-basic.test.di # Loop functionality
150
- ├── exception-basic.test.di # Exception handling
151
- └── test-if-basic.test.di # test-if conditional
152
- ```
153
-
154
- ## Future Enhancements
155
-
156
- Potential improvements:
157
- - Watch mode for TDD workflow
158
- - Code coverage reporting
159
- - Performance benchmarks
160
- - Parallel test execution
161
- - Test fixtures/setup/teardown
162
- - Snapshot testing for complex outputs
package/config.test.yml DELETED
@@ -1,5 +0,0 @@
1
- # Test configuration for verifying embedding config works
2
- embeddingServer:
3
- host: localhost
4
- port: 11434
5
- model: nomic-embed-text # Different model to test config loading
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <dirac>
3
- <import src="../lib/index.di"/>
4
-
5
- <output>Demo:</output>
6
- <output>&#10;</output>
7
- <HTTP_EXAMPLE input="test"/>
8
- <output>&#10;</output>
9
- </dirac>
@@ -1,12 +0,0 @@
1
- <dirac>
2
-
3
- <!-- All tags use the library prefix to avoid naming conflicts -->
4
- <subroutine name="HTTP_EXAMPLE">
5
- <eval>
6
- const caller = getParams();
7
- const input = caller.attributes.input || 'no input';
8
- console.log('Processed: ' + input);
9
- </eval>
10
- </subroutine>
11
-
12
- </dirac>
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <dirac>
3
- <!--
4
- Method 1: Using <expr> tag (clean, declarative)
5
- -->
6
- <subroutine name="ADD">
7
- <expr eval="plus">
8
- <arg><parameters select="@x"/></arg>
9
- <arg><parameters select="@y"/></arg>
10
- </expr>
11
- </subroutine>
12
-
13
- <output>Method 1 (expr tag):&#10;</output>
14
- <output> 1 + 2 = </output>
15
- <ADD x="1" y="2"/>
16
- <output>&#10;</output>
17
-
18
- <output> 5 + 7 = </output>
19
- <ADD x="5" y="7"/>
20
- <output>&#10;</output>
21
-
22
- <output> 100 + 200 = </output>
23
- <ADD x="100" y="200"/>
24
- <output>&#10;</output>
25
-
26
- <!--
27
- Method 2: Using getParams() in eval (programmatic)
28
- -->
29
- <subroutine name="MULTIPLY">
30
- <eval>
31
- const caller = getParams();
32
- if (caller && caller.attributes) {
33
- const x = parseInt(caller.attributes.x || 0);
34
- const y = parseInt(caller.attributes.y || 0);
35
- console.log(x * y);
36
- }
37
- </eval>
38
- </subroutine>
39
-
40
- <output>&#10;Method 2 (eval with getParams):&#10;</output>
41
- <output>3 * 4 = </output>
42
- <MULTIPLY x="3" y="4"/>
43
- <output>&#10;</output>
44
-
45
- <output>5 * 6 = </output>
46
- <MULTIPLY x="5" y="6"/>
47
- <output>&#10;</output>
48
-
49
- <!-- More expr examples -->
50
- <output>&#10;More operations:&#10;</output>
51
- <output>10 - 3 = </output>
52
- <expr eval="minus"><arg>10</arg><arg>3</arg></expr>
53
- <output>&#10;</output>
54
-
55
- <output>7 * 8 = </output>
56
- <expr eval="times"><arg>7</arg><arg>8</arg></expr>
57
- <output>&#10;</output>
58
-
59
- <output>20 / 4 = </output>
60
- <expr eval="divide"><arg>20</arg><arg>4</arg></expr>
61
- <output>&#10;</output>
62
-
63
- <output>17 mod 5 = </output>
64
- <expr eval="mod"><arg>17</arg><arg>5</arg></expr>
65
- <output>&#10;</output>
66
-
67
- <output>5 &lt; 10 = </output>
68
- <expr eval="lt"><arg>5</arg><arg>10</arg></expr>
69
- <output>&#10;</output>
70
-
71
- <output>5 &gt; 10 = </output>
72
- <expr eval="gt"><arg>5</arg><arg>10</arg></expr>
73
- <output>&#10;</output>
74
- </dirac>
package/examples/add.bk DELETED
@@ -1,11 +0,0 @@
1
- <add|
2
- |parameters select=@x>
3
- |parameters select=@y>
4
- |expr op=plus>
5
- |arg>
6
- |variable name=x>
7
- |arg>
8
- |variable name=y>
9
-
10
- |output>5 + 3 =
11
- |add x=5 y=3>
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <dirac>
3
- <!-- Import advanced math library -->
4
- <import src="./lib/advanced-math.di"/>
5
-
6
- <output>Advanced Math Library Demo&#10;&#10;</output>
7
-
8
- <!-- Square root -->
9
- <output>Square root of 16: </output>
10
- <MATH_SQRT n="16"/>
11
- <output>&#10;</output>
12
-
13
- <output>Square root of 2: </output>
14
- <MATH_SQRT n="2"/>
15
- <output>&#10;</output>
16
-
17
- <!-- Factorial -->
18
- <output>Factorial of 5: </output>
19
- <MATH_FACTORIAL n="5"/>
20
- <output>&#10;</output>
21
-
22
- <output>Factorial of 10: </output>
23
- <MATH_FACTORIAL n="10"/>
24
- <output>&#10;</output>
25
-
26
- <!-- GCD -->
27
- <output>GCD(48, 18): </output>
28
- <MATH_GCD a="48" b="18"/>
29
- <output>&#10;</output>
30
-
31
- <output>GCD(100, 35): </output>
32
- <MATH_GCD a="100" b="35"/>
33
- <output>&#10;</output>
34
-
35
- <!-- Prime check -->
36
- <output>Is 17 prime? </output>
37
- <MATH_PRIME n="17"/>
38
- <output>&#10;</output>
39
-
40
- <output>Is 20 prime? </output>
41
- <MATH_PRIME n="20"/>
42
- <output>&#10;</output>
43
-
44
- <!-- Random number -->
45
- <output>Random number [0-100]: </output>
46
- <MATH_RANDOM min="0" max="100"/>
47
- <output>&#10;</output>
48
-
49
- <!-- Statistics -->
50
- <output>&#10;Statistics for [1,2,3,4,5,10,100]:&#10;</output>
51
- <MATH_STATS data="[1,2,3,4,5,10,100]"/>
52
- <output>&#10;</output>
53
- </dirac>
@@ -1,32 +0,0 @@
1
- ```xml
2
- <?xml version="1.0"?>
3
- <!-- Basic Arithmetic Calculator -->
4
- <dirac>
5
- <!-- Declaration of variables -->
6
- <defvar name="num1" value="0" />
7
- <defvar name="num2" value="0" />
8
- <defvar name="result" value="0" />
9
- <defvar name="operation" value="" />
10
-
11
- <!-- User input for first number -->
12
- <LLM output="num1">Please enter the first number:</LLM>
13
-
14
- <!-- User input for second number -->
15
- <LLM output="num2">Please enter the second number:</LLM>
16
-
17
- <!-- User input for the operation -->
18
- <LLM output="operation">Please choose the operation (+, -, *, /):</LLM>
19
-
20
- <!-- Perform selected operation -->
21
- <if test="${operation} == '+'">
22
- <set var="result" value="${num1} + ${num2}" />
23
- </if>
24
- <if test="${operation} == '-'">
25
- <set var="result" value="${num1} - ${num2}" />
26
- </if>
27
- <if test="${operation} == '*'">
28
- <set var="result" value="${num1} * ${num2}" />
29
- </if>
30
- <if test="${operation} == '/'">
31
- <if test="${num2} == 0">
32
- <output>Division by zero is not allowed.</output>
@@ -1,6 +0,0 @@
1
- <dirac>
2
- <defvar name="dir">examples</defvar>
3
- <output>Files in <variable name="dir" />:</output>
4
- <output>&#10;</output>
5
- <system>ls -la <variable name="dir" /> | head -10</system>
6
- </dirac>
@@ -1,29 +0,0 @@
1
- |output>Bra-Ket Notation Demo
2
-
3
- <factorial|
4
- |parameters select=@n>
5
- |variable name=n>
6
- |if>
7
- |expr op=eq>
8
- |arg>
9
- |variable name=n>
10
- |arg>1
11
- |output>1
12
- |expr op=times>
13
- |arg>
14
- |variable name=n>
15
- |arg>
16
- |factorial>
17
- |expr op=minus>
18
- |arg>
19
- |variable name=n>
20
- |arg>1
21
-
22
- |output>Factorial of 5 =
23
- |factorial n=5>
24
- |output>
25
-
26
- <format|
27
- |output>Name: |variable name=name>, Age: |variable name=age>
28
-
29
- |format name=Alice age=30>
@@ -1,18 +0,0 @@
1
- <dirac>
2
- <!-- Simple example: defvar sets, variable gets -->
3
- <defvar name="greeting">Hello, World!</defvar>
4
- <output><variable name="greeting"/></output>
5
- <output>&#10;</output>
6
-
7
- <!-- Subroutine with parameter -->
8
- <subroutine name="greet">
9
- <parameters select="@name">
10
- <defvar name="localname"/>
11
- </parameters>
12
- <output>Greetings, <variable name="localname"/>!</output>
13
- </subroutine>
14
-
15
- <greet name="Alice"/>
16
- <output>&#10;</output>
17
- <greet name="Bob"/>
18
- </dirac>
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <dirac>
3
- <import src="./lib/math.di" />
4
-
5
- <output>Direct Tag Call Test&#10;&#10;</output>
6
-
7
- <defvar name="x" value="9" />
8
- <output>Using &lt;SQUARE /&gt;: </output>
9
- <SQUARE />
10
- <output>&#10;</output>
11
-
12
- <defvar name="a" value="100" />
13
- <defvar name="b" value="200" />
14
- <output>Using &lt;ADD /&gt;: </output>
15
- <ADD />
16
- <output>&#10;</output>
17
- </dirac>
@@ -1,16 +0,0 @@
1
- <dirac>
2
- <!-- Get disk usage and ask LLM to summarize -->
3
- <output>Analyzing disk usage...</output>
4
- <output>&#10;</output>
5
-
6
- <llm>
7
- <system>du -sh . 2>/dev/null</system>
8
- <system>df -h . | tail -1</system>
9
-
10
- Above are two commands:
11
- 1. Total size of current directory
12
- 2. Disk space information for the filesystem
13
-
14
- Please tell me in one sentence: How much space is this directory using and what percentage of the disk is free?
15
- </llm>
16
- </dirac>
@@ -1,82 +0,0 @@
1
- <dirac>
2
- <output>===== Try/Catch/Throw Exception Handling Tests =====</output>
3
- <output>
4
- </output>
5
-
6
- <!-- Test 1: Simple exception -->
7
- <output>Test 1: Simple exception throw and catch</output>
8
- <try>
9
- <throw name="error1">
10
- <output>Error message from throw</output>
11
- </throw>
12
- </try>
13
-
14
- <catch name="error1">
15
- <output>Caught: </output>
16
- <exception/>
17
- </catch>
18
- <output>
19
- </output>
20
-
21
- <!-- Test 2: Named exceptions -->
22
- <output>Test 2: Multiple named exceptions</output>
23
- <try>
24
- <throw name="warning">
25
- <output>This is a warning</output>
26
- </throw>
27
- <throw name="error">
28
- <output>This is an error</output>
29
- </throw>
30
- </try>
31
-
32
- <catch name="warning">
33
- <output>Warnings: </output>
34
- <exception/>
35
- </catch>
36
-
37
- <catch name="error">
38
- <output>Errors: </output>
39
- <exception/>
40
- </catch>
41
- <output>
42
- </output>
43
-
44
- <!-- Test 3: Exception with variable data -->
45
- <output>Test 3: Exception with variable data</output>
46
- <defvar name="errorCode" value="404"/>
47
- <defvar name="errorMsg" value="Not Found"/>
48
-
49
- <try>
50
- <throw name="httperror">
51
- <output>HTTP Error </output>
52
- <variable name="errorCode"/>
53
- <output>: </output>
54
- <variable name="errorMsg"/>
55
- </throw>
56
- </try>
57
-
58
- <catch name="httperror">
59
- <output>Caught HTTP error: </output>
60
- <exception/>
61
- </catch>
62
- <output>
63
- </output>
64
-
65
- <!-- Test 4: No matching catch -->
66
- <output>Test 4: Exception with no matching catch (should not output)</output>
67
- <try>
68
- <throw name="uncaught">
69
- <output>This won't be caught</output>
70
- </throw>
71
- </try>
72
-
73
- <catch name="different">
74
- <output>This should NOT appear</output>
75
- <exception/>
76
- </catch>
77
- <output>Done with test 4</output>
78
- <output>
79
- </output>
80
-
81
- <output>===== All tests complete =====</output>
82
- </dirac>
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env dirac
2
- <!-- Executable Dirac Script -->
3
- <dirac>
4
- <defvar name="name" value="World" />
5
- <output>Hello, ${name}!&#10;</output>
6
- <output>This script runs directly!&#10;</output>
7
- </dirac>