Esempio n. 1
0
 private void ProcessParentheses(StringScanner scanner, List<Token> output, bool lastTokenWasNumber)
 {
     // If the last token was a number, it's a count of how many times to execute the parenthetic expression.
     // in normal non-random-number math, this is just multiplication, but since we use random numbers,
     // it is implemented as iterative addition, allowing us to re-roll the dice every iteration.
     // If there are no dice defs in the parentheses, then this will yield the same result as normal multiplication.
     string expr = ExtractParentheses (scanner);
     List<Token> multiplier = LookForMultiplier (output, lastTokenWasNumber);
     ParenToken toke = new ParenToken (multiplier, InfixToPostfix (expr, 0, null), this);
     output.Add (toke);
 }
Esempio n. 2
0
 private void ProcessFormula(StringScanner scanner, List<Token> output, bool lastTokenWasNumber)
 {
     Formula f = ExtractFormula (scanner);
     List<Token> multiplier = LookForMultiplier (output, lastTokenWasNumber);
     ParenToken toke = new ParenToken (multiplier, InfixToPostfix (f.Expression, 0, f.Name), this);
     output.Add (toke);
 }