块和语句
最后更新于:2022-04-02 04:08:05
[TOC]
## 定义语句块和语句:
```
program -> stmts -> Stmt Stmts | ε
Stmt -> IfStmt | WhileStmt | ForStmt | Function | Block
Block -> {Stmts}
```
整体定义

## 变量定义
```
DeclareStmt -> var Variable = Expr
```

## 变量赋值
```
AssignStmt -> Variable = Expr
```

## 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 | ε
```

## Function 定义
```
Function ->func (Args) Type Block
Args -> Type Variable Args | Type Variable | ε
ReturnType -> Type | ε
Type : int |string |void | bool |string
```
';