Skip to content

Commit b9d2a6b

Browse files
authored
Merge pull request #86 from iewnfod/nightly
Update to Stable
2 parents 9dd035a + e1bf2ff commit b9d2a6b

File tree

17 files changed

+23992
-23315
lines changed

17 files changed

+23992
-23315
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ It runs the entire file if `filepath` is provided, otherwise, it enters playgrou
6969
| `-h` | `--help` | To show the help page |
7070
| `-k` | `--keywords` | To show all the keywords |
7171
| `-m` | `--migrate` | To migrate `.p` files to `.cpc` in a specified directory |
72+
| `-n` | `--notification` | To show notification published by developer (only if this is not expired) |
7273
| `-p` | `--parse` | To show parse information during running |
7374
| `-t` | `--time` | To show the time for the script to run |
7475
| `-u` | `--update` | To update the version |
@@ -108,6 +109,15 @@ It runs the entire file if `filepath` is provided, otherwise, it enters playgrou
108109
- `recursion-limit(rl)`
109110
all integer number as the recursion depth limit of the interpreter.
110111

112+
- `integrity-protection`
113+
114+
- `true`: Enable integrity protection.
115+
- `false`: Disable integrity protection.
116+
117+
> Integrity Protection prevent any accidental or malicious modification of the interpreter.
118+
119+
> This protection will be automatically disabled in developer mode.
120+
111121
- `dev`
112122

113123
- `true`: Enable developer mode.

README_zh.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cpc [file_paths] [options]
5656
| `-h` | `--help` | 显示帮助页面 |
5757
| `-k` | `--keywords` | 显示所有的关键字 |
5858
| `-m` | `--migrate` | 将一个目录中的所有 `.p` 文件切换为 `.cpc` |
59+
| `-n` | `--notification` | 显示由开发者发布的未过期通知 |
5960
| `-p` | `--parse` | 显示所有解析的信息 |
6061
| `-t` | `--time` | 显示运行脚本花费的时间 |
6162
| `-u` | `--update` | 更新此解释器的版本 |
@@ -100,6 +101,15 @@ cpc [file_paths] [options]
100101
- `true`: 启用开发者模式。
101102
- `false`: 关闭开发者模式。
102103

104+
- `integrity-protection`
105+
106+
- `true`: 启用完整性保护。
107+
- `false`: 禁用完整性保护。
108+
109+
> 完整性保护将会阻止任何意外或恶意的解释器修改。
110+
111+
> 此保护将在开发者模式下被自动禁用。
112+
103113
- 开发者选项
104114

105115
- `dev.simulate-update`

main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from src.line_commands import run_command
2323
from src.update import update
2424
from src.update import update_expired
25+
from src.update import integrity_protection
2526

2627
import sys
2728
import os
@@ -193,6 +194,9 @@ def main(input_=None, output_=None, addition_file_name=None):
193194
if addition_file_name:
194195
file_paths.add(addition_file_name)
195196

197+
if not config.get_config('dev') and config.get_config('integrity-protection'):
198+
integrity_protection()
199+
196200
#自动更新
197201
if config.get_config('dev.simulate-update') or (config.get_config('auto-update') and not config.get_config('dev') and update_expired()):
198202
update()

notification/notification.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "deprecate",
3+
"branch": ["stable", "nightly", "dev"],
4+
"expiry_date": "2024-04-05",
5+
"deprecation": {
6+
"keyword": ["Ucase", "Lcase"],
7+
"deprecation_date": "2024-03-29"
8+
}
9+
}

notification/template.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"type": "add|update|deprecate",
3+
"branch": ["stable", "nightly", "dev"],
4+
"expiry_date": "YYYY-MM-DD",
5+
"content": "Update Content",
6+
"deprecation": {
7+
"keyword": ["Deprecated Keyword 1", "Deprecated Keyword 2"],
8+
"deprecation_date": "YYYY-MM-DD"
9+
}
10+
}

parser.out

Lines changed: 23678 additions & 23144 deletions
Large diffs are not rendered by default.

parsetab.py

Lines changed: 146 additions & 141 deletions
Large diffs are not rendered by default.

pkg-script/postupgrade.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ git config --global --add safe.directory /usr/local/sbin/CAIE_Code || exit 1
1414
chown -R $loggedInUser $current_dir || exit 1
1515

1616
# 链接到 bin 目录
17+
mkdir -p /usr/local/bin
1718
ln -sf ${current_dir}/bin/cpc /usr/local/bin/cpc || exit 1
1819

1920
# 链接到 man 目录,如果失败则返回退出代码1

scripts/string.cpc

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,6 @@ FUNCTION Split(s : STRING, sep : STRING) RETURNS ARRAY
2525
RETURN returnArr
2626
ENDFUNCTION
2727

28-
FUNCTION Lcase(s : STRING) RETURNS STRING
29-
DECLARE result : STRING
30-
result <- ""
31-
32-
FOR i <- 1 TO LENGTH(s)
33-
result <- result & LCASE(CHAR(MID(s, i, 1)))
34-
NEXT i
35-
36-
RETURN result
37-
ENDFUNCTION
38-
39-
FUNCTION Ucase(s : STRING) RETURNS STRING
40-
DECLARE result : STRING
41-
result <- ""
42-
43-
FOR i <- 1 TO LENGTH(s)
44-
result <- result & UCASE(CHAR(MID(s, i, 1)))
45-
NEXT i
46-
47-
RETURN result
48-
ENDFUNCTION
49-
5028
FUNCTION TrimStart(s : STRING) RETURNS STRING
5129
DECLARE len : INTEGER
5230
len <- LENGTH(s)

src/AST/calc.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def get_tree(self, level=0):
5959
def exe(self):
6060
n1 = self.left.exe()
6161
n2 = self.right.exe()
62+
if any(i[1] == 'STRING' for i in [n1, n2]):
63+
add_error_message(f'Cannot multiply `{n1[1]}` with `{n2[1]}`', self)
64+
return
6265
try:
6366
v = n1[0] * n2[0]
6467
if int(v) == v:
@@ -108,12 +111,14 @@ def get_tree(self, level=0):
108111
def exe(self):
109112
s1 = self.left.exe()
110113
s2 = self.right.exe()
111-
try:
112-
return (s1[0] + s2[0], 'STRING')
113-
except:
114+
if all(i[1] in ('STRING', 'CHAR') for i in [s1, s2]):
115+
try:
116+
return (s1[0] + s2[0], 'STRING')
117+
except:
118+
add_error_message(f'Cannot connect `{s1[1]}` with `{s2[1]}`', self)
119+
else:
114120
add_error_message(f'Cannot connect `{s1[1]}` with `{s2[1]}`', self)
115121

116-
117122
class Op_mod(AST_Node):
118123
def __init__(self, left, right, *args, **kwargs):
119124
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)