Unify bytecode errors with path:line:col, support --stdin-file and live view preset stdin, and ship the S0 standard library with gold coverage. Co-authored-by: Cursor <cursoragent@cursor.com>
3.3 KiB
3.3 KiB
Marqdo 关键字与内置名(v0 最小集)
| 状态 | 已定(前期够用) |
| 日期 | 2026-08-04 |
| 原则 | 英文;参考 Python 但远更少;控制流仍靠 Markdown 标记,不引入 if/while/def |
| 相关 | markdown-mapping.md |
1. 设计原则
- 标记承担架构:函数=
#,分支=+,循环=-,返回=**…**,语句=*…*。因此 不把def/if/else/while/for/return做成关键字。 - 英文标识:内置与字面量用英文,便于工具高亮与国际协作。
- 学 Python 的边界:Python 3 里
print/input是内置函数,不是关键字;布尔与空值是字面量关键字。Marqdo 同样区分 关键字 vs 内置函数名。 - 宁少勿多:前期只列执行金样例所需;要加再进 ADR。
2. 关键字(词法保留,不可作变量名)
| 关键字 | 含义 | 备注 |
|---|---|---|
True |
布尔真 | 对齐 Python 大小写 |
False |
布尔假 | |
None |
空值 | |
and |
逻辑与 | 表达式内 |
or |
逻辑或 | |
not |
逻辑非 |
本期不引入: if else elif while for def class return import pass break continue in is lambda …
(else 分支臂仍用臂头单独的 * 标记,不是单词 else。)
3. 内置函数(可调用名,建议勿遮蔽)
| 名称 | 作用 | 调用示例 |
|---|---|---|
print |
写到 stdout(副作用) | > print text=Hello 或 > print Hello(位置实参,见 call-arguments.md) |
input |
从 stdin 读一行(返回文本) | *name = > input prompt=Name: * |
len |
文本或表的长度 | *n= > lens* 或 > len value=s`` |
str |
转为显示文本 | *t = > str 42* |
int |
转为整数 | *i = > int 7* / > int True / 文本十进制 |
参数约定(v0):
print:具名实参text(必填);日后可扩展end等。input:可选prompt;返回用户输入字符串(不含换行)。len/str/int:形参名均为value(可位置传入)。len:文本按 Unicode 标量计数;表/列表按元素数。str:与print相同的显示规则。int:Int原样;Bool→ 0/1;文本 trim 后按十进制解析,失败则诊断。
旧文档中的中文 print 废弃,统一为 print。
4. 与 Markup 调用的关系
# main
> print text=Hello World!
*`n` = 1*
+ `n` > 0
> print text=positive
+ *
> print text=other
>是调用标记(架构)。print是被调名字(内置库)。- 用户自定义
# print会遮蔽内置(实现应警告)。
5. 标识符规则(摘要)
- 变量:行内
`name`;name不可为上表关键字。 - 函数名:
#标题文本;建议 ASCII/英文,中文标题仍允许但内置名保持英文。 - 比较:
==><>=<=;逻辑:andornot。
6. 后续可增(未批准)
float、type、range;以及 break/continue(若循环需要)。增加前开短 ADR。