Open Bernardo-MG opened 5 years ago
Roll20 makes use of a much more complex DSL:
Wikipedia includes more examples:
More examples of additional rules:
Another parser:
i was going to make an issue about this. for those perusing the thread ill give some examples:
advantage/disadvantage from 5e
roll20: 2d20kh1
for "keep highest 1" or 2d20kl1
for "keep lowest 1"
anydice: [highest 1 of 2d20]
or [lowest 1 of 2d20]
character creation from D&D
roll20: 4d6dl1
for "drop lowest 1"
anydice: [highest 3 of 4d6]
This may be easier, and cleaner, to handle as functions.
Keep lowest: "kl(2d20)" Repeat values of 6: "r(1d6, 6)"
This would require a new node, for the functions.
Ideally there would be a way to map functions into objects, to ease extension and adding new functions.
The rule could be something like:
operation: FUNCNAME LPAREN function RPAREN;
The default rule is named function. This is confusing and should be changed before this.
For example:
These rules are applied to the parsed expression. So they should be applied with transformers.
But maybe they can be activated through special keywords in the grammar, which would require an extension of the basic grammar.