语言手册
语法
Tao 支持两种语法风格:
// Python 风格 (默认)
def hello() :
println("Tao")
// C 风格 (--braces 兼容)
def hello() {
println("Tao");
}
关键字 (30个)
def let const if elif else for while return
true false nil pass break continue import
struct enum trait impl match extern
try catch finally throw safe unsafe
agent task llm
数据类型
| 类型 | 说明 | 示例 |
|---|---|---|
i32 | 32位整数 | 42 |
f64 | 64位浮点 | 3.14 |
str | 字符串 | "hello" |
(T1,T2) | 元组 | (1, "hi") |
控制流
// 条件
if score >= 90 :
println("A")
elif score >= 60 :
println("B")
else :
println("C")
// 循环
let i = 0
while i < 10 :
println(itoa(i))
i = i + 1
AI 原生
// 基础对话
let r = llm.call("你好")
// 流式响应
let sid = llm_stream_start("写首诗", "{}")
while llm_stream_done(sid) == 0 :
println(llm_stream_read(sid))
sleep(100)
// 工具调用
let result = llm_tool_call("2+3=?", tools_json)