-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlumen.php
42 lines (37 loc) · 1.1 KB
/
lumen.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
$requirements = [
"root" => "./src/cli.php",
"dependencies" => [
"./src/structures/cursor.php",
"./src/structures/diagnostic.php",
"./src/structures/tokens.php",
"./src/lexer.php",
"./src/structures/nodes.php",
"./src/nativelib/array.php",
"./src/nativelib/math.php",
"./src/nativelib/std.php",
"./src/nativelib/core.php",
"./src/parser.php",
"./src/optimizer.php",
"./src/interpreter.php",
]
];
function loadAndStripPHP($filePath) {
if (!file_exists($filePath)) {
throw new Exception("File not found: $filePath");
}
$content = file_get_contents($filePath);
$content = preg_replace('/^\s*<\?php\s*/', '', $content, 1);
$content = preg_replace('/\s*\?>\s*$/', '', $content, 1);
return $content;
}
try {
$code = "";
foreach ($requirements["dependencies"] as $dependency) {
$code .= loadAndStripPHP($dependency);
}
$code .= loadAndStripPHP($requirements["root"]);
eval($code);
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}