10
10
#include < cmath>
11
11
#include < cstdlib>
12
12
#include < cstring>
13
+ #include < ctime>
13
14
#include < deque>
14
15
#include < fstream>
15
16
#include < iomanip>
@@ -57,7 +58,7 @@ class basic_interpreter
57
58
| id_%Var > " (" > r1_%Expr > " )" <[this ]{ return &at (lists_[*id_], *r1_); }
58
59
| id_%Var <[this ]{ return &vars_[*id_]; };
59
60
60
- rule Value = !( " [A-Z][A-Z][A-Z]" _irx > " ( " )
61
+ rule Value = !" [A-Z][A-Z][A-Z]" _irx
61
62
> ( ref_%Ref <[this ]{ return **ref_; }
62
63
| Real | " (" > Expr > " )" )
63
64
| fn_%Fn > " (" > r1_%Expr > " )" <[this ]{ return call (*fn_, *r1_); }
@@ -70,7 +71,7 @@ class basic_interpreter
70
71
| " LOG" _isx > " (" > r1_%Expr > " )" <[this ]{ return std::log (*r1_); }
71
72
| " SQR" _isx > " (" > r1_%Expr > " )" <[this ]{ return std::sqrt (*r1_); }
72
73
| " INT" _isx > " (" > r1_%Expr > " )" <[this ]{ return std::trunc (*r1_); }
73
- | " RND" _isx > " (" > r1_% Expr > " )" <[] { return std::rand () / static_cast <double >(RAND_MAX); };
74
+ | " RND" _isx > ~ ( " (" > ~ Expr > " )" ) <[] { return std::rand () / static_cast <double >(RAND_MAX); };
74
75
75
76
rule Factor = r1_%Value > ~(u8" [↑^]" _rx > r2_%Value <[this ]{ *r1_ = std::pow (*r1_, *r2_); }
76
77
) <[this ]{ return *r1_; };
@@ -408,6 +409,7 @@ class basic_interpreter
408
409
int main (int argc, char ** argv)
409
410
{
410
411
try {
412
+ std::srand (std::time (nullptr ));
411
413
basic_interpreter interpreter;
412
414
while (--argc > 1 )
413
415
interpreter.load (*++argv);
0 commit comments