about summary refs log tree commit diff stats
path: root/html/014literal_noninteger.cc.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-29 15:55:05 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-29 15:55:05 -0700
commit9570363aec35e187e2395b1760a4b94e71580ac9 (patch)
tree5b0d9cf65b5d5a403ab29e88535ba158efb276fe /html/014literal_noninteger.cc.html
parentb318b7fb127a2bdf3e394b315a45d339dc738447 (diff)
downloadmu-9570363aec35e187e2395b1760a4b94e71580ac9.tar.gz
1885
Diffstat (limited to 'html/014literal_noninteger.cc.html')
-rw-r--r--html/014literal_noninteger.cc.html30
1 files changed, 14 insertions, 16 deletions
diff --git a/html/014literal_noninteger.cc.html b/html/014literal_noninteger.cc.html
index b2578e88..7235bf47 100644
--- a/html/014literal_noninteger.cc.html
+++ b/html/014literal_noninteger.cc.html
@@ -13,14 +13,13 @@
 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>
 
@@ -33,7 +32,6 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; }
 <body>
 <pre id='vimCodeElement'>
 <span class="Comment">//: Support literal non-integers.</span>
-<span class="Comment">//: '3.14159:literal' is ugly, so we'll just say '3.14159' for non-integers.</span>
 
 <span class="Delimiter">:(scenarios load)</span>
 <span class="Delimiter">:(scenario noninteger_literal)</span>
@@ -42,26 +40,26 @@ recipe main [
 ]
 <span class="traceContains">+parse:   ingredient: {name: &quot;3.14159&quot;, properties: [&quot;3.14159&quot;: &quot;literal-number&quot;]}</span>
 
-<span class="Delimiter">:(after &quot;reagent::reagent(string s)&quot;)</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&lt;string<span class="Delimiter">,</span> vector&lt;string&gt; &gt;<span class="Delimiter">(</span>name<span class="Delimiter">,</span> vector&lt;string&gt;<span class="Delimiter">()));</span>
-    properties<span class="Delimiter">.</span>back<span class="Delimiter">().</span>second<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">&quot;literal-number&quot;</span><span class="Delimiter">);</span>
-    set_value<span class="Delimiter">(</span>to_double<span class="Delimiter">(</span>s<span class="Delimiter">));</span>
-    <span class="Identifier">return</span><span class="Delimiter">;</span>
-  <span class="Delimiter">}</span>
+<span class="Delimiter">:(after &quot;Parsing reagent(string s)&quot;)</span>
+if <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&lt;string<span class="Delimiter">,</span> vector&lt;string&gt; &gt;<span class="Delimiter">(</span>name<span class="Delimiter">,</span> vector&lt;string&gt;<span class="Delimiter">()));</span>
+  properties<span class="Delimiter">.</span>back<span class="Delimiter">().</span>second<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span><span class="Constant">&quot;literal-number&quot;</span><span class="Delimiter">);</span>
+  set_value<span class="Delimiter">(</span>to_double<span class="Delimiter">(</span>s<span class="Delimiter">));</span>
+  <span class="Identifier">return</span><span class="Delimiter">;</span>
+<span class="Delimiter">}</span>
 
 <span class="Delimiter">:(code)</span>
-<span class="Normal">bool</span> is_noninteger<span class="Delimiter">(</span><span class="Normal">const</span> string&amp; s<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+bool is_noninteger<span class="Delimiter">(</span>const string&amp; 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">&quot;0123456789-.&quot;</span><span class="Delimiter">)</span> == string::npos
       &amp;&amp; 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>
 
-<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>
+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="Comment">// safe because string.c_str() is guaranteed to be null-terminated</span>
-  <span class="Normal">double</span> result = strtod<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &amp;end<span class="Delimiter">);</span>
+  double result = strtod<span class="Delimiter">(</span>n<span class="Delimiter">.</span>c_str<span class="Delimiter">(),</span> &amp;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>