@lewin671/python-vm 0.1.0 → 0.1.1

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 (142) hide show
  1. package/dist/compiler.d.ts.map +1 -0
  2. package/dist/compiler.js.map +1 -0
  3. package/dist/compiler_module/compiler.d.ts.map +1 -0
  4. package/dist/compiler_module/compiler.js.map +1 -0
  5. package/dist/compiler_module/index.d.ts.map +1 -0
  6. package/dist/compiler_module/index.js.map +1 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/lexer/index.d.ts.map +1 -0
  10. package/dist/lexer/index.js.map +1 -0
  11. package/dist/lexer/lexer.d.ts.map +1 -0
  12. package/dist/lexer/lexer.js.map +1 -0
  13. package/dist/parser/expressions.d.ts.map +1 -0
  14. package/dist/parser/expressions.js.map +1 -0
  15. package/dist/parser/index.d.ts.map +1 -0
  16. package/dist/parser/index.js.map +1 -0
  17. package/dist/parser/parser.d.ts.map +1 -0
  18. package/dist/parser/parser.js.map +1 -0
  19. package/dist/parser/statements.d.ts.map +1 -0
  20. package/dist/parser/statements.js.map +1 -0
  21. package/dist/parser/targets.d.ts.map +1 -0
  22. package/dist/parser/targets.js.map +1 -0
  23. package/dist/types/ast.d.ts.map +1 -0
  24. package/dist/types/ast.js.map +1 -0
  25. package/dist/types/bytecode.d.ts.map +1 -0
  26. package/dist/types/bytecode.js.map +1 -0
  27. package/dist/types/index.d.ts.map +1 -0
  28. package/dist/types/index.js.map +1 -0
  29. package/dist/types/token.d.ts.map +1 -0
  30. package/dist/types/token.js.map +1 -0
  31. package/dist/vm/builtins.d.ts.map +1 -0
  32. package/dist/vm/builtins.js.map +1 -0
  33. package/dist/vm/callable.d.ts.map +1 -0
  34. package/dist/vm/callable.js.map +1 -0
  35. package/dist/vm/execution.d.ts.map +1 -0
  36. package/dist/vm/execution.js.map +1 -0
  37. package/dist/vm/expression-generator.d.ts.map +1 -0
  38. package/dist/vm/expression-generator.js.map +1 -0
  39. package/dist/vm/expressions.d.ts.map +1 -0
  40. package/dist/vm/expressions.js.map +1 -0
  41. package/dist/vm/imports.d.ts.map +1 -0
  42. package/dist/vm/imports.js.map +1 -0
  43. package/dist/vm/index.d.ts.map +1 -0
  44. package/dist/vm/index.js.map +1 -0
  45. package/dist/vm/operations.d.ts.map +1 -0
  46. package/dist/vm/operations.js.map +1 -0
  47. package/dist/vm/runtime-types.d.ts.map +1 -0
  48. package/dist/vm/runtime-types.js.map +1 -0
  49. package/dist/vm/statements.d.ts.map +1 -0
  50. package/dist/vm/statements.js.map +1 -0
  51. package/dist/vm/truthy.d.ts.map +1 -0
  52. package/dist/vm/truthy.js.map +1 -0
  53. package/dist/vm/value-utils.d.ts.map +1 -0
  54. package/dist/vm/value-utils.js.map +1 -0
  55. package/dist/vm/vm.d.ts.map +1 -0
  56. package/dist/vm/vm.js.map +1 -0
  57. package/package.json +7 -1
  58. package/.claude/settings.local.json +0 -3
  59. package/.prettierrc +0 -7
  60. package/Agents.md +0 -66
  61. package/SETUP.md +0 -171
  62. package/examples/assert_testing.py +0 -38
  63. package/examples/big_int_precision.py +0 -2
  64. package/examples/boolean_logic.py +0 -35
  65. package/examples/break_continue.py +0 -43
  66. package/examples/classes_objects.py +0 -43
  67. package/examples/compiler_killer_async.py +0 -6
  68. package/examples/compiler_killer_bigint.py +0 -3
  69. package/examples/compiler_killer_bool_int_dict_key.py +0 -5
  70. package/examples/compiler_killer_bool_len.py +0 -9
  71. package/examples/compiler_killer_floor_division.py +0 -4
  72. package/examples/compiler_killer_is_identity.py +0 -3
  73. package/examples/compiler_killer_list_sort_return.py +0 -3
  74. package/examples/compiler_killer_match.py +0 -13
  75. package/examples/compiler_killer_negative_repeat.py +0 -3
  76. package/examples/compiler_killer_negative_zero_repr.py +0 -3
  77. package/examples/compiler_killer_rounding.py +0 -4
  78. package/examples/compiler_killer_slice_assign.py +0 -3
  79. package/examples/comprehensions.py +0 -28
  80. package/examples/conditions.py +0 -13
  81. package/examples/context_manager.py +0 -35
  82. package/examples/decorators.py +0 -50
  83. package/examples/exceptions.py +0 -40
  84. package/examples/fibonacci.py +0 -10
  85. package/examples/functions.py +0 -38
  86. package/examples/generator.py +0 -51
  87. package/examples/global_nonlocal.py +0 -48
  88. package/examples/hello.py +0 -3
  89. package/examples/itertools_example.py +0 -33
  90. package/examples/lists_dicts.py +0 -29
  91. package/examples/loops.py +0 -19
  92. package/examples/math_ops.py +0 -15
  93. package/examples/nan_set.py +0 -6
  94. package/examples/numbers_operators.py +0 -51
  95. package/examples/sets.py +0 -36
  96. package/examples/slicing.py +0 -29
  97. package/examples/starred_unpacking.py +0 -3
  98. package/examples/string_formatting.py +0 -36
  99. package/examples/strings.py +0 -22
  100. package/examples/tuples.py +0 -45
  101. package/examples/type_conversion.py +0 -41
  102. package/jest.config.js +0 -15
  103. package/notes/iterations/compiler-runtime/compiler-runtime_2025-09-16.md +0 -25
  104. package/notes/iterations/compiler-runtime/compiler-runtime_2026-01-16.md +0 -24
  105. package/notes/iterations/compiler-runtime/compiler-runtime_test_2026-01-16.md +0 -21
  106. package/notes/iterations/floor-division/floor-division_2026-01-16.md +0 -29
  107. package/prompts/commit.txt +0 -9
  108. package/prompts/task.txt +0 -21
  109. package/prompts/test.txt +0 -23
  110. package/scripts/codex-loop.js +0 -215
  111. package/scripts/verify.sh +0 -12
  112. package/src/compiler.ts +0 -58
  113. package/src/compiler_module/compiler.ts +0 -19
  114. package/src/compiler_module/index.ts +0 -1
  115. package/src/index.ts +0 -39
  116. package/src/lexer/index.ts +0 -1
  117. package/src/lexer/lexer.ts +0 -402
  118. package/src/parser/expressions.ts +0 -462
  119. package/src/parser/index.ts +0 -1
  120. package/src/parser/parser.ts +0 -102
  121. package/src/parser/statements.ts +0 -366
  122. package/src/parser/targets.ts +0 -71
  123. package/src/types/ast.ts +0 -64
  124. package/src/types/bytecode.ts +0 -50
  125. package/src/types/index.ts +0 -3
  126. package/src/types/token.ts +0 -44
  127. package/src/vm/builtins.ts +0 -237
  128. package/src/vm/callable.ts +0 -154
  129. package/src/vm/execution.ts +0 -251
  130. package/src/vm/expression-generator.ts +0 -65
  131. package/src/vm/expressions.ts +0 -373
  132. package/src/vm/imports.ts +0 -61
  133. package/src/vm/index.ts +0 -2
  134. package/src/vm/operations.ts +0 -414
  135. package/src/vm/runtime-types.ts +0 -292
  136. package/src/vm/statements.ts +0 -358
  137. package/src/vm/truthy.ts +0 -36
  138. package/src/vm/value-utils.ts +0 -173
  139. package/src/vm/vm.ts +0 -80
  140. package/tests/compiler.test.ts +0 -111
  141. package/tsconfig.json +0 -20
  142. package/vitest.config.ts +0 -16
