diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-25 22:15:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-25 22:15:51 -0700 |
commit | 9542bb112419d575190a72baf7f964c3e32df223 (patch) | |
tree | f9edd69ee91c47d41d50dc1f86ae86dcf10e4428 /html/014literal_noninteger.cc.html | |
parent | 955a66a504aec3f106b415d271403b63d0d0e410 (diff) | |
download | mu-9542bb112419d575190a72baf7f964c3e32df223.tar.gz |
1853
Diffstat (limited to 'html/014literal_noninteger.cc.html')
-rw-r--r-- | html/014literal_noninteger.cc.html | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/html/014literal_noninteger.cc.html b/html/014literal_noninteger.cc.html index f24ed9ac..b2578e88 100644 --- a/html/014literal_noninteger.cc.html +++ b/html/014literal_noninteger.cc.html @@ -13,13 +13,14 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.traceContains { color: #008000; } .cSpecial { color: #008000; } .Constant { color: #00a0a0; } +.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; } .Comment { color: #9090ff; } .Delimiter { color: #a04060; } .Special { color: #ff6060; } .Identifier { color: #804000; } +.traceContains { color: #008000; } --> </style> @@ -42,7 +43,7 @@ recipe main [ <span class="traceContains">+parse: ingredient: {name: "3.14159", properties: ["3.14159": "literal-number"]}</span> <span class="Delimiter">:(after "reagent::reagent(string s)")</span> - if <span class="Delimiter">(</span>is_noninteger<span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> + <span class="Normal">if</span> <span class="Delimiter">(</span>is_noninteger<span class="Delimiter">(</span>s<span class="Delimiter">))</span> <span class="Delimiter">{</span> name = s<span class="Delimiter">;</span> types<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span> properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> vector<string> ><span class="Delimiter">(</span>name<span class="Delimiter">,</span> vector<string><span class="Delimiter">()));</span> @@ -52,15 +53,15 @@ recipe main [ <span class="Delimiter">}</span> <span class="Delimiter">:(code)</span> -bool is_noninteger<span class="Delimiter">(</span>const string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> +<span class="Normal">bool</span> is_noninteger<span class="Delimiter">(</span><span class="Normal">const</span> string& s<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Identifier">return</span> s<span class="Delimiter">.</span>find_first_not_of<span class="Delimiter">(</span><span class="Constant">"0123456789-."</span><span class="Delimiter">)</span> == string::npos && s<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">'.'</span><span class="Delimiter">)</span> != string::npos<span class="Delimiter">;</span> <span class="Delimiter">}</span> -double to_double<span class="Delimiter">(</span>string n<span class="Delimiter">)</span> <span class="Delimiter">{</span> - char* end = <span class="Constant">NULL</span><span class="Delimiter">;</span> +<span class="Normal">double</span> to_double<span class="Delimiter">(</span>string n<span class="Delimiter">)</span> <span class="Delimiter">{</span> + <span class="Normal">char</span>* end = <span class="Constant">NULL</span><span class="Delimiter">;</span> <span class="Comment">// safe because string.c_str() is guaranteed to be null-terminated</span> - double result = strtod<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &end<span class="Delimiter">);</span> + <span class="Normal">double</span> result = strtod<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &end<span class="Delimiter">);</span> assert<span class="Delimiter">(</span>*end == <span class="cSpecial">'\0'</span><span class="Delimiter">);</span> <span class="Identifier">return</span> result<span class="Delimiter">;</span> <span class="Delimiter">}</span> |