timewarp-ide 1.0.0__py3-none-any.whl

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 (135) hide show
  1. compilers/__init__.py +37 -0
  2. compilers/base.py +205 -0
  3. compilers/basic_compiler.py +806 -0
  4. compilers/logo_compiler.py +570 -0
  5. compilers/pilot_compiler.py +585 -0
  6. core/__init__.py +18 -0
  7. core/audio/__init__.py +8 -0
  8. core/audio/engine.py +363 -0
  9. core/debugging/__init__.py +24 -0
  10. core/debugging/error_analyzer.py +710 -0
  11. core/debugging/performance_monitor.py +704 -0
  12. core/debugging/test_framework.py +634 -0
  13. core/debugging/visual_debugger.py +481 -0
  14. core/editor/__init__.py +18 -0
  15. core/editor/code_completion.py +441 -0
  16. core/editor/code_completion_engine.py +412 -0
  17. core/editor/code_formatter.py +262 -0
  18. core/editor/compiler_manager.py +396 -0
  19. core/editor/enhanced_editor.py +762 -0
  20. core/editor/language_engine.py +591 -0
  21. core/editor/syntax_analyzer.py +427 -0
  22. core/framework.py +538 -0
  23. core/hardware/__init__.py +8 -0
  24. core/hardware/devices.py +317 -0
  25. core/interpreter.py +1230 -0
  26. core/iot/__init__.py +8 -0
  27. core/iot/devices.py +380 -0
  28. core/language/__init__.py +18 -0
  29. core/language/compiler/__init__.py +19 -0
  30. core/language/compiler/codegen.py +310 -0
  31. core/language/compiler/lexer.py +491 -0
  32. core/language/compiler/optimizer.py +146 -0
  33. core/language/compiler/parser.py +566 -0
  34. core/language/errors/__init__.py +17 -0
  35. core/language/errors/error_manager.py +224 -0
  36. core/language/handlers/__init__.py +14 -0
  37. core/language/handlers/logo_handler.py +287 -0
  38. core/language/handlers/pilot_handler.py +221 -0
  39. core/language/handlers/python_handler.py +224 -0
  40. core/language/interpreter.py +447 -0
  41. core/language/james_compiler.py +289 -0
  42. core/language/lexer.py +346 -0
  43. core/language/parser.py +909 -0
  44. core/language/plugins/__init__.py +18 -0
  45. core/language/plugins/base.py +367 -0
  46. core/language/plugins/loader.py +313 -0
  47. core/language/plugins/manager.py +257 -0
  48. core/language/plugins/registry.py +206 -0
  49. core/language/runtime/__init__.py +17 -0
  50. core/language/runtime/engine.py +383 -0
  51. core/language/runtime/modes.py +9 -0
  52. core/language/runtime/variables.py +9 -0
  53. core/language/stdlib/core.py +237 -0
  54. core/language/tests/__init__.py +20 -0
  55. core/language/tests/test_errors.py +115 -0
  56. core/language/tests/test_integration.py +182 -0
  57. core/language/tests/test_stdlib.py +155 -0
  58. core/languages/__init__.py +21 -0
  59. core/languages/basic.py +617 -0
  60. core/languages/javascript_executor.py +137 -0
  61. core/languages/logo.py +553 -0
  62. core/languages/perl.py +142 -0
  63. core/languages/pilot.py +641 -0
  64. core/languages/python_executor.py +100 -0
  65. core/networking/__init__.py +8 -0
  66. core/networking/collaboration.py +518 -0
  67. core/optimizations/performance_optimizer.py +307 -0
  68. core/utilities/__init__.py +12 -0
  69. core/utilities/animation.py +40 -0
  70. core/utilities/audio.py +45 -0
  71. core/utilities/hardware.py +58 -0
  72. core/utilities/particles.py +24 -0
  73. core/utilities/timing.py +23 -0
  74. docs/languages/basic.md +283 -0
  75. docs/languages/logo.md +487 -0
  76. docs/languages/pilot.md +400 -0
  77. features/ai_assistant.py +502 -0
  78. features/gamification.py +1093 -0
  79. features/tutorial_system.py +457 -0
  80. games/__init__.py +17 -0
  81. games/engine/__init__.py +11 -0
  82. games/engine/game_manager.py +183 -0
  83. games/engine/game_objects.py +120 -0
  84. games/engine/game_renderer.py +81 -0
  85. games/engine/physics.py +157 -0
  86. gui/__init__.py +19 -0
  87. gui/components/__init__.py +22 -0
  88. gui/components/dialogs.py +1210 -0
  89. gui/components/educational_debug.py +344 -0
  90. gui/components/project_explorer.py +311 -0
  91. gui/components/venv_manager.py +202 -0
  92. gui/editor/__init__.py +543 -0
  93. gui/editor/features.py +737 -0
  94. plugins/__init__.py +560 -0
  95. plugins/plugins/code_formatter/manifest.json +9 -0
  96. plugins/plugins/code_formatter/plugin.py +348 -0
  97. plugins/plugins/syntax_highlighter/manifest.json +9 -0
  98. plugins/plugins/syntax_highlighter/plugin.py +350 -0
  99. plugins/sample_plugin/manifest.json +9 -0
  100. plugins/sample_plugin/plugin.py +208 -0
  101. samples/basic/arrays.bas +20 -0
  102. samples/basic/functions.bas +102 -0
  103. samples/basic/hello.bas +11 -0
  104. samples/basic_ascii_art.bas +163 -0
  105. samples/logo/complex.logo +97 -0
  106. samples/logo/shapes.logo +44 -0
  107. samples/logo_geometry_explorer.logo +297 -0
  108. samples/pilot/adventure.pilot +445 -0
  109. samples/pilot/math_quiz.pilot +72 -0
  110. samples/pilot_math_quiz.pilot +81 -0
  111. samples/python_data_science_demo.py +399 -0
  112. samples/sample_basic_program.bas +25 -0
  113. samples/sample_logo_program.logo +63 -0
  114. samples/sample_pilot_program.pilot +22 -0
  115. samples/sample_python_program.py +233 -0
  116. timewarp_ide/__init__.py +32 -0
  117. timewarp_ide/compiler.py +117 -0
  118. timewarp_ide/main.py +32 -0
  119. timewarp_ide-1.0.0.dist-info/METADATA +357 -0
  120. timewarp_ide-1.0.0.dist-info/RECORD +135 -0
  121. timewarp_ide-1.0.0.dist-info/WHEEL +5 -0
  122. timewarp_ide-1.0.0.dist-info/entry_points.txt +4 -0
  123. timewarp_ide-1.0.0.dist-info/licenses/LICENSE +21 -0
  124. timewarp_ide-1.0.0.dist-info/top_level.txt +10 -0
  125. tools/__init__.py +14 -0
  126. tools/ml/__init__.py +9 -0
  127. tools/ml/aiml_integration.py +296 -0
  128. tools/ml/ml_manager_dialog.py +333 -0
  129. tools/plugins/advanced_debugger/plugin.py +726 -0
  130. tools/plugins/hardware_controller/plugin.py +620 -0
  131. tools/plugins/iot_device_manager/plugin.py +722 -0
  132. tools/plugins/learning_assistant/plugin.py +1131 -0
  133. tools/plugins/sensor_visualizer/plugin.py +765 -0
  134. tools/theme.py +490 -0
  135. tools/tool_manager.py +659 -0