@@ -1,111 +0,0 @@
1
- import { PythonCompiler } from '../src/index';
2
- import { execFileSync } from 'child_process';
3
- import * as fs from 'fs';
4
- import * as path from 'path';
5
-
6
- const pythonCommandCandidates = [
7
- process.env.PYTHON,
8
- 'python3',
9
- 'python',
10
- ].filter(Boolean) as string[];
11
-
12
- const runPythonFile = (filePath: string): string => {
13
- const errors: { cmd: string; error: string }[] = [];
14
-
15
- for (const cmd of pythonCommandCandidates) {
16
- try {
17
- return execFileSync(cmd, [filePath], { encoding: 'utf8' });
18
- } catch (error) {
19
- const errorMsg = error instanceof Error ? error.message : String(error);
20
- errors.push({ cmd, error: errorMsg });
21
- }
22
- }
23
-
24
- const errorDetails = errors
25
- .map(({ cmd, error }) => ` • ${cmd}: ${error}`)
26
- .join('\n');
27
-
28
- throw new Error(
29
- `❌ Python interpreter not found\n\n` +
30
- `Attempted commands:\n${errorDetails}\n\n` +
31
- `Please ensure Python 3 is installed and in your PATH, or set the PYTHON environment variable.`
32
- );
33
- };
34
-
35
- const captureOutput = (fn: () => void): string => {
36
- const outputChunks: string[] = [];
37
- const originalWrite = process.stdout.write;
38
-
39
- process.stdout.write = ((chunk: any) => {
40
- const normalized =
41
- typeof chunk === 'string' ? chunk : chunk.toString('utf8');
42
- outputChunks.push(normalized);
43
- return true;
44
- }) as any;
45
-
46
- try {
47
- fn();
48
- } finally {
49
- process.stdout.write = originalWrite;
50
- }
51
-
52
- return outputChunks.join('');
53
- };
54
-
55
- describe('PythonCompiler - Public API Tests', () => {
56
- let compiler: PythonCompiler;
57
-
58
- beforeEach(() => {
59
- compiler = new PythonCompiler();
60
- });
61
-
62
- describe('runFile() method', () => {
63
- const examplesDir = path.join(__dirname, '../examples');
64
- const exampleFiles = fs
65
- .readdirSync(examplesDir)
66
- .filter((file) => file.endsWith('.py'))
67
- .sort();
68
-
69
- it('should match output for example files', () => {
70
- const failedTests: Array<{ file: string; expected: string; actual: string }> = [];
71
-
72
- for (const fileName of exampleFiles) {
73
- const filePath = path.join(examplesDir, fileName);
74
- const expectedOutput = runPythonFile(filePath);
75
- const actualOutput = captureOutput(() => {
76
- compiler.runFile(filePath);
77
- });
78
-
79
- if (actualOutput !== expectedOutput) {
80
- failedTests.push({
81
- file: fileName,
82
- expected: expectedOutput,
83
- actual: actualOutput,
84
- });
85
- }
86
- }
87
-
88
- if (failedTests.length > 0) {
89
- const failureDetails = failedTests
90
- .map(({ file, expected, actual }) => {
91
- return (
92
- `\n📄 ${file}\n` +
93
- ` Expected:\n${expected
94
- .split('\n')
95
- .map((l) => ` ${l}`)
96
- .join('\n')}\n` +
97
- ` Actual:\n${actual
98
- .split('\n')
99
- .map((l) => ` ${l}`)
100
- .join('\n')}`
101
- );
102
- })
103
- .join('\n');
104
-
105
- throw new Error(
106
- `❌ ${failedTests.length} test(s) failed:${failureDetails}`
107
- );
108
- }
109
- });
110
- });
111
- });
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": ["ES2020"],
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "resolveJsonModule": true,
13
- "declaration": true,
14
- "declarationMap": true,
15
- "sourceMap": true,
16
- "moduleResolution": "node"
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist", "tests"]
20
- }
package/vitest.config.ts DELETED
@@ -1,16 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: 'node',
7
- include: ['tests/**/*.test.ts'],
8
- coverage: {
9
- provider: 'v8',
10
- reporter: ['text', 'json', 'html'],
11
- include: ['src/**/*.ts'],
12
- exclude: ['src/**/*.d.ts'],
13
- },
14
- testTimeout: 10000,
15
- },
16
- });