aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/oneroll
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2025-09-13 02:34:14 +0800
committer简律纯 <i@jyunko.cn>2025-09-13 02:34:14 +0800
commit00670619f3a9ac80683f1a1d751349e010c602dc (patch)
tree242ccdbede9b38099ed773ea5ab725ded053843f /src/oneroll
parent93d462c41cf0ed359475f07578bac511a329c580 (diff)
downloadOneRoll-00670619f3a9ac80683f1a1d751349e010c602dc.tar.gz
OneRoll-00670619f3a9ac80683f1a1d751349e010c602dc.zip
feat: introduce new dice modifiers for grouping and merging, enhance variable references and instruction sequences in parser
Diffstat (limited to 'src/oneroll')
-rw-r--r--src/oneroll/grammar.pest14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/oneroll/grammar.pest b/src/oneroll/grammar.pest
index e5ce667..ac017b7 100644
--- a/src/oneroll/grammar.pest
+++ b/src/oneroll/grammar.pest
@@ -29,6 +29,8 @@ modifier = {
| unique
| sort
| count
+ | merge
+ | group
}
explode = { "!" }
explode_alias = { "e" }
@@ -45,5 +47,15 @@ drop_low = { "dl" ~ number }
unique = { "u" }
sort = { "s" }
count = { "c" ~ number }
+merge = { "m" }
+group = { "g" ~ ("s")? ~ number }
+
op = { "+" | "-" | "*" | "/" | "^" }
-main = { SOI ~ dice_expr ~ EOI } \ No newline at end of file
+
+// Instruction sequences and variable references
+var_ref = { "$" ~ number ~ modifiers? }
+
+instruction = { dice_expr | var_ref }
+instruction_list = { instruction ~ (";" ~ instruction)* }
+
+main = { SOI ~ instruction_list ~ EOI } \ No newline at end of file