💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## 定义语句块和语句: ``` program -> stmts -> Stmt Stmts | ε Stmt -> IfStmt | WhileStmt | ForStmt | Function | Block Block -> {Stmts} ``` 整体定义 ![](https://img.kancloud.cn/12/8a/128aa51270cbf8c28f6a43dff5d2e2a6_1964x528.png) ## 变量定义 ``` DeclareStmt -> var Variable = Expr ``` ![](https://img.kancloud.cn/41/ff/41ff532f5cd9525a855092c850b77156_221x400.png) ## 变量赋值 ``` AssignStmt -> Variable = Expr ``` ![](https://img.kancloud.cn/d7/a2/d7a2045d3c7e7be177e9b9b1794c8fa3_261x400.png) ## IfStmt ``` IfStmt -> If(Expr) Block | If(Expr) BLock else Block | If(Expr) Block else IfStmt // 简化:提取公共前缀 IfStmt -> If(Expr) BLock Tail Tail -> else {BLock} | else IfStmt | ε ``` ![](https://img.kancloud.cn/72/76/727669d4d7784418926694012c4b6b6d_800x113.png) ## Function 定义 ``` Function ->func (Args) Type Block Args -> Type Variable Args | Type Variable | ε ReturnType -> Type | ε Type : int |string |void | bool |string ```