about summary refs log tree commit diff stats
path: root/html/013literal_string.cc.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-06 00:19:03 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-06 00:19:03 -0700
commit672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9 (patch)
tree5fa3d82e40137b15dec2941a3446e838ce43d3e5 /html/013literal_string.cc.html
parent20d1c9057a559ce8db83bbc2787ca91348bcb16f (diff)
downloadmu-672e3e50c6ed6de161e40aa256c3fc0f2b1f7cf9.tar.gz
1279 - colorized rendering of the source files
Diffstat (limited to 'html/013literal_string.cc.html')
-rw-r--r--html/013literal_string.cc.html115
1 files changed, 115 insertions, 0 deletions
diff --git a/html/013literal_string.cc.html b/html/013literal_string.cc.html
new file mode 100644
index 00000000..61f6105b
--- /dev/null
+++ b/html/013literal_string.cc.html
@@ -0,0 +1,115 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<title>~/Desktop/s/mu/013literal_string.cc.html</title>
+<meta name="Generator" content="Vim/7.4">
+<meta name="plugin-version" content="vim7.4_v1">
+<meta name="syntax" content="cpp">
+<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
+<meta name="colorscheme" content="minimal">
+<style type="text/css">
+<!--
+pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background-color: #000000; }
+body { font-family: monospace; color: #d0d0d0; background-color: #000000; }
+* { font-size: 1em; }
+.CommentedCode { color: #6c6c6c; }
+.Constant { color: #008080; }
+.Comment { color: #8080ff; }
+.Delimiter { color: #c000c0; }
+.Special { color: #ff6060; }
+.Identifier { color: #008080; }
+.traceContains { color: #008000; }
+-->
+</style>
+
+<script type='text/javascript'>
+<!--
+
+-->
+</script>
+</head>
+<body>
+<pre id='vimCodeElement'>
+<span class="Comment">//: For convenience, some instructions will take literal arrays of characters (strings).</span>
+<span class="Comment">//:</span>
+<span class="Comment">//: Instead of quotes, we'll use [] to delimit strings. That'll reduce the</span>
+<span class="Comment">//: need for escaping since we can support nested brackets. And we can also</span>
+<span class="Comment">//: imagine that 'recipe' might one day itself be defined in mu, doing its own</span>
+<span class="Comment">//: parsing.</span>
+
+<span class="Delimiter">:(scenarios load)</span>
+<span class="Delimiter">:(scenario string_literal)</span>
+recipe main [
+  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>copy [abc def]  <span class="Comment"># copy can't really take a string</span>
+]
+<span class="traceContains">+parse:   ingredient: {name: &quot;abc def&quot;, value: 0, type: 0, properties: [&quot;abc def&quot;: &quot;literal-string&quot;]}</span>
+
+<span class="Delimiter">:(scenario string_literal_with_colons)</span>
+recipe main [
+  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>copy [abc:def/ghi]
+]
+<span class="traceContains">+parse:   ingredient: {name: &quot;abc:def/ghi&quot;, value: 0, type: 0, properties: [&quot;abc:def/ghi&quot;: &quot;literal-string&quot;]}</span>
+
+<span class="Delimiter">:(before &quot;End Mu Types Initialization&quot;)</span>
+Type_number[<span class="Constant">&quot;literal-string&quot;</span>] = <span class="Constant">0</span><span class="Delimiter">;</span>
+
+<span class="Delimiter">:(after &quot;string next_word(istream&amp; in)&quot;)</span>
+  if <span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'['</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    string result = slurp_quoted<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+    skip_whitespace<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+    skip_comment<span class="Delimiter">(</span>in<span class="Delimiter">);</span>
+    <span class="Identifier">return</span> result<span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+
+<span class="Delimiter">:(code)</span>
+string slurp_quoted<span class="Delimiter">(</span>istream&amp; in<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+  assert<span class="Delimiter">(</span>!in<span class="Delimiter">.</span>eof<span class="Delimiter">());</span>
+  assert<span class="Delimiter">(</span>in<span class="Delimiter">.</span>peek<span class="Delimiter">()</span> == <span class="Constant">'['</span><span class="Delimiter">);</span>
+  ostringstream out<span class="Delimiter">;</span>
+  int size = <span class="Constant">0</span><span class="Delimiter">;</span>
+  while <span class="Delimiter">(</span>!in<span class="Delimiter">.</span>eof<span class="Delimiter">())</span> <span class="Delimiter">{</span>
+    char c = in<span class="Delimiter">.</span>get<span class="Delimiter">();</span>
+<span class="CommentedCode">//?     cout &lt;&lt; c &lt;&lt; '\n'; //? 1</span>
+    out &lt;&lt; c<span class="Delimiter">;</span>
+<span class="CommentedCode">//?     cout &lt;&lt; out.str() &lt;&lt; &quot;$\n&quot;; //? 1</span>
+    if <span class="Delimiter">(</span>c == <span class="Constant">'['</span><span class="Delimiter">)</span> ++size<span class="Delimiter">;</span>
+    if <span class="Delimiter">(</span>c == <span class="Constant">']'</span><span class="Delimiter">)</span> --size<span class="Delimiter">;</span>
+    if <span class="Delimiter">(</span>size == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">break</span><span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+  <span class="Identifier">return</span> out<span class="Delimiter">.</span>str<span class="Delimiter">();</span>
+<span class="Delimiter">}</span>
+
+<span class="Delimiter">:(after &quot;reagent::reagent(string s)&quot;)</span>
+<span class="CommentedCode">//?   cout &lt;&lt; s[0] &lt;&lt; '\n'; //? 1</span>
+  if <span class="Delimiter">(</span>s[<span class="Constant">0</span>] == <span class="Constant">'['</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
+    assert<span class="Delimiter">(</span>s[s<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span>] == <span class="Constant">']'</span><span class="Delimiter">);</span>
+    <span class="Comment">// delete [] delimiters</span>
+    s<span class="Delimiter">.</span>erase<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">);</span>
+    s<span class="Delimiter">.</span>erase<span class="Delimiter">(</span>s<span class="Delimiter">.</span>size<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">,</span> s<span class="Delimiter">.</span>size<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-string&quot;</span><span class="Delimiter">);</span>
+    <span class="Identifier">return</span><span class="Delimiter">;</span>
+  <span class="Delimiter">}</span>
+
+<span class="Delimiter">:(scenario string_literal_nested)</span>
+recipe main [
+  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>copy [abc [def]]
+]
+<span class="traceContains">+parse:   ingredient: {name: &quot;abc [def]&quot;, value: 0, type: 0, properties: [&quot;abc [def]&quot;: &quot;literal-string&quot;]}</span>
+
+<span class="Delimiter">:(scenario string_literal_and_comment)</span>
+recipe main [
+  <span class="Constant">1</span>:address:array:character<span class="Special"> &lt;- </span>copy [abc]  <span class="Comment"># comment</span>
+]
+<span class="traceContains">+parse: instruction: copy</span>
+<span class="traceContains">+parse:   ingredient: {name: &quot;abc&quot;, value: 0, type: 0, properties: [&quot;abc&quot;: &quot;literal-string&quot;]}</span>
+<span class="traceContains">+parse:   product: {name: &quot;1&quot;, value: 0, type: 2-5-4, properties: [&quot;1&quot;: &quot;address&quot;:&quot;array&quot;:&quot;character&quot;]}</span>
+<span class="Comment"># no other ingredients</span>
+$parse: <span class="Constant">3</span>
+</pre>
+</body>
+</html>
+<!-- vim: set foldmethod=manual : -->