From: Pierre Barbier de Reuille
Date: 2006-01-08T22:48:01+09:00
Subject: Re: [QUIZ] Dice Roller (#61)
Matthew Moss a �crit :
> Wow... You guys are just having too much fun with
> "(5d5-4)d(16/d4)+3", I think. Heck, if y'all know Ruby so well (more
> than me, cause I'm still such a n00b), you'd be able to swap in loaded
> dice for random dice and get your min's and max's. =)
>
> Anyway, I just wanted to add a couple of notes. It was made aware to
> me that the simplified BNF (in the original post) is slightly in
> error, in that it allows expressions like this:
>
> 3dddd6
>
> which is invalid.
>
> A couple possible fixes:
>
> 1. Use the expanded BNF I posted, which doesn't have this fault.
> 2. Implement your dice parser using right-associativity for 'd'
> operators (but maintain left-assoc for the other binary operators).
>
> Feel free to do what you like.
>
>
Well, why do you say it's invalid ? Given the simplified BNF it must be
read as :
3d(d(d(d6)))
and it is perfectly valid as there is no other way to understand that ...
Pierre