Skip to content

Commit

Permalink
feat: 向外暴露^st 并补了一点测试
Browse files Browse the repository at this point in the history
  • Loading branch information
fy0 committed Jun 7, 2024
1 parent 912d8a2 commit 774764a
Show file tree
Hide file tree
Showing 4 changed files with 649 additions and 570 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ DiceScript将更好的实现骰点功能,语法规范化的同时,具有更

## 进度

- [x] 基础类型 int float string
- [x] 基础类型 undefined null
- [x] 基础类型 int float string null
- [x] 一元算符 + -
- [x] 二元算符 +-*/% >,>=,==,!=,<,<=,&,|,&&,||
- [x] 三元算符 ? :
Expand All @@ -76,7 +75,7 @@ DiceScript将更好的实现骰点功能,语法规范化的同时,具有更
- [ ] 报错信息优化
- [x] 线程安全
- [x] 变量作用域
- [ ] 测试覆盖率 77% / 90%
- [ ] 测试覆盖率 81% / 90%

## 更新记录

Expand Down
13 changes: 8 additions & 5 deletions roll.peg
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ func toStr(x []byte) string {
}

// 出口
dicescript <- sp stmtRoot sp {
dicescript <- sp stmtSt sp {
c.data.AddOp(typeHalt)
}

stmtSt <- "^st" st_expr
/ stmtRoot

stmtRoot <- stmtLines sp

stmtLines <- &{return !c.data.Config.DisableStmts} stmtWithBlock stmtLines?
Expand Down Expand Up @@ -422,8 +425,8 @@ commentLineRest2 <- (![\r\n] .)* [\r\n]
// st &手枪=(1d6+2)

st_expr <- st_modify_multi_1
/ st_assign_multi
/ st_modify_multi_2
/ st_assign_multi
/ st_modify_multi_2

// est <- eDice / &'(' ? e0
// est <- e0
Expand Down Expand Up @@ -451,7 +454,7 @@ st_modify_multi_1 <- ((st_name2 st_modify_rest1 / st_name2r st_modify_rest1 / st
st_modify_rest1 <- sp (
"+=" sp text:< e0 > {c.data.AddStModify("+", text.(string))} /
"-=" sp text:< e0 > {c.data.AddStModify("-", text.(string))}
)
)

// 第二类,在第一种基础上增加:
// 力量123+1d3
Expand All @@ -466,7 +469,7 @@ st_modify_rest <- sp (
'+' '='? sp text:< e0 > {c.data.AddStModify("+", text.(string))} /
&( '-' ) sp text:< e0 > {c.data.AddStModify("-", text.(string))} /
'-' '='? sp text:< e0 > {c.data.AddStModify("-", text.(string))}
)
)

st_name1 <- text:<( id_ch0+ ":" id_ch0+ )> { c.data.PushStr(text.(string)) } // 结尾不带数字
st_name1r <- text: <( id_ch0+ )> { c.data.PushStr(text.(string)) } // 结尾不带数字
Expand Down
Loading

0 comments on commit 774764a

Please sign in to comment.