////////////////////////////////////////////////////////////////////////// Our complex number micro parser //////////////////////////////////////////////////////////////////////////
| 28 | // |
| 29 | /////////////////////////////////////////////////////////////////////////////// |
| 30 | bool |
| 31 | parse_complex(char const* str, complex<double>& c) |
| 32 | { |
| 33 | double rN = 0.0; |
| 34 | double iN = 0.0; |
| 35 | |
| 36 | subrule<0> first; |
| 37 | subrule<1> r; |
| 38 | subrule<2> i; |
| 39 | |
| 40 | if (parse(str, |
| 41 | |
| 42 | // Begin grammar |
| 43 | ( |
| 44 | first = '(' >> r >> !(',' >> i) >> ')' | r, |
| 45 | r = real_p[assign(rN)], |
| 46 | i = real_p[assign(iN)] |
| 47 | ) |
| 48 | , |
| 49 | // End grammar |
| 50 | |
| 51 | space_p).full) |
| 52 | { |
| 53 | c = complex<double>(rN, iN); |
| 54 | return true; |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | return false; |