MCPcopy Create free account
hub / github.com/boostorg/spirit / parse_complex

Function parse_complex

classic/example/fundamental/complex_number.cpp:30–55  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Our complex number micro parser //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

28//
29///////////////////////////////////////////////////////////////////////////////
30bool
31parse_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;

Callers 1

mainFunction · 0.70

Calls 2

assignFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected