about summary refs log blame commit diff stats
path: root/html/001help.cc.html
blob: d1a53d634a32cc933a006fb98592187472800f98 (plain) (tree)
1
2
3
4
5



                                                                                          
                                        

















































































                                                                                                                                                                                                                                                                                                                 
<!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/001help.cc</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; }
.cSpecial { color: #008000; }
.Constant { color: #008080; }
.Comment { color: #8080ff; }
.Delimiter { color: #c000c0; }
.SalientComment { color: #00ffff; }
.Identifier { color: #008080; }
.PreProc { color: #c000c0; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: Everything this project/binary supports.</span>
<span class="Comment">//: This should give you a sense for what to look forward to in later layers.</span>

<span class="Delimiter">:(before &quot;End Commandline Parsing&quot;)</span>
if <span class="Delimiter">(</span>argc &lt;= <span class="Constant">1</span> || is_equal<span class="Delimiter">(</span>argv[<span class="Constant">1</span>]<span class="Delimiter">,</span> <span class="Constant">&quot;--help&quot;</span><span class="Delimiter">))</span> <span class="Delimiter">{</span>
  <span class="Comment">// this is the functionality later layers will provide</span>
  <span class="Comment">// currently no automated tests for commandline arg parsing</span>
  cerr &lt;&lt; <span class="Constant">&quot;To load files and run 'main':</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;  mu file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;To run all tests:</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;  mu test</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;To load files and then run all tests:</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       &lt;&lt; <span class="Constant">&quot;  mu test file1.mu file2.mu ...</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span>
       <span class="Delimiter">;</span>
  <span class="Identifier">return</span> <span class="Constant">0</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="SalientComment">//:: Helper function used by the above fragment of code (and later layers too,</span>
<span class="SalientComment">//:: who knows?).</span>
<span class="Comment">//: The :(code) directive appends function definitions to the end of the</span>
<span class="Comment">//: project. Regardless of where functions are defined, we can call them</span>
<span class="Comment">//: anywhere we like as long as we format the function header in a specific</span>
<span class="Comment">//: way: put it all on a single line without indent, end the line with ') {'</span>
<span class="Comment">//: and no trailing whitespace. As long as functions uniformly start this</span>
<span class="Comment">//: way, our makefile contains a little command to automatically generate</span>
<span class="Comment">//: declarations for them.</span>
<span class="Delimiter">:(code)</span>
bool is_equal<span class="Delimiter">(</span>char* s<span class="Delimiter">,</span> const char* lit<span class="Delimiter">)</span> <span class="Delimiter">{</span>
  <span class="Identifier">return</span> strncmp<span class="Delimiter">(</span>s<span class="Delimiter">,</span> lit<span class="Delimiter">,</span> strlen<span class="Delimiter">(</span>lit<span class="Delimiter">))</span> == <span class="Constant">0</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Includes&quot;)</span>
<span class="PreProc">#include</span><span class="Constant">&lt;assert.h&gt;</span>

<span class="PreProc">#include</span><span class="Constant">&lt;iostream&gt;</span>
using std::istream<span class="Delimiter">;</span>
using std::ostream<span class="Delimiter">;</span>
using std::iostream<span class="Delimiter">;</span>
using std::cin<span class="Delimiter">;</span>
using std::cout<span class="Delimiter">;</span>
using std::cerr<span class="Delimiter">;</span>

<span class="PreProc">#include</span><span class="Constant">&lt;cstring&gt;</span>
<span class="PreProc">#include</span><span class="Constant">&lt;string&gt;</span>
using std::string<span class="Delimiter">;</span>
typedef size_t index_t<span class="Delimiter">;</span>
const index_t NOT_FOUND = string::npos<span class="Delimiter">;</span>
<span class="Delimiter">:(after &quot;int main(int argc, char* argv[])&quot;)</span>
assert<span class="Delimiter">(</span>sizeof<span class="Delimiter">(</span>string::size_type<span class="Delimiter">)</span> == sizeof<span class="Delimiter">(</span>size_t<span class="Delimiter">));</span>
assert<span class="Delimiter">(</span>sizeof<span class="Delimiter">(</span>index_t<span class="Delimiter">)</span> == sizeof<span class="Delimiter">(</span>size_t<span class="Delimiter">));</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->