os-lang 0.1.0__tar.gz

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.
os_lang-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: os-lang
3
+ Version: 0.1.0
4
+ Summary: A next-generation Pythonic language for building bare-metal Operating Systems.
5
+ Author: Manus AI
6
+ Author-email: Hamza <founder@nexus-os.org>
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Topic :: Software Development :: Compilers
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: llvmlite>=0.40.0
14
+ Requires-Dist: Flask>=2.0.0
15
+ Dynamic: author
16
+
17
+ # OS Programming Language
18
+
19
+ A new, highly efficient systems programming language designed for building operating systems.
20
+
21
+ ## Running the Compiler
22
+
23
+ To run the compiler:
24
+ ```bash
25
+ python src/main.py <source_file>
26
+ ```
@@ -0,0 +1,10 @@
1
+ # OS Programming Language
2
+
3
+ A new, highly efficient systems programming language designed for building operating systems.
4
+
5
+ ## Running the Compiler
6
+
7
+ To run the compiler:
8
+ ```bash
9
+ python src/main.py <source_file>
10
+ ```
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: os-lang
3
+ Version: 0.1.0
4
+ Summary: A next-generation Pythonic language for building bare-metal Operating Systems.
5
+ Author: Manus AI
6
+ Author-email: Hamza <founder@nexus-os.org>
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Topic :: Software Development :: Compilers
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: llvmlite>=0.40.0
14
+ Requires-Dist: Flask>=2.0.0
15
+ Dynamic: author
16
+
17
+ # OS Programming Language
18
+
19
+ A new, highly efficient systems programming language designed for building operating systems.
20
+
21
+ ## Running the Compiler
22
+
23
+ To run the compiler:
24
+ ```bash
25
+ python src/main.py <source_file>
26
+ ```
@@ -0,0 +1,26 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ os_lang.egg-info/PKG-INFO
5
+ os_lang.egg-info/SOURCES.txt
6
+ os_lang.egg-info/dependency_links.txt
7
+ os_lang.egg-info/entry_points.txt
8
+ os_lang.egg-info/requires.txt
9
+ os_lang.egg-info/top_level.txt
10
+ src/__init__.py
11
+ src/ast.py
12
+ src/codegen.py
13
+ src/lexer.py
14
+ src/main.py
15
+ src/parser.py
16
+ src/semantic.py
17
+ src/token.py
18
+ tests/test_codegen.py
19
+ tests/test_lexer.py
20
+ tests/test_parser.py
21
+ tests/test_phase10.py
22
+ tests/test_phase11.py
23
+ tests/test_phase7.py
24
+ tests/test_phase8.py
25
+ tests/test_phase9.py
26
+ tests/test_semantic.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ osc = src.main:main
3
+ osc-gui = gui:main_gui
@@ -0,0 +1,2 @@
1
+ llvmlite>=0.40.0
2
+ Flask>=2.0.0
@@ -0,0 +1 @@
1
+ src
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "os-lang"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Hamza", email="founder@nexus-os.org" },
10
+ ]
11
+ description = "A next-generation Pythonic language for building bare-metal Operating Systems."
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Topic :: Software Development :: Compilers",
19
+ ]
20
+ dependencies = [
21
+ "llvmlite>=0.40.0",
22
+ "Flask>=2.0.0",
23
+ ]
24
+
25
+ [project.scripts]
26
+ osc = "src.main:main"
27
+ osc-gui = "gui:main_gui"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
os_lang-0.1.0/setup.py ADDED
@@ -0,0 +1,19 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='os-lang',
5
+ version='0.1.0',
6
+ packages=['src'],
7
+ install_requires=[
8
+ 'llvmlite',
9
+ 'pytest',
10
+ ],
11
+ entry_points={
12
+ 'console_scripts': [
13
+ 'osc=src.main:main',
14
+ 'osc-gui=gui:main_gui',
15
+ ],
16
+ },
17
+ author='Manus AI',
18
+ description='Next-Generation OS Development Language Compiler',
19
+ )
File without changes
@@ -0,0 +1,232 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import List, Optional
3
+
4
+ class ASTNode:
5
+ """Base class for all Abstract Syntax Tree nodes."""
6
+ pass
7
+
8
+ # ==========================================
9
+ # Expressions (Produce a value)
10
+ # ==========================================
11
+
12
+ @dataclass
13
+ class NumberLiteral(ASTNode):
14
+ value: float # Stored as float to handle both int/float
15
+
16
+ @dataclass
17
+ class BoolLiteral(ASTNode):
18
+ value: bool
19
+
20
+ @dataclass
21
+ class StringLiteral(ASTNode):
22
+ value: str
23
+
24
+ @dataclass
25
+ class Identifier(ASTNode):
26
+ name: str
27
+
28
+ @dataclass
29
+ class BinaryOp(ASTNode):
30
+ left: ASTNode
31
+ operator: str
32
+ right: ASTNode
33
+
34
+ @dataclass
35
+ class FunctionCall(ASTNode):
36
+ callee: ASTNode
37
+ arguments: List[ASTNode]
38
+
39
+ @dataclass
40
+ class MemberAccess(ASTNode):
41
+ object: ASTNode
42
+ property: 'Identifier'
43
+
44
+ @dataclass
45
+ class Cast(ASTNode):
46
+ expr: ASTNode
47
+ target_type: str
48
+
49
+ @dataclass
50
+ class SizeOf(ASTNode):
51
+ target_type: str
52
+
53
+ # ==========================================
54
+ # Phase 7: New Expression Nodes
55
+ # ==========================================
56
+
57
+ @dataclass
58
+ class ArrayLiteral(ASTNode):
59
+ """Represents [1, 2, 3] array literal expressions."""
60
+ elements: List[ASTNode]
61
+
62
+ @dataclass
63
+ class ArrayIndex(ASTNode):
64
+ """Represents array[index] element access."""
65
+ array: ASTNode
66
+ index: ASTNode
67
+
68
+ @dataclass
69
+ class StructLiteral(ASTNode):
70
+ """Represents MyStruct { field: value, ... } struct initialization."""
71
+ struct_name: str
72
+ fields: List[tuple] # List of (field_name: str, value: ASTNode)
73
+
74
+ @dataclass
75
+ class EnumVariant(ASTNode):
76
+ """Represents an enum variant access: Status.OK"""
77
+ enum_name: str
78
+ variant: str
79
+
80
+ # ==========================================
81
+ # Statements (Do not produce a value)
82
+ # ==========================================
83
+
84
+ @dataclass
85
+ class VariableDeclaration(ASTNode):
86
+ name: 'Identifier'
87
+ is_mut: bool
88
+ type_annotation: Optional[str]
89
+ initializer: Optional[ASTNode]
90
+ is_shared: bool = False
91
+
92
+ @dataclass
93
+ class Assignment(ASTNode):
94
+ target: ASTNode
95
+ value: ASTNode
96
+
97
+ @dataclass
98
+ class ImportStatement(ASTNode):
99
+ module_name: str
100
+
101
+ @dataclass
102
+ class ReturnStatement(ASTNode):
103
+ value: Optional[ASTNode]
104
+
105
+ @dataclass
106
+ class Block(ASTNode):
107
+ """A collection of statements, e.g., inside an if-statement or function."""
108
+ statements: List[ASTNode]
109
+
110
+ @dataclass
111
+ class IfStatement(ASTNode):
112
+ condition: ASTNode
113
+ then_block: Block
114
+ elif_branches: List[tuple] # List of (condition, block)
115
+ else_block: Optional[Block]
116
+
117
+ @dataclass
118
+ class WhileStatement(ASTNode):
119
+ condition: ASTNode
120
+ body: Block
121
+
122
+ @dataclass
123
+ class FunctionDeclaration(ASTNode):
124
+ name: 'Identifier'
125
+ parameters: List[tuple] # List of (name, type)
126
+ return_type: Optional[str]
127
+ body: Block
128
+ # Phase 6: existing decorators
129
+ is_unsafe: bool = False
130
+ is_interrupt: bool = False
131
+ interrupt_number: Optional[int] = None
132
+ # Phase 9: new OS primitive decorators
133
+ is_syscall: bool = False
134
+ syscall_number: Optional[int] = None # @syscall(0x80)
135
+ is_driver: bool = False # @driver
136
+ is_noreturn: bool = False # @noreturn (panic, halt)
137
+ is_naked: bool = False # @naked (no stack frame)
138
+
139
+ @dataclass
140
+ class StructDeclaration(ASTNode):
141
+ name: 'Identifier'
142
+ fields: List[tuple] # List of (name, type)
143
+ is_hwmap: bool = False
144
+
145
+ @dataclass
146
+ class EnumDeclaration(ASTNode):
147
+ """Phase 7: enum Status { OK, ERROR, PENDING }"""
148
+ name: 'Identifier'
149
+ variants: List[str] # List of variant names
150
+
151
+ @dataclass
152
+ class LockBlock(ASTNode):
153
+ """Represents a `lock x:` concurrency block."""
154
+ target: 'Identifier'
155
+ body: Block
156
+
157
+ @dataclass
158
+ class UnsafeBlock(ASTNode):
159
+ """Represents an `@unsafe` block."""
160
+ body: Block
161
+
162
+ @dataclass
163
+ class AsmBlock(ASTNode):
164
+ """Represents an inline assembly block `asm \"...\"`."""
165
+ assembly_string: str
166
+
167
+ # ==========================================
168
+ # Phase 8: C Interoperability Nodes
169
+ # ==========================================
170
+
171
+ @dataclass
172
+ class ExternDeclaration(ASTNode):
173
+ """
174
+ A single extern function signature, e.g.:
175
+ extern "C" fn printf(fmt: str, ...) -> int
176
+ """
177
+ name: 'Identifier'
178
+ parameters: List[tuple] # [(Identifier, type_str), ...]
179
+ return_type: Optional[str]
180
+ is_variadic: bool
181
+ abi: str # e.g. "C"
182
+
183
+ @dataclass
184
+ class ExternBlock(ASTNode):
185
+ """
186
+ A block of extern declarations sharing one ABI, e.g.:
187
+ extern "C":
188
+ fn malloc(size: int) -> ptr
189
+ fn free(ptr: ptr)
190
+ """
191
+ abi: str
192
+ declarations: List[ExternDeclaration]
193
+
194
+ # ==========================================
195
+ # Phase 9: OS Primitive Nodes
196
+ # ==========================================
197
+
198
+ @dataclass
199
+ class OsIntrinsicCall(ASTNode):
200
+ """
201
+ Built-in OS intrinsics that map directly to single instructions:
202
+ halt() → hlt
203
+ cli() → cli
204
+ sti() → sti
205
+ rdtsc() → rdtsc (returns u64 timestamp)
206
+ cpuid(leaf: int) → cpuid (returns struct CpuInfo)
207
+ outb(port: int, val: int)
208
+ inb(port: int) -> int
209
+ """
210
+ name: str # e.g. "halt", "cli", "sti", "rdtsc"
211
+ arguments: List[ASTNode]
212
+
213
+ # ==========================================
214
+ # Phase 10: OS Advanced Primitives
215
+ # ==========================================
216
+
217
+ @dataclass
218
+ class AsmBlock(ASTNode):
219
+ """
220
+ Inline assembly blocks: asm("mov cr3, {0}", in: ptr)
221
+ """
222
+ assembly_string: str
223
+ args: List[tuple] # [("in", ASTNode), ("out", ASTNode), ...]
224
+
225
+ # ==========================================
226
+ # Root Node
227
+ # ==========================================
228
+
229
+ @dataclass
230
+ class Program(ASTNode):
231
+ """The root of the AST representing an entire source file."""
232
+ statements: List[ASTNode]