camel-lang 0.0.11__py3-none-win_amd64.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.
- camel/.cmlenv/bin/camel.exe +0 -0
- camel/.cmlenv/lib/std/ctrl.cml +16 -0
- camel/.cmlenv/lib/std/std.cml +126 -0
- camel/__init__.py +5 -0
- camel/cli.py +101 -0
- camel_lang-0.0.11.dist-info/LICENSE +21 -0
- camel_lang-0.0.11.dist-info/METADATA +45 -0
- camel_lang-0.0.11.dist-info/RECORD +11 -0
- camel_lang-0.0.11.dist-info/WHEEL +5 -0
- camel_lang-0.0.11.dist-info/entry_points.txt +3 -0
- camel_lang-0.0.11.dist-info/top_level.txt +1 -0
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024 Beijing Jiaotong University
|
|
3
|
+
* Camel is licensed under the MIT license.
|
|
4
|
+
* You can use this software according to the terms and conditions of the the MIT license.
|
|
5
|
+
* You may obtain a copy of the MIT license at: [https://opensource.org/license/mit]
|
|
6
|
+
*
|
|
7
|
+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
8
|
+
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
9
|
+
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
10
|
+
*
|
|
11
|
+
* See the the MIT license for more details.
|
|
12
|
+
*
|
|
13
|
+
* Author: Zhenjie Wei
|
|
14
|
+
* Created: Sep. 01, 2023
|
|
15
|
+
* Supported by: National Key Research and Development Program of China
|
|
16
|
+
*/
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2024 Beijing Jiaotong University
|
|
3
|
+
* Camel is licensed under the MIT license.
|
|
4
|
+
* You can use this software according to the terms and conditions of the the MIT license.
|
|
5
|
+
* You may obtain a copy of the MIT license at: [https://opensource.org/license/mit]
|
|
6
|
+
*
|
|
7
|
+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
8
|
+
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
9
|
+
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
10
|
+
*
|
|
11
|
+
* See the the MIT license for more details.
|
|
12
|
+
*
|
|
13
|
+
* Author: Zhenjie Wei
|
|
14
|
+
* Created: Sep. 01, 2023
|
|
15
|
+
* Supported by: National Key Research and Development Program of China
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This CML module will be imported by interpreter automatically,
|
|
20
|
+
* and can be accessed Anywhere in Any CML script.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// psl, json, phtc, xml, toml
|
|
24
|
+
|
|
25
|
+
with <loader: Functor = psl>
|
|
26
|
+
inner func load(path: String): Any {
|
|
27
|
+
// inner func
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
with <path: String, ftype: String = 'psl'>
|
|
31
|
+
inner func save(entity: Any) {
|
|
32
|
+
// inner func
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
with <stream: String = 'stdout'>
|
|
36
|
+
inner shared func print(data: Any) {
|
|
37
|
+
// inner func
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
with <diagram: Functor = eye>
|
|
41
|
+
inner shared func analyze(data: Any) {
|
|
42
|
+
// inner func
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
inner shared func help() {
|
|
46
|
+
// inner func
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
inner shared func version() {
|
|
50
|
+
// inner func
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
inner shared func about() {
|
|
54
|
+
// inner func
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
inner shared func exit() {
|
|
58
|
+
// inner func
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
inner shared func map() {
|
|
62
|
+
// inner func
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
inner shared func reduce() {
|
|
66
|
+
// inner func
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
inner shared func ifexpr(
|
|
70
|
+
condition: Bool,
|
|
71
|
+
trueValue: Any,
|
|
72
|
+
falseValue: Any
|
|
73
|
+
) {
|
|
74
|
+
// return trueValue if condition is true, otherwise return falseValue
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
with <after: Functor>
|
|
78
|
+
inner func exec(block: Functor): Void {
|
|
79
|
+
// execute the following block synchronously
|
|
80
|
+
// if after is specified, run it after execution of block
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
with <after: Functor>
|
|
84
|
+
inner shared func skip(entity: Any): Void {
|
|
85
|
+
// skip an entity in an entity chain
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
let else = skip;
|
|
89
|
+
|
|
90
|
+
shared func if(condition: Bool) {
|
|
91
|
+
return ifexpr(condition, exec, skip<skip>)
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
shared func while(condition: Functor) {
|
|
95
|
+
return test<condition: condition>
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
shared func for(
|
|
99
|
+
capture: Any,
|
|
100
|
+
condition: Functor,
|
|
101
|
+
update: Functor
|
|
102
|
+
) {
|
|
103
|
+
return test<capture, condition, update>
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
with <f: Functor>
|
|
107
|
+
inner func map(entity: Any) {
|
|
108
|
+
// apply f to each element in entity
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
with <f: Functor>
|
|
112
|
+
inner func foreach(entity: Any) {
|
|
113
|
+
// for each element in entity, apply f to it
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
inner func plus(lhs: Any, rhs: Any): Any {
|
|
117
|
+
// return lhs + rhs
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
inner func minus(lhs: Any, rhs: Any): Any {
|
|
121
|
+
// return lhs - rhs
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
inner func leq(lhs: Any, rhs: Any): Bool {
|
|
125
|
+
// return lhs <= rhs
|
|
126
|
+
};
|
camel/__init__.py
ADDED
camel/cli.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
import platform
|
|
4
|
+
import subprocess
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_binary_path():
|
|
10
|
+
system = platform.system().lower()
|
|
11
|
+
bin_name = "camel.exe" if system == "windows" else "camel"
|
|
12
|
+
install_dir = Path(os.path.dirname(__file__)) / ".cmlenv" / "bin"
|
|
13
|
+
return install_dir / bin_name
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Windows 特殊处理
|
|
17
|
+
if platform.system() == "Windows":
|
|
18
|
+
import msvcrt
|
|
19
|
+
import ctypes
|
|
20
|
+
else:
|
|
21
|
+
import termios
|
|
22
|
+
import tty
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TerminalResetter:
|
|
26
|
+
"""跨平台终端状态恢复器"""
|
|
27
|
+
|
|
28
|
+
def __enter__(self):
|
|
29
|
+
# self.original_mode = self._save_terminal()
|
|
30
|
+
return self
|
|
31
|
+
|
|
32
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
33
|
+
# self._restore_terminal(self.original_mode)
|
|
34
|
+
# # Windows 额外清理
|
|
35
|
+
# if platform.system() == "Windows":
|
|
36
|
+
# self._clean_windows_console()
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
def _save_terminal(self) -> Optional[bytes]:
|
|
40
|
+
"""保存终端原始状态"""
|
|
41
|
+
if platform.system() == "Windows":
|
|
42
|
+
# 获取控制台模式
|
|
43
|
+
kernel32 = ctypes.windll.kernel32
|
|
44
|
+
mode = ctypes.c_uint32()
|
|
45
|
+
handle = kernel32.GetStdHandle(-10) # STD_INPUT_HANDLE
|
|
46
|
+
kernel32.GetConsoleMode(handle, ctypes.byref(mode))
|
|
47
|
+
return mode.value
|
|
48
|
+
else:
|
|
49
|
+
# Unix 保存 termios 设置
|
|
50
|
+
return termios.tcgetattr(sys.stdin)
|
|
51
|
+
|
|
52
|
+
def _restore_terminal(self, original: Optional[bytes]):
|
|
53
|
+
"""恢复终端状态"""
|
|
54
|
+
if platform.system() == "Windows" and original is not None:
|
|
55
|
+
kernel32 = ctypes.windll.kernel32
|
|
56
|
+
handle = kernel32.GetStdHandle(-10)
|
|
57
|
+
kernel32.SetConsoleMode(handle, original)
|
|
58
|
+
elif original is not None:
|
|
59
|
+
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, original)
|
|
60
|
+
|
|
61
|
+
def _clean_windows_console(self):
|
|
62
|
+
"""Windows 控制台特殊清理"""
|
|
63
|
+
os.system("cls") # 清屏
|
|
64
|
+
# 重置颜色
|
|
65
|
+
ctypes.windll.kernel32.SetConsoleTextAttribute(
|
|
66
|
+
ctypes.windll.kernel32.GetStdHandle(-11), 7 # 灰色
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def camel():
|
|
71
|
+
with TerminalResetter():
|
|
72
|
+
bin_path = get_binary_path()
|
|
73
|
+
if not bin_path.exists():
|
|
74
|
+
print("Error: Camel binary not found!")
|
|
75
|
+
sys.exit(1)
|
|
76
|
+
|
|
77
|
+
# 启动子进程
|
|
78
|
+
proc = subprocess.Popen(
|
|
79
|
+
[str(bin_path)] + sys.argv[1:],
|
|
80
|
+
stdin=sys.stdin,
|
|
81
|
+
stdout=sys.stdout,
|
|
82
|
+
stderr=sys.stderr,
|
|
83
|
+
# 跨平台信号处理
|
|
84
|
+
creationflags=(
|
|
85
|
+
subprocess.CREATE_NEW_PROCESS_GROUP if platform.system() == "Windows"
|
|
86
|
+
else subprocess.CREATE_NEW_SESSION
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
proc.wait()
|
|
92
|
+
except KeyboardInterrupt:
|
|
93
|
+
if platform.system() == "Windows":
|
|
94
|
+
# Windows 使用特殊信号
|
|
95
|
+
proc.send_signal(subprocess.signal.CTRL_C_EVENT)
|
|
96
|
+
else:
|
|
97
|
+
proc.send_signal(subprocess.signal.SIGINT)
|
|
98
|
+
proc.wait()
|
|
99
|
+
|
|
100
|
+
def cpm():
|
|
101
|
+
print("Hello! Camel Package Manager!")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Wei Zhenjie
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: camel-lang
|
|
3
|
+
Version: 0.0.11
|
|
4
|
+
Summary: Camel: A Next-Generation Language for AI and High-Performance Computing
|
|
5
|
+
Author-email: Zhenjie Wei <kogler_s@outlook.com>
|
|
6
|
+
Maintainer-email: Zhenjie Wei <kogler_s@outlook.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2023 Wei Zhenjie
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://www.opencml.com
|
|
30
|
+
Project-URL: Documentation, https://docs.opencml.com
|
|
31
|
+
Project-URL: Repository, https://github.com/OpenCML/Camel
|
|
32
|
+
Project-URL: Issues, https://github.com/OpenCML/Camel/issues
|
|
33
|
+
Keywords: language,camel,ai,dsl,graph,opencml
|
|
34
|
+
Classifier: Development Status :: 1 - Planning
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
37
|
+
Classifier: Operating System :: MacOS
|
|
38
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
39
|
+
Classifier: Programming Language :: Other
|
|
40
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
41
|
+
Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
|
|
42
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
43
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
camel/__init__.py,sha256=dZBds2LmNfkY5sXurBJU5sED3cvjZ0vEPXkmIAY25Ag,232
|
|
2
|
+
camel/cli.py,sha256=TOAhShwEJup_Lmm9UVHqXQMlZ1ihBaAt9gwGc96HQ3Y,3180
|
|
3
|
+
camel/.cmlenv/bin/camel.exe,sha256=s44zZdggiRTJ15mYQN4EcqEtXB93eW7fFjFrhiAqdrU,1242112
|
|
4
|
+
camel/.cmlenv/lib/std/ctrl.cml,sha256=9NyaW3ogynespKM4qBqmQqE-zyUnbV-agCxfn9u3Dug,680
|
|
5
|
+
camel/.cmlenv/lib/std/std.cml,sha256=7biOiVYfzJpzRsZlnFmnMmr1dmsSLrzu_OHt3LIl0CY,2801
|
|
6
|
+
camel_lang-0.0.11.dist-info/LICENSE,sha256=Cl4b4QErFXO8HJgToDqpkgLvlRo3HsvqHqYNQY5Ksug,1089
|
|
7
|
+
camel_lang-0.0.11.dist-info/METADATA,sha256=GMd53XA8XQNdpaX5JuqpH57mob2-6ymvBZt-n6IOuhU,2390
|
|
8
|
+
camel_lang-0.0.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
camel_lang-0.0.11.dist-info/entry_points.txt,sha256=cPSxC7H6icY3IVmdEPESAdChtLQV9ZH7mty9HwUK4D4,62
|
|
10
|
+
camel_lang-0.0.11.dist-info/top_level.txt,sha256=MVQUVnAwZRgPB-vAFV0O3cppLVp-cKCJX-VAG-o8wJ8,6
|
|
11
|
+
camel_lang-0.0.11.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
camel
|