-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore_language.py
More file actions
28 lines (25 loc) · 908 Bytes
/
core_language.py
File metadata and controls
28 lines (25 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# core_language.py
class LanguageInterpreter:
def __init__(self):
self.environment = {}
def parse(self, code: str):
# Basic parsing logic for the second-layer language
lines = code.splitlines()
parsed = []
for line in lines:
command, *args = line.split()
parsed.append((command, args))
return parsed
def execute(self, parsed_code):
for command, args in parsed_code:
self.dispatch_command(command, args)
def dispatch_command(self, command, args):
# Basic command dispatch logic
if command == "PRINT":
print(" ".join(args))
elif command == "SET":
var_name = args[0]
value = " ".join(args[1:])
self.environment[var_name] = value
else:
print(f"Unknown command: {command}")