compilers/__init__.py ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ TimeWarp Native Compilers
4
+ ==========================
5
+
6
+ A unified compiler framework for converting TimeWarp IDE languages
7
+ (BASIC, Logo, PILOT) into standalone Linux executables.
8
+ """
9
+
10
+ from .base import BaseCompiler, CodeGenerator, CompilerResult, Language
11
+ from .basic_compiler import BasicCompiler
12
+ from .logo_compiler import LogoCompiler
13
+ from .pilot_compiler import PilotCompiler
14
+
15
+
16
+ def create_compiler(language: Language) -> BaseCompiler:
17
+ """Factory function to create appropriate compiler"""
18
+ if language == Language.BASIC:
19
+ return BasicCompiler()
20
+ elif language == Language.LOGO:
21
+ return LogoCompiler()
22
+ elif language == Language.PILOT:
23
+ return PilotCompiler()
24
+ else:
25
+ raise ValueError(f"Unsupported language: {language}")
26
+
27
+
28
+ __all__ = [
29
+ 'BaseCompiler',
30
+ 'CodeGenerator',
31
+ 'CompilerResult',
32
+ 'Language',
33
+ 'create_compiler',
34
+ 'BasicCompiler',
35
+ 'LogoCompiler',
36
+ 'PilotCompiler',
37
+ ]
compilers/base.py ADDED
@@ -0,0 +1,205 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ TimeWarp Native Compilers
4
+ ==========================
5
+
6
+ A unified compiler framework for converting TimeWarp IDE languages
7
+ (BASIC, Logo, PILOT) into standalone Linux executables.
8
+
9
+ This framework provides:
10
+ - Unified compiler interface
11
+ - Common code generation utilities
12
+ - Cross-language optimizations
13
+ - Native executable output
14
+ """
15
+
16
+ import os
17
+ import subprocess
18
+ import tempfile
19
+ from abc import ABC, abstractmethod
20
+ from typing import List, Any, Optional
21
+ from dataclasses import dataclass
22
+ from enum import Enum
23
+
24
+
25
+ class Language(Enum):
26
+ """Supported programming languages"""
27
+ BASIC = "basic"
28
+ LOGO = "logo"
29
+ PILOT = "pilot"
30
+
31
+
32
+ @dataclass
33
+ class CompilerResult:
34
+ """Result of compilation process"""
35
+ success: bool
36
+ executable_path: Optional[str] = None
37
+ error_message: Optional[str] = None
38
+ warnings: Optional[List[str]] = None
39
+
40
+ def __post_init__(self):
41
+ if self.warnings is None:
42
+ self.warnings = []
43
+
44
+
45
+ class CodeGenerator(ABC):
46
+ """Abstract base class for code generators"""
47
+
48
+ def __init__(self, language: Language):
49
+ self.language = language
50
+ self.debug = False
51
+ self.optimize = False
52
+
53
+ @abstractmethod
54
+ def generate_header(self) -> List[str]:
55
+ """Generate language-specific header code"""
56
+ raise NotImplementedError
57
+
58
+ @abstractmethod
59
+ def generate_runtime(self) -> List[str]:
60
+ """Generate runtime support functions"""
61
+ raise NotImplementedError
62
+
63
+ @abstractmethod
64
+ def generate_main(self, statements: List[Any]) -> List[str]:
65
+ """Generate main function from parsed statements"""
66
+ raise NotImplementedError
67
+
68
+ def generate_c_code(self, statements: List[Any]) -> str:
69
+ """Generate complete C code"""
70
+ lines = []
71
+
72
+ # Add header
73
+ lines.extend(self.generate_header())
74
+
75
+ # Add runtime functions
76
+ lines.extend(self.generate_runtime())
77
+
78
+ # Add main function
79
+ lines.extend(self.generate_main(statements))
80
+
81
+ return "\n".join(lines)
82
+
83
+
84
+ class BaseCompiler(ABC):
85
+ """Abstract base compiler class"""
86
+
87
+ def __init__(self, language: Language):
88
+ self.language = language
89
+ self.debug = False
90
+ self.optimize = False
91
+ self.code_generator = self.create_code_generator()
92
+
93
+ @abstractmethod
94
+ def create_code_generator(self) -> CodeGenerator:
95
+ """Create the appropriate code generator"""
96
+ raise NotImplementedError
97
+
98
+ @abstractmethod
99
+ def parse_source(self, source: str) -> List[Any]:
100
+ """Parse source code into statements"""
101
+ raise NotImplementedError
102
+
103
+ def compile_file(self, input_file: str, output_file: Optional[str] = None) -> CompilerResult:
104
+ """Compile source file to executable"""
105
+ try:
106
+ # Read source
107
+ with open(input_file, 'r', encoding='utf-8') as f:
108
+ source = f.read()
109
+
110
+ # Determine output filename
111
+ if not output_file:
112
+ base_name = os.path.splitext(os.path.basename(input_file))[0]
113
+ output_file = f"{base_name}_compiled"
114
+
115
+ return self.compile_source(source, output_file)
116
+
117
+ except (IOError, OSError) as e:
118
+ return CompilerResult(
119
+ success=False,
120
+ error_message=f"File error: {str(e)}"
121
+ )
122
+
123
+ def compile_source(self, source: str, output_file: str) -> CompilerResult:
124
+ """Compile source code to executable"""
125
+ try:
126
+ print(f"🔧 Compiling {self.language.value.upper()} source to executable: {output_file}")
127
+
128
+ # Parse source
129
+ print("📝 Step 1: Parsing source...")
130
+ statements = self.parse_source(source)
131
+ print(f" Found {len(statements)} statements")
132
+
133
+ if self.debug:
134
+ self.print_statements(statements)
135
+
136
+ # Generate C code
137
+ print("⚙️ Step 2: Generating C code...")
138
+ c_code = self.code_generator.generate_c_code(statements)
139
+
140
+ if self.debug:
141
+ print("Generated C code preview:")
142
+ print(c_code[:1000] + "..." if len(c_code) > 1000 else c_code)
143
+
144
+ # Build executable
145
+ print("🔨 Step 3: Building executable...")
146
+ success = self.build_executable(c_code, output_file)
147
+
148
+ if success:
149
+ print(f"✅ Compilation successful: {output_file}")
150
+ os.chmod(output_file, 0o755)
151
+ return CompilerResult(success=True, executable_path=output_file)
152
+ else:
153
+ return CompilerResult(
154
+ success=False,
155
+ error_message="C compilation failed"
156
+ )
157
+
158
+ except (ValueError, RuntimeError) as e:
159
+ return CompilerResult(
160
+ success=False,
161
+ error_message=f"Compilation failed: {str(e)}"
162
+ )
163
+
164
+ def build_executable(self, c_code: str, output_file: str) -> bool:
165
+ """Compile C code to executable"""
166
+ try:
167
+ # Create temporary C file
168
+ with tempfile.NamedTemporaryFile(mode='w', suffix='.c', delete=False) as f:
169
+ f.write(c_code)
170
+ c_file = f.name
171
+
172
+ try:
173
+ # Compile with gcc
174
+ cmd = ['gcc', '-o', output_file, c_file, '-lm']
175
+
176
+ if self.optimize:
177
+ cmd.extend(['-O2'])
178
+ else:
179
+ cmd.extend(['-g']) # Debug symbols
180
+
181
+ result = subprocess.run(cmd, capture_output=True, text=True, check=False)
182
+
183
+ if result.returncode == 0:
184
+ print(" C compilation successful")
185
+ return True
186
+ else:
187
+ print(f" C compilation failed: {result.stderr}")
188
+ return False
189
+
190
+ finally:
191
+ # Clean up temporary file
192
+ os.unlink(c_file)
193
+
194
+ except (subprocess.SubprocessError, OSError) as e:
195
+ print(f" Build error: {e}")
196
+ return False
197
+
198
+ def print_statements(self, statements: List[Any]):
199
+ """Print statements for debugging"""
200
+ print(f"\n=== {self.language.value.upper()} STATEMENTS ===")
201
+ for i, stmt in enumerate(statements[:20]): # Limit output
202
+ print(f"{i}: {stmt}")
203
+ if len(statements) > 20:
204
+ print(f"... and {len(statements) - 20} more statements")
205
+ print()