Further work on JSON requirements

This commit is contained in:
Graham Nelson 2022-06-02 00:59:27 +01:00
parent 9cf61b4e21
commit a0710cfef9
24 changed files with 897 additions and 293 deletions

View file

@ -1,6 +1,6 @@
# Inweb 7.1.0
v7.1.0-beta+1B07 'Escape to Danger' (1 June 2022)
v7.1.0-beta+1B08 'Escape to Danger' (2 June 2022)
## About Inweb

View file

@ -1,3 +1,3 @@
Prerelease: beta
Build Date: 1 June 2022
Build Number: 1B07
Build Date: 2 June 2022
Build Number: 1B08

View file

@ -80,7 +80,7 @@ efficiency's sake the caller can set them up with an initial size of her choice.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::new</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::new</span></span>:<br/><a href="2-dct.html#SP7_2">&#167;7.2</a><br/>Command Line Arguments - <a href="3-cla.html#SP5">&#167;5</a><br/>String Manipulation - <a href="4-sm.html#SP27_1">&#167;27.1</a><br/>JSON - <a href="4-jsn.html#SP6">&#167;6</a>, <a href="4-jsn.html#SP19">&#167;19</a><br/>HTML - <a href="5-htm.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">textual</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::new</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::new</span></span>:<br/><a href="2-dct.html#SP7_2">&#167;7.2</a><br/>Command Line Arguments - <a href="3-cla.html#SP5">&#167;5</a><br/>String Manipulation - <a href="4-sm.html#SP27_1">&#167;27.1</a><br/>JSON - <a href="4-jsn.html#SP6">&#167;6</a>, <a href="4-jsn.html#SP20">&#167;20</a>, <a href="4-jsn.html#SP33">&#167;33</a><br/>HTML - <a href="5-htm.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">textual</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">2</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"dictionary too small"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">D</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">textual</span><span class="plain-syntax"> = </span><span class="identifier-syntax">textual</span><span class="plain-syntax">;</span>
@ -132,10 +132,10 @@ so be careful if thread safety's an issue.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::find</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::find</span></span>:<br/><a href="2-dct.html#SP6">&#167;6</a>, <a href="2-dct.html#SP8">&#167;8</a>, <a href="2-dct.html#SP10">&#167;10</a><br/>Command Line Arguments - <a href="3-cla.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP7">&#167;7</a>, <a href="4-jsn.html#SP23">&#167;23</a>, <a href="4-jsn.html#SP28">&#167;28</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::find</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::find</span></span>:<br/><a href="2-dct.html#SP6">&#167;6</a>, <a href="2-dct.html#SP8">&#167;8</a>, <a href="2-dct.html#SP10">&#167;10</a><br/>Command Line Arguments - <a href="3-cla.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP7">&#167;7</a>, <a href="4-jsn.html#SP24">&#167;24</a>, <a href="4-jsn.html#SP29">&#167;29</a>, <a href="4-jsn.html#SP33">&#167;33</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-dct.html#SP7" class="function-link"><span class="function-syntax">Dictionaries::find_p</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::create</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::create</span></span>:<br/><a href="2-dct.html#SP6">&#167;6</a>, <a href="2-dct.html#SP9">&#167;9</a><br/>Command Line Arguments - <a href="3-cla.html#SP5">&#167;5</a><br/>JSON - <a href="4-jsn.html#SP6">&#167;6</a>, <a href="4-jsn.html#SP22">&#167;22</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::create</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::create</span></span>:<br/><a href="2-dct.html#SP6">&#167;6</a>, <a href="2-dct.html#SP9">&#167;9</a><br/>Command Line Arguments - <a href="3-cla.html#SP5">&#167;5</a><br/>JSON - <a href="4-jsn.html#SP6">&#167;6</a>, <a href="4-jsn.html#SP23">&#167;23</a>, <a href="4-jsn.html#SP33">&#167;33</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-dct.html#SP7" class="function-link"><span class="function-syntax">Dictionaries::find_p</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Dictionaries::destroy</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::destroy</span></span>:<br/><a href="2-dct.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
@ -280,7 +280,7 @@ values which are arbitrary pointers, so we have to use void pointers:
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::read_value</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::read_value</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP16">&#167;16</a>, <a href="4-jsn.html#SP26_3">&#167;26.3</a>, <a href="4-jsn.html#SP31">&#167;31</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">key</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="function-syntax">Dictionaries::read_value</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Dictionaries::read_value</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP17">&#167;17</a>, <a href="4-jsn.html#SP27_3">&#167;27.3</a>, <a href="4-jsn.html#SP32">&#167;32</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">key</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">D</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">textual</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"textual dictionary accessed as pointy"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><a href="2-dct.html#SP5" class="function-link"><span class="function-syntax">Dictionaries::find</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">D</span><span class="plain-syntax">, </span><span class="identifier-syntax">key</span><span class="plain-syntax">);</span>

View file

@ -67,6 +67,7 @@ here we are.
<span class="definition-keyword">enum</span> <span class="constant-syntax">HTML_tag_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">JSON_pair_requirement_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">JSON_requirement_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">JSON_single_requirement_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">JSON_value_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">linked_list_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">linked_list_item_CLASS</span>
@ -111,6 +112,7 @@ here we are.
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">HTML_file_state</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">JSON_pair_requirement</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">JSON_requirement</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">JSON_single_requirement</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">JSON_value</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">linked_list</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">method_set</span><span class="plain-syntax">)</span>

View file

@ -193,7 +193,7 @@ of the list, <span class="extract"><span class="extract-syntax">N</span></span>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. A function call API. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">LinkedLists::len</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">LinkedLists::len</span></span>:<br/><a href="2-llas.html#SP11">&#167;11</a><br/>Time - <a href="3-tm.html#SP7">&#167;7</a><br/>JSON - <a href="4-jsn.html#SP25">&#167;25</a><br/>Epub Ebooks - <a href="5-ee.html#SP7_3">&#167;7.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">LinkedLists::len</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">LinkedLists::len</span></span>:<br/><a href="2-llas.html#SP11">&#167;11</a><br/>Time - <a href="3-tm.html#SP7">&#167;7</a><br/>JSON - <a href="4-jsn.html#SP26">&#167;26</a>, <a href="4-jsn.html#SP32">&#167;32</a><br/>Epub Ebooks - <a href="5-ee.html#SP7_3">&#167;7.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">L</span><span class="plain-syntax">?(</span><span class="identifier-syntax">L</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">linked_list_length</span><span class="plain-syntax">):0;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">linked_list_item</span><span class="plain-syntax"> *</span><span class="function-syntax">LinkedLists::first</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">LinkedLists::first</span></span>:<br/><a href="2-llas.html#SP8">&#167;8</a><br/>Version Numbers - <a href="7-vn.html#SP8">&#167;8</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">L</span><span class="plain-syntax">) {</span>

View file

@ -134,7 +134,7 @@ constraints:
<span class="plain-syntax"> </span><span class="constant-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">tree_type</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure tree_type is accessed in 4/prp and here.</li></ul>
<ul class="endnotetexts"><li>The structure tree_type is accessed in 4/prp, 4/jsn and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b></p>
<pre class="displayed-code all-displayed-code code-font">

View file

@ -186,7 +186,7 @@ specify this at three levels of abstraction:
<span class="plain-syntax"> </span><a href="3-em.html#SP6" class="function-link"><span class="function-syntax">Errors::at_position</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Errors::in_text_file_S</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">Errors::in_text_file_S</span></span>:<br/>Preprocessor - <a href="4-prp.html#SP4_1">&#167;4.1</a>, <a href="4-prp.html#SP4_1_2_1">&#167;4.1.2.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP4_1_3_1_2">&#167;4.1.3.1.2</a><br/>Web Structure - <a href="8-ws.html#SP7_3_2">&#167;7.3.2</a>, <a href="8-ws.html#SP7_3_2_1">&#167;7.3.2.1</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">here</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Errors::in_text_file_S</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">Errors::in_text_file_S</span></span>:<br/>Preprocessor - <a href="4-prp.html#SP4_1">&#167;4.1</a>, <a href="4-prp.html#SP4_1_2_1">&#167;4.1.2.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP4_1_3_1_2">&#167;4.1.3.1.2</a><br/>JSON - <a href="4-jsn.html#SP33">&#167;33</a><br/>Web Structure - <a href="8-ws.html#SP7_3_2">&#167;7.3.2</a>, <a href="8-ws.html#SP7_3_2_1">&#167;7.3.2.1</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">here</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">here</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><a href="3-em.html#SP6" class="function-link"><span class="function-syntax">Errors::at_position_S</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="identifier-syntax">here</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">text_file_filename</span><span class="plain-syntax">, </span><span class="identifier-syntax">here</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">line_count</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span>

View file

@ -64,7 +64,7 @@ function togglePopup(material_id) {
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Characters::isalpha</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Characters::isalpha</span></span>:<br/><a href="4-chr.html#SP7">&#167;7</a><br/>Writers and Loggers - <a href="2-wal.html#SP5">&#167;5</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">isalpha</span><span class="plain-syntax">((</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Characters::isdigit</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Characters::isdigit</span></span>:<br/>Writers and Loggers - <a href="2-wal.html#SP5">&#167;5</a><br/>Filenames - <a href="3-fln.html#SP9">&#167;9</a><br/>JSON - <a href="4-jsn.html#SP10">&#167;10</a>, <a href="4-jsn.html#SP14">&#167;14</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a>, <a href="7-vn.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Characters::isdigit</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Characters::isdigit</span></span>:<br/>Writers and Loggers - <a href="2-wal.html#SP5">&#167;5</a><br/>Filenames - <a href="3-fln.html#SP9">&#167;9</a><br/>JSON - <a href="4-jsn.html#SP11">&#167;11</a>, <a href="4-jsn.html#SP15">&#167;15</a>, <a href="4-jsn.html#SP29">&#167;29</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a>, <a href="7-vn.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">isdigit</span><span class="plain-syntax">((</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Characters::isupper</span><span class="plain-syntax">(</span><span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
@ -89,7 +89,7 @@ function togglePopup(material_id) {
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">' '</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'\t'</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Characters::is_whitespace</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Characters::is_whitespace</span></span>:<br/>Preprocessor - <a href="4-prp.html#SP3_1">&#167;3.1</a>, <a href="4-prp.html#SP4_1_3">&#167;4.1.3</a><br/>Pattern Matching - <a href="4-pm.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP10_1">&#167;10.1</a>, <a href="4-jsn.html#SP11">&#167;11</a>, <a href="4-jsn.html#SP12">&#167;12</a>, <a href="4-jsn.html#SP13">&#167;13</a>, <a href="4-jsn.html#SP14">&#167;14</a>, <a href="4-jsn.html#SP28_1">&#167;28.1</a>, <a href="4-jsn.html#SP29">&#167;29</a>, <a href="4-jsn.html#SP30">&#167;30</a><br/>Web Structure - <a href="8-ws.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Characters::is_whitespace</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Characters::is_whitespace</span></span>:<br/>Preprocessor - <a href="4-prp.html#SP3_1">&#167;3.1</a>, <a href="4-prp.html#SP4_1_3">&#167;4.1.3</a><br/>Pattern Matching - <a href="4-pm.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP11_1">&#167;11.1</a>, <a href="4-jsn.html#SP12">&#167;12</a>, <a href="4-jsn.html#SP13">&#167;13</a>, <a href="4-jsn.html#SP14">&#167;14</a>, <a href="4-jsn.html#SP15">&#167;15</a>, <a href="4-jsn.html#SP29_1">&#167;29.1</a>, <a href="4-jsn.html#SP30">&#167;30</a>, <a href="4-jsn.html#SP31">&#167;31</a><br/>Web Structure - <a href="8-ws.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">' '</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'\t'</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'\n'</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

File diff suppressed because it is too large Load diff

View file

@ -195,7 +195,7 @@ are not. They are simply a little faster to access if short.
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">exp_at</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_BRACKETED_SUBEXPRESSIONS</span><span class="plain-syntax">];</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">match_results</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure match_result is private to this section.</li><li>The structure match_results is accessed in 3/cla, 4/prp, 8/ws, 8/wm, 8/bf and here.</li></ul>
<ul class="endnotetexts"><li>The structure match_result is private to this section.</li><li>The structure match_results is accessed in 3/cla, 4/prp, 4/jsn, 8/ws, 8/wm, 8/bf and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>Match result objects are inherently ephemeral, and we can expect to be
creating them and throwing them away frequently. This must be done
explicitly. Note that the storage required is on the C stack (unless some
@ -204,7 +204,7 @@ deallocate.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="function-syntax">Regexp::create_mr</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Regexp::create_mr</span></span>:<br/><a href="4-pm.html#SP14">&#167;14</a><br/>Command Line Arguments - <a href="3-cla.html#SP11">&#167;11</a>, <a href="3-cla.html#SP12">&#167;12</a><br/>Preprocessor - <a href="4-prp.html#SP3_2">&#167;3.2</a>, <a href="4-prp.html#SP4_1">&#167;4.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP17">&#167;17</a><br/>Web Structure - <a href="8-ws.html#SP7_3_2">&#167;7.3.2</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a>, <a href="8-ws.html#SP7_3_3_2_1">&#167;7.3.3.2.1</a>, <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_3">&#167;7.2.2.3</a><br/>Web Modules - <a href="8-wm.html#SP9">&#167;9</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a><br/>Simple Tangler - <a href="8-st.html#SP7_2_3">&#167;7.2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="function-syntax">Regexp::create_mr</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Regexp::create_mr</span></span>:<br/><a href="4-pm.html#SP14">&#167;14</a><br/>Command Line Arguments - <a href="3-cla.html#SP11">&#167;11</a>, <a href="3-cla.html#SP12">&#167;12</a><br/>Preprocessor - <a href="4-prp.html#SP3_2">&#167;3.2</a>, <a href="4-prp.html#SP4_1">&#167;4.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP17">&#167;17</a><br/>JSON - <a href="4-jsn.html#SP33">&#167;33</a><br/>Web Structure - <a href="8-ws.html#SP7_3_2">&#167;7.3.2</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a>, <a href="8-ws.html#SP7_3_3_2_1">&#167;7.3.3.2.1</a>, <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_3">&#167;7.2.2.3</a><br/>Web Modules - <a href="8-wm.html#SP9">&#167;9</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a><br/>Simple Tangler - <a href="8-st.html#SP7_2_3">&#167;7.2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">no_matched_texts</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="constant-syntax">MAX_BRACKETED_SUBEXPRESSIONS</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
@ -229,7 +229,7 @@ deallocate.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Regexp::match</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Regexp::match</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP11">&#167;11</a>, <a href="3-cla.html#SP12">&#167;12</a><br/>Preprocessor - <a href="4-prp.html#SP3_2">&#167;3.2</a>, <a href="4-prp.html#SP4_1">&#167;4.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP17">&#167;17</a><br/>Web Structure - <a href="8-ws.html#SP7_3_2">&#167;7.3.2</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a>, <a href="8-ws.html#SP7_3_3_2_1">&#167;7.3.3.2.1</a>, <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_3">&#167;7.2.2.3</a><br/>Web Modules - <a href="8-wm.html#SP9">&#167;9</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a><br/>Simple Tangler - <a href="8-st.html#SP7_2_3">&#167;7.2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pattern</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Regexp::match</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Regexp::match</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP11">&#167;11</a>, <a href="3-cla.html#SP12">&#167;12</a><br/>Preprocessor - <a href="4-prp.html#SP3_2">&#167;3.2</a>, <a href="4-prp.html#SP4_1">&#167;4.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP17">&#167;17</a><br/>JSON - <a href="4-jsn.html#SP33">&#167;33</a><br/>Web Structure - <a href="8-ws.html#SP7_3_2">&#167;7.3.2</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a>, <a href="8-ws.html#SP7_3_3_2_1">&#167;7.3.3.2.1</a>, <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_3">&#167;7.2.2.3</a><br/>Web Modules - <a href="8-wm.html#SP9">&#167;9</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a><br/>Simple Tangler - <a href="8-st.html#SP7_2_3">&#167;7.2.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">match_results</span><span class="plain-syntax"> *</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pattern</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mr</span><span class="plain-syntax">) </span><a href="4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::prepare</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">rv</span><span class="plain-syntax"> = (</span><a href="4-pm.html#SP11" class="function-link"><span class="function-syntax">Regexp::match_r</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">text</span><span class="plain-syntax">, </span><span class="identifier-syntax">pattern</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">) &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">)?</span><span class="identifier-syntax">TRUE:FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">mr</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">rv</span><span class="plain-syntax"> == </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">)) </span><a href="4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>

View file

@ -88,7 +88,7 @@ access.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">Str::new</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Str::new</span></span>:<br/><a href="4-sm.html#SP3">&#167;3</a><br/>Debugging Log - <a href="2-dl.html#SP4_1">&#167;4.1</a><br/>Dictionaries - <a href="2-dct.html#SP7_3_1">&#167;7.3.1</a><br/>Command Line Arguments - <a href="3-cla.html#SP6">&#167;6</a>, <a href="3-cla.html#SP11">&#167;11</a><br/>Directories - <a href="3-drc.html#SP4">&#167;4</a><br/>Preprocessor - <a href="4-prp.html#SP3_2_1">&#167;3.2.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP4_1_3_1_3">&#167;4.1.3.1.3</a><br/>JSON - <a href="4-jsn.html#SP25">&#167;25</a><br/>HTML - <a href="5-htm.html#SP27_2">&#167;27.2</a><br/>Epub Ebooks - <a href="5-ee.html#SP5">&#167;5</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a><br/>Web Structure - <a href="8-ws.html#SP5_2">&#167;5.2</a>, <a href="8-ws.html#SP6_1">&#167;6.1</a>, <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">Str::new</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Str::new</span></span>:<br/><a href="4-sm.html#SP3">&#167;3</a><br/>Debugging Log - <a href="2-dl.html#SP4_1">&#167;4.1</a><br/>Dictionaries - <a href="2-dct.html#SP7_3_1">&#167;7.3.1</a><br/>Command Line Arguments - <a href="3-cla.html#SP6">&#167;6</a>, <a href="3-cla.html#SP11">&#167;11</a><br/>Directories - <a href="3-drc.html#SP4">&#167;4</a><br/>Preprocessor - <a href="4-prp.html#SP3_2_1">&#167;3.2.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP4_1_3_1_3">&#167;4.1.3.1.3</a><br/>JSON - <a href="4-jsn.html#SP26">&#167;26</a>, <a href="4-jsn.html#SP29">&#167;29</a>, <a href="4-jsn.html#SP33">&#167;33</a><br/>HTML - <a href="5-htm.html#SP27_2">&#167;27.2</a><br/>Epub Ebooks - <a href="5-ee.html#SP5">&#167;5</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a><br/>Web Structure - <a href="8-ws.html#SP5_2">&#167;5.2</a>, <a href="8-ws.html#SP6_1">&#167;6.1</a>, <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-sm.html#SP2" class="function-link"><span class="function-syntax">Str::new_with_capacity</span></a><span class="plain-syntax">(32);</span>
<span class="plain-syntax">}</span>
@ -108,7 +108,7 @@ duplicated as <span class="extract"><span class="extract-syntax">NULL</span></sp
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">Str::duplicate</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Str::duplicate</span></span>:<br/>Dictionaries - <a href="2-dct.html#SP7_3_1">&#167;7.3.1</a><br/>Trees - <a href="2-trs.html#SP7">&#167;7</a>, <a href="2-trs.html#SP9">&#167;9</a><br/>Command Line Arguments - <a href="3-cla.html#SP5_1">&#167;5.1</a><br/>Time - <a href="3-tm.html#SP6">&#167;6</a><br/>Preprocessor - <a href="4-prp.html#SP2">&#167;2</a>, <a href="4-prp.html#SP6">&#167;6</a>, <a href="4-prp.html#SP8">&#167;8</a>, <a href="4-prp.html#SP11_1">&#167;11.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP11_2_1">&#167;11.2.1</a>, <a href="4-prp.html#SP12">&#167;12</a>, <a href="4-prp.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP4">&#167;4</a>, <a href="4-jsn.html#SP6">&#167;6</a>, <a href="4-jsn.html#SP8">&#167;8</a>, <a href="4-jsn.html#SP22">&#167;22</a>, <a href="4-jsn.html#SP24">&#167;24</a><br/>Epub Ebooks - <a href="5-ee.html#SP5">&#167;5</a><br/>Version Numbers - <a href="7-vn.html#SP7_1">&#167;7.1</a><br/>Web Structure - <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_3_1">&#167;7.2.2.3.1</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP7_1">&#167;7.1</a><br/>Web Modules - <a href="8-wm.html#SP2">&#167;2</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">Str::duplicate</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Str::duplicate</span></span>:<br/>Dictionaries - <a href="2-dct.html#SP7_3_1">&#167;7.3.1</a><br/>Trees - <a href="2-trs.html#SP7">&#167;7</a>, <a href="2-trs.html#SP9">&#167;9</a><br/>Command Line Arguments - <a href="3-cla.html#SP5_1">&#167;5.1</a><br/>Time - <a href="3-tm.html#SP6">&#167;6</a><br/>Preprocessor - <a href="4-prp.html#SP2">&#167;2</a>, <a href="4-prp.html#SP6">&#167;6</a>, <a href="4-prp.html#SP8">&#167;8</a>, <a href="4-prp.html#SP11_1">&#167;11.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP11_2_1">&#167;11.2.1</a>, <a href="4-prp.html#SP12">&#167;12</a>, <a href="4-prp.html#SP13">&#167;13</a><br/>JSON - <a href="4-jsn.html#SP4">&#167;4</a>, <a href="4-jsn.html#SP6">&#167;6</a>, <a href="4-jsn.html#SP8">&#167;8</a>, <a href="4-jsn.html#SP23">&#167;23</a>, <a href="4-jsn.html#SP25">&#167;25</a><br/>Epub Ebooks - <a href="5-ee.html#SP5">&#167;5</a><br/>Version Numbers - <a href="7-vn.html#SP7_1">&#167;7.1</a><br/>Web Structure - <a href="8-ws.html#SP7_2_1">&#167;7.2.1</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_3_1">&#167;7.2.2.3.1</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP7_1">&#167;7.1</a><br/>Web Modules - <a href="8-wm.html#SP2">&#167;2</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="4-sm.html#SP2" class="function-link"><span class="function-syntax">Str::new</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-str.html#SP26" class="function-link"><span class="function-syntax">Streams::open_to_memory</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><a href="4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">)+4)) {</span>
@ -184,7 +184,7 @@ thing plus a little extra, for efficiency's sake.
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Converting to integers. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::atoi</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Str::atoi</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP12">&#167;12</a><br/>JSON - <a href="4-jsn.html#SP14">&#167;14</a><br/>HTML - <a href="5-htm.html#SP27_2">&#167;27.2</a><br/>Version Numbers - <a href="7-vn.html#SP10">&#167;10</a><br/>Web Structure - <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::atoi</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Str::atoi</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP12">&#167;12</a><br/>JSON - <a href="4-jsn.html#SP15">&#167;15</a><br/>HTML - <a href="5-htm.html#SP27_2">&#167;27.2</a><br/>Version Numbers - <a href="7-vn.html#SP10">&#167;10</a><br/>Web Structure - <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">char</span><span class="plain-syntax"> </span><span class="identifier-syntax">buffer</span><span class="plain-syntax">[32];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string_position</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="4-sm.html#SP10" class="function-link"><span class="function-syntax">Str::at</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">index</span><span class="plain-syntax">);</span>
@ -198,7 +198,7 @@ thing plus a little extra, for efficiency's sake.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::len</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Str::len</span></span>:<br/><a href="4-sm.html#SP3">&#167;3</a>, <a href="4-sm.html#SP7">&#167;7</a>, <a href="4-sm.html#SP10">&#167;10</a>, <a href="4-sm.html#SP11">&#167;11</a>, <a href="4-sm.html#SP12">&#167;12</a>, <a href="4-sm.html#SP13">&#167;13</a>, <a href="4-sm.html#SP14">&#167;14</a>, <a href="4-sm.html#SP15">&#167;15</a>, <a href="4-sm.html#SP17">&#167;17</a>, <a href="4-sm.html#SP19">&#167;19</a>, <a href="4-sm.html#SP20">&#167;20</a>, <a href="4-sm.html#SP21">&#167;21</a>, <a href="4-sm.html#SP22">&#167;22</a>, <a href="4-sm.html#SP24">&#167;24</a>, <a href="4-sm.html#SP25">&#167;25</a>, <a href="4-sm.html#SP26">&#167;26</a><br/>Debugging Log - <a href="2-dl.html#SP9">&#167;9</a><br/>Command Line Arguments - <a href="3-cla.html#SP13">&#167;13</a>, <a href="3-cla.html#SP14">&#167;14</a>, <a href="3-cla.html#SP14_1">&#167;14.1</a><br/>Pathnames - <a href="3-pth.html#SP4">&#167;4</a>, <a href="3-pth.html#SP5">&#167;5</a>, <a href="3-pth.html#SP7">&#167;7</a>, <a href="3-pth.html#SP8">&#167;8</a><br/>Filenames - <a href="3-fln.html#SP2">&#167;2</a>, <a href="3-fln.html#SP3">&#167;3</a>, <a href="3-fln.html#SP5">&#167;5</a>, <a href="3-fln.html#SP8">&#167;8</a>, <a href="3-fln.html#SP9">&#167;9</a><br/>Preprocessor - <a href="4-prp.html#SP3_3">&#167;3.3</a>, <a href="4-prp.html#SP4">&#167;4</a>, <a href="4-prp.html#SP4_1_1">&#167;4.1.1</a><br/>Tries and Avinues - <a href="4-taa.html#SP2_1">&#167;2.1</a><br/>Pattern Matching - <a href="4-pm.html#SP3">&#167;3</a>, <a href="4-pm.html#SP4">&#167;4</a>, <a href="4-pm.html#SP10">&#167;10</a>, <a href="4-pm.html#SP11_3">&#167;11.3</a>, <a href="4-pm.html#SP14">&#167;14</a><br/>JSON - <a href="4-jsn.html#SP9">&#167;9</a>, <a href="4-jsn.html#SP25">&#167;25</a>, <a href="4-jsn.html#SP27">&#167;27</a><br/>HTML - <a href="5-htm.html#SP8">&#167;8</a>, <a href="5-htm.html#SP17">&#167;17</a><br/>Epub Ebooks - <a href="5-ee.html#SP7_1">&#167;7.1</a>, <a href="5-ee.html#SP7_2_3">&#167;7.2.3</a>, <a href="5-ee.html#SP7_2_4">&#167;7.2.4</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a>, <a href="7-vn.html#SP7_1">&#167;7.1</a>, <a href="7-vn.html#SP10">&#167;10</a><br/>Web Structure - <a href="8-ws.html#SP5_4">&#167;5.4</a>, <a href="8-ws.html#SP5_4_1">&#167;5.4.1</a>, <a href="8-ws.html#SP5_4_1_1">&#167;5.4.1.1</a>, <a href="8-ws.html#SP5_4_1_2">&#167;5.4.1.2</a>, <a href="8-ws.html#SP7_3">&#167;7.3</a>, <a href="8-ws.html#SP7_3_3_1">&#167;7.3.3.1</a>, <a href="8-ws.html#SP7_2_2_3_1">&#167;7.2.2.3.1</a>, <a href="8-ws.html#SP7_2_2_4">&#167;7.2.2.4</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP5">&#167;5</a>, <a href="8-bdfw.html#SP6">&#167;6</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a>, <a href="8-bf.html#SP4">&#167;4</a>, <a href="8-bf.html#SP5">&#167;5</a>, <a href="8-bf.html#SP6">&#167;6</a>, <a href="8-bf.html#SP9">&#167;9</a><br/>Simple Tangler - <a href="8-st.html#SP7">&#167;7</a>, <a href="8-st.html#SP7_1">&#167;7.1</a>, <a href="8-st.html#SP7_2_4">&#167;7.2.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::len</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Str::len</span></span>:<br/><a href="4-sm.html#SP3">&#167;3</a>, <a href="4-sm.html#SP7">&#167;7</a>, <a href="4-sm.html#SP10">&#167;10</a>, <a href="4-sm.html#SP11">&#167;11</a>, <a href="4-sm.html#SP12">&#167;12</a>, <a href="4-sm.html#SP13">&#167;13</a>, <a href="4-sm.html#SP14">&#167;14</a>, <a href="4-sm.html#SP15">&#167;15</a>, <a href="4-sm.html#SP17">&#167;17</a>, <a href="4-sm.html#SP19">&#167;19</a>, <a href="4-sm.html#SP20">&#167;20</a>, <a href="4-sm.html#SP21">&#167;21</a>, <a href="4-sm.html#SP22">&#167;22</a>, <a href="4-sm.html#SP24">&#167;24</a>, <a href="4-sm.html#SP25">&#167;25</a>, <a href="4-sm.html#SP26">&#167;26</a><br/>Debugging Log - <a href="2-dl.html#SP9">&#167;9</a><br/>Command Line Arguments - <a href="3-cla.html#SP13">&#167;13</a>, <a href="3-cla.html#SP14">&#167;14</a>, <a href="3-cla.html#SP14_1">&#167;14.1</a><br/>Pathnames - <a href="3-pth.html#SP4">&#167;4</a>, <a href="3-pth.html#SP5">&#167;5</a>, <a href="3-pth.html#SP7">&#167;7</a>, <a href="3-pth.html#SP8">&#167;8</a><br/>Filenames - <a href="3-fln.html#SP2">&#167;2</a>, <a href="3-fln.html#SP3">&#167;3</a>, <a href="3-fln.html#SP5">&#167;5</a>, <a href="3-fln.html#SP8">&#167;8</a>, <a href="3-fln.html#SP9">&#167;9</a><br/>Preprocessor - <a href="4-prp.html#SP3_3">&#167;3.3</a>, <a href="4-prp.html#SP4">&#167;4</a>, <a href="4-prp.html#SP4_1_1">&#167;4.1.1</a><br/>Tries and Avinues - <a href="4-taa.html#SP2_1">&#167;2.1</a><br/>Pattern Matching - <a href="4-pm.html#SP3">&#167;3</a>, <a href="4-pm.html#SP4">&#167;4</a>, <a href="4-pm.html#SP10">&#167;10</a>, <a href="4-pm.html#SP11_3">&#167;11.3</a>, <a href="4-pm.html#SP14">&#167;14</a><br/>JSON - <a href="4-jsn.html#SP10">&#167;10</a>, <a href="4-jsn.html#SP26">&#167;26</a>, <a href="4-jsn.html#SP28">&#167;28</a>, <a href="4-jsn.html#SP33">&#167;33</a><br/>HTML - <a href="5-htm.html#SP8">&#167;8</a>, <a href="5-htm.html#SP17">&#167;17</a><br/>Epub Ebooks - <a href="5-ee.html#SP7_1">&#167;7.1</a>, <a href="5-ee.html#SP7_2_3">&#167;7.2.3</a>, <a href="5-ee.html#SP7_2_4">&#167;7.2.4</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a>, <a href="7-vn.html#SP7_1">&#167;7.1</a>, <a href="7-vn.html#SP10">&#167;10</a><br/>Web Structure - <a href="8-ws.html#SP5_4">&#167;5.4</a>, <a href="8-ws.html#SP5_4_1">&#167;5.4.1</a>, <a href="8-ws.html#SP5_4_1_1">&#167;5.4.1.1</a>, <a href="8-ws.html#SP5_4_1_2">&#167;5.4.1.2</a>, <a href="8-ws.html#SP7_3">&#167;7.3</a>, <a href="8-ws.html#SP7_3_3_1">&#167;7.3.3.1</a>, <a href="8-ws.html#SP7_2_2_3_1">&#167;7.2.2.3.1</a>, <a href="8-ws.html#SP7_2_2_4">&#167;7.2.2.4</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP5">&#167;5</a>, <a href="8-bdfw.html#SP6">&#167;6</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a>, <a href="8-bf.html#SP4">&#167;4</a>, <a href="8-bf.html#SP5">&#167;5</a>, <a href="8-bf.html#SP6">&#167;6</a>, <a href="8-bf.html#SP9">&#167;9</a><br/>Simple Tangler - <a href="8-st.html#SP7">&#167;7</a>, <a href="8-st.html#SP7_1">&#167;7.1</a>, <a href="8-st.html#SP7_2_4">&#167;7.2.4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-str.html#SP38" class="function-link"><span class="function-syntax">Streams::get_position</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
@ -277,12 +277,12 @@ at those positions may well not be, of course.)
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="function-syntax">Str::get</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">Str::get</span></span>:<br/><a href="4-sm.html#SP7">&#167;7</a>, <a href="4-sm.html#SP17">&#167;17</a>, <a href="4-sm.html#SP20">&#167;20</a>, <a href="4-sm.html#SP22">&#167;22</a>, <a href="4-sm.html#SP23">&#167;23</a>, <a href="4-sm.html#SP24">&#167;24</a>, <a href="4-sm.html#SP25">&#167;25</a>, <a href="4-sm.html#SP26">&#167;26</a><br/>Dictionaries - <a href="2-dct.html#SP4">&#167;4</a><br/>Pathnames - <a href="3-pth.html#SP4">&#167;4</a>, <a href="3-pth.html#SP5">&#167;5</a><br/>Filenames - <a href="3-fln.html#SP2">&#167;2</a>, <a href="3-fln.html#SP3">&#167;3</a>, <a href="3-fln.html#SP7">&#167;7</a>, <a href="3-fln.html#SP8">&#167;8</a>, <a href="3-fln.html#SP9">&#167;9</a><br/>Shell - <a href="3-shl.html#SP1">&#167;1</a><br/>Preprocessor - <a href="4-prp.html#SP3_1">&#167;3.1</a>, <a href="4-prp.html#SP5">&#167;5</a>, <a href="4-prp.html#SP18_1">&#167;18.1</a><br/>Pattern Matching - <a href="4-pm.html#SP5">&#167;5</a><br/>JSON - <a href="4-jsn.html#SP17">&#167;17</a><br/>HTML - <a href="5-htm.html#SP26">&#167;26</a><br/>Epub Ebooks - <a href="5-ee.html#SP5">&#167;5</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a>, <a href="7-vn.html#SP10">&#167;10</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP7_2">&#167;7.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">string_position</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="function-syntax">Str::get</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">Str::get</span></span>:<br/><a href="4-sm.html#SP7">&#167;7</a>, <a href="4-sm.html#SP17">&#167;17</a>, <a href="4-sm.html#SP20">&#167;20</a>, <a href="4-sm.html#SP22">&#167;22</a>, <a href="4-sm.html#SP23">&#167;23</a>, <a href="4-sm.html#SP24">&#167;24</a>, <a href="4-sm.html#SP25">&#167;25</a>, <a href="4-sm.html#SP26">&#167;26</a><br/>Dictionaries - <a href="2-dct.html#SP4">&#167;4</a><br/>Pathnames - <a href="3-pth.html#SP4">&#167;4</a>, <a href="3-pth.html#SP5">&#167;5</a><br/>Filenames - <a href="3-fln.html#SP2">&#167;2</a>, <a href="3-fln.html#SP3">&#167;3</a>, <a href="3-fln.html#SP7">&#167;7</a>, <a href="3-fln.html#SP8">&#167;8</a>, <a href="3-fln.html#SP9">&#167;9</a><br/>Shell - <a href="3-shl.html#SP1">&#167;1</a><br/>Preprocessor - <a href="4-prp.html#SP3_1">&#167;3.1</a>, <a href="4-prp.html#SP5">&#167;5</a>, <a href="4-prp.html#SP18_1">&#167;18.1</a><br/>Pattern Matching - <a href="4-pm.html#SP5">&#167;5</a><br/>JSON - <a href="4-jsn.html#SP18">&#167;18</a><br/>HTML - <a href="5-htm.html#SP26">&#167;26</a><br/>Epub Ebooks - <a href="5-ee.html#SP5">&#167;5</a><br/>Version Numbers - <a href="7-vn.html#SP7">&#167;7</a>, <a href="7-vn.html#SP10">&#167;10</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP7_2">&#167;7.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">string_position</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="identifier-syntax">S</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">index</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-str.html#SP40" class="function-link"><span class="function-syntax">Streams::get_char_at_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">P</span><span class="plain-syntax">.</span><span class="element-syntax">index</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
<span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="function-syntax">Str::get_at</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">Str::get_at</span></span>:<br/><a href="4-sm.html#SP20">&#167;20</a>, <a href="4-sm.html#SP21">&#167;21</a>, <a href="4-sm.html#SP24">&#167;24</a>, <a href="4-sm.html#SP26">&#167;26</a><br/>Pathnames - <a href="3-pth.html#SP7">&#167;7</a><br/>Filenames - <a href="3-fln.html#SP5">&#167;5</a><br/>Preprocessor - <a href="4-prp.html#SP4">&#167;4</a><br/>Tries and Avinues - <a href="4-taa.html#SP2">&#167;2</a><br/>Pattern Matching - <a href="4-pm.html#SP3">&#167;3</a>, <a href="4-pm.html#SP4">&#167;4</a>, <a href="4-pm.html#SP11">&#167;11</a>, <a href="4-pm.html#SP11_4">&#167;11.4</a>, <a href="4-pm.html#SP11_6">&#167;11.6</a>, <a href="4-pm.html#SP14">&#167;14</a>, <a href="4-pm.html#SP14_1">&#167;14.1</a><br/>JSON - <a href="4-jsn.html#SP10_1">&#167;10.1</a>, <a href="4-jsn.html#SP11">&#167;11</a>, <a href="4-jsn.html#SP12">&#167;12</a>, <a href="4-jsn.html#SP13">&#167;13</a>, <a href="4-jsn.html#SP14">&#167;14</a>, <a href="4-jsn.html#SP15">&#167;15</a>, <a href="4-jsn.html#SP15_1">&#167;15.1</a>, <a href="4-jsn.html#SP28">&#167;28</a>, <a href="4-jsn.html#SP28_1">&#167;28.1</a>, <a href="4-jsn.html#SP29">&#167;29</a>, <a href="4-jsn.html#SP30">&#167;30</a><br/>Web Structure - <a href="8-ws.html#SP5_4_1_1">&#167;5.4.1.1</a>, <a href="8-ws.html#SP7">&#167;7</a><br/>Build Files - <a href="8-bf.html#SP9">&#167;9</a><br/>Simple Tangler - <a href="8-st.html#SP7_2_1">&#167;7.2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax">) {</span>
<span class="identifier-syntax">wchar_t</span><span class="plain-syntax"> </span><span class="function-syntax">Str::get_at</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">Str::get_at</span></span>:<br/><a href="4-sm.html#SP20">&#167;20</a>, <a href="4-sm.html#SP21">&#167;21</a>, <a href="4-sm.html#SP24">&#167;24</a>, <a href="4-sm.html#SP26">&#167;26</a><br/>Pathnames - <a href="3-pth.html#SP7">&#167;7</a><br/>Filenames - <a href="3-fln.html#SP5">&#167;5</a><br/>Preprocessor - <a href="4-prp.html#SP4">&#167;4</a><br/>Tries and Avinues - <a href="4-taa.html#SP2">&#167;2</a><br/>Pattern Matching - <a href="4-pm.html#SP3">&#167;3</a>, <a href="4-pm.html#SP4">&#167;4</a>, <a href="4-pm.html#SP11">&#167;11</a>, <a href="4-pm.html#SP11_4">&#167;11.4</a>, <a href="4-pm.html#SP11_6">&#167;11.6</a>, <a href="4-pm.html#SP14">&#167;14</a>, <a href="4-pm.html#SP14_1">&#167;14.1</a><br/>JSON - <a href="4-jsn.html#SP10">&#167;10</a>, <a href="4-jsn.html#SP11_1">&#167;11.1</a>, <a href="4-jsn.html#SP12">&#167;12</a>, <a href="4-jsn.html#SP13">&#167;13</a>, <a href="4-jsn.html#SP14">&#167;14</a>, <a href="4-jsn.html#SP15">&#167;15</a>, <a href="4-jsn.html#SP16">&#167;16</a>, <a href="4-jsn.html#SP16_1">&#167;16.1</a>, <a href="4-jsn.html#SP29">&#167;29</a>, <a href="4-jsn.html#SP29_1">&#167;29.1</a>, <a href="4-jsn.html#SP30">&#167;30</a>, <a href="4-jsn.html#SP31">&#167;31</a><br/>Web Structure - <a href="8-ws.html#SP5_4_1_1">&#167;5.4.1.1</a>, <a href="8-ws.html#SP7">&#167;7</a><br/>Build Files - <a href="8-bf.html#SP9">&#167;9</a><br/>Simple Tangler - <a href="8-st.html#SP7_2_1">&#167;7.2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">S</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">index</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-str.html#SP40" class="function-link"><span class="function-syntax">Streams::get_char_at_index</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">index</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
@ -319,7 +319,7 @@ at those positions may well not be, of course.)
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. Truncation. </b></p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Str::clear</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">Str::clear</span></span>:<br/><a href="4-sm.html#SP16">&#167;16</a>, <a href="4-sm.html#SP17">&#167;17</a>, <a href="4-sm.html#SP18">&#167;18</a>, <a href="4-sm.html#SP25">&#167;25</a><br/>Directories - <a href="3-drc.html#SP2">&#167;2</a><br/>Text Files - <a href="4-tf.html#SP6">&#167;6</a><br/>Preprocessor - <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP13">&#167;13</a>, <a href="4-prp.html#SP17">&#167;17</a>, <a href="4-prp.html#SP18_1">&#167;18.1</a><br/>Pattern Matching - <a href="4-pm.html#SP11_6">&#167;11.6</a><br/>HTML - <a href="5-htm.html#SP27_2">&#167;27.2</a><br/>Version Numbers - <a href="7-vn.html#SP7_1">&#167;7.1</a><br/>Web Structure - <a href="8-ws.html#SP5_4_1">&#167;5.4.1</a>, <a href="8-ws.html#SP5_4_1_2">&#167;5.4.1.2</a>, <a href="8-ws.html#SP7_3_2_1">&#167;7.3.2.1</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_4">&#167;7.2.2.4</a><br/>Build Files - <a href="8-bf.html#SP8">&#167;8</a>, <a href="8-bf.html#SP9">&#167;9</a><br/>Simple Tangler - <a href="8-st.html#SP7_2">&#167;7.2</a>, <a href="8-st.html#SP7_2_5_1">&#167;7.2.5.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Str::clear</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">Str::clear</span></span>:<br/><a href="4-sm.html#SP16">&#167;16</a>, <a href="4-sm.html#SP17">&#167;17</a>, <a href="4-sm.html#SP18">&#167;18</a>, <a href="4-sm.html#SP25">&#167;25</a><br/>Directories - <a href="3-drc.html#SP2">&#167;2</a><br/>Text Files - <a href="4-tf.html#SP6">&#167;6</a><br/>Preprocessor - <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP11_2">&#167;11.2</a>, <a href="4-prp.html#SP13">&#167;13</a>, <a href="4-prp.html#SP17">&#167;17</a>, <a href="4-prp.html#SP18_1">&#167;18.1</a><br/>Pattern Matching - <a href="4-pm.html#SP11_6">&#167;11.6</a><br/>JSON - <a href="4-jsn.html#SP33">&#167;33</a><br/>HTML - <a href="5-htm.html#SP27_2">&#167;27.2</a><br/>Version Numbers - <a href="7-vn.html#SP7_1">&#167;7.1</a><br/>Web Structure - <a href="8-ws.html#SP5_4_1">&#167;5.4.1</a>, <a href="8-ws.html#SP5_4_1_2">&#167;5.4.1.2</a>, <a href="8-ws.html#SP7_3_2_1">&#167;7.3.2.1</a>, <a href="8-ws.html#SP7_3_3_2">&#167;7.3.3.2</a>, <a href="8-ws.html#SP7_2_2_1">&#167;7.2.2.1</a>, <a href="8-ws.html#SP7_2_2_4">&#167;7.2.2.4</a><br/>Build Files - <a href="8-bf.html#SP8">&#167;8</a>, <a href="8-bf.html#SP9">&#167;9</a><br/>Simple Tangler - <a href="8-st.html#SP7_2">&#167;7.2</a>, <a href="8-st.html#SP7_2_5_1">&#167;7.2.5.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><a href="4-sm.html#SP15" class="function-link"><span class="function-syntax">Str::truncate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
@ -411,7 +411,7 @@ at those positions may well not be, of course.)
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::eq</span><button class="popup" onclick="togglePopup('usagePopup25')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup25">Usage of <span class="code-font"><span class="function-syntax">Str::eq</span></span>:<br/>Debugging Log - <a href="2-dl.html#SP9">&#167;9</a><br/>Dictionaries - <a href="2-dct.html#SP7_3">&#167;7.3</a><br/>Pathnames - <a href="3-pth.html#SP3">&#167;3</a>, <a href="3-pth.html#SP7">&#167;7</a>, <a href="3-pth.html#SP8">&#167;8</a><br/>Filenames - <a href="3-fln.html#SP11">&#167;11</a><br/>Preprocessor - <a href="4-prp.html#SP4_1_1">&#167;4.1.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP7">&#167;7</a>, <a href="4-prp.html#SP14">&#167;14</a><br/>Web Structure - <a href="8-ws.html#SP5_4">&#167;5.4</a>, <a href="8-ws.html#SP5_4_1_2">&#167;5.4.1.2</a>, <a href="8-ws.html#SP7_1">&#167;7.1</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S1</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S2</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::eq</span><button class="popup" onclick="togglePopup('usagePopup25')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup25">Usage of <span class="code-font"><span class="function-syntax">Str::eq</span></span>:<br/>Debugging Log - <a href="2-dl.html#SP9">&#167;9</a><br/>Dictionaries - <a href="2-dct.html#SP7_3">&#167;7.3</a><br/>Pathnames - <a href="3-pth.html#SP3">&#167;3</a>, <a href="3-pth.html#SP7">&#167;7</a>, <a href="3-pth.html#SP8">&#167;8</a><br/>Filenames - <a href="3-fln.html#SP11">&#167;11</a><br/>Preprocessor - <a href="4-prp.html#SP4_1_1">&#167;4.1.1</a>, <a href="4-prp.html#SP4_1_3_1_1">&#167;4.1.3.1.1</a>, <a href="4-prp.html#SP7">&#167;7</a>, <a href="4-prp.html#SP14">&#167;14</a><br/>JSON - <a href="4-jsn.html#SP9">&#167;9</a><br/>Web Structure - <a href="8-ws.html#SP5_4">&#167;5.4</a>, <a href="8-ws.html#SP5_4_1_2">&#167;5.4.1.2</a>, <a href="8-ws.html#SP7_1">&#167;7.1</a><br/>Bibliographic Data for Webs - <a href="8-bdfw.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S1</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-sm.html#SP20" class="function-link"><span class="function-syntax">Str::cmp</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S1</span><span class="plain-syntax">, </span><span class="identifier-syntax">S2</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
@ -694,7 +694,7 @@ for the staff of a publishing house.)
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::includes_at</span><button class="popup" onclick="togglePopup('usagePopup40')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup40">Usage of <span class="code-font"><span class="function-syntax">Str::includes_at</span></span>:<br/>JSON - <a href="4-jsn.html#SP10">&#167;10</a>, <a href="4-jsn.html#SP28">&#167;28</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pattern</span><span class="plain-syntax">) {</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Str::includes_at</span><button class="popup" onclick="togglePopup('usagePopup40')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup40">Usage of <span class="code-font"><span class="function-syntax">Str::includes_at</span></span>:<br/>JSON - <a href="4-jsn.html#SP11">&#167;11</a>, <a href="4-jsn.html#SP29">&#167;29</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">line</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">pattern</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pattern</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><a href="4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">pattern</span><span class="plain-syntax">) &gt; </span><a href="4-sm.html#SP8" class="function-link"><span class="function-syntax">Str::len</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">line</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">FALSE</span><span class="plain-syntax">;</span>

View file

@ -97,7 +97,7 @@ does essentially that.
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">actively_scanning</span><span class="plain-syntax">; </span><span class="comment-syntax"> whether we are still interested in the rest of the file</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure text_file_position is accessed in 3/em, 3/cla, 8/ws and here.</li></ul>
<ul class="endnotetexts"><li>The structure text_file_position is accessed in 3/em, 3/cla, 4/jsn, 8/ws and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>For access:
</p>
@ -135,7 +135,7 @@ client.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">TextFiles::read</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">TextFiles::read</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP11">&#167;11</a><br/>Preprocessor - <a href="4-prp.html#SP1">&#167;1</a><br/>HTML - <a href="5-htm.html#SP11">&#167;11</a><br/>Web Structure - <a href="8-ws.html#SP6">&#167;6</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">escape_oddities</span><span class="plain-syntax">, </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">serious</span><span class="plain-syntax">,</span>
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">TextFiles::read</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">TextFiles::read</span></span>:<br/>Command Line Arguments - <a href="3-cla.html#SP11">&#167;11</a><br/>Preprocessor - <a href="4-prp.html#SP1">&#167;1</a><br/>JSON - <a href="4-jsn.html#SP33">&#167;33</a><br/>HTML - <a href="5-htm.html#SP11">&#167;11</a><br/>Web Structure - <a href="8-ws.html#SP6">&#167;6</a><br/>Build Files - <a href="8-bf.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">F</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">escape_oddities</span><span class="plain-syntax">, </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">serious</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">void</span><span class="plain-syntax"> (</span><span class="identifier-syntax">iterator</span><span class="plain-syntax">)(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *, </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *),</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> *</span><span class="identifier-syntax">start_at</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">state</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_file_position</span><span class="plain-syntax"> </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">;</span>

View file

@ -494,29 +494,25 @@ function togglePopup(material_id) {
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rname</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rtext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"JSON requirement &lt;%S&gt; set to:\n%S----\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">rname</span><span class="plain-syntax">, </span><span class="identifier-syntax">rtext</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_requirement</span><span class="plain-syntax"> *</span><span class="identifier-syntax">req</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP27" class="function-link"><span class="function-syntax">JSON::decode_req</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rtext</span><span class="plain-syntax">, </span><span class="identifier-syntax">known_JSON_reqs</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">req</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">JSON_type</span><span class="plain-syntax"> == </span><span class="constant-syntax">ERROR_JSONTYPE</span><span class="plain-syntax">))</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"JSON requirement error: %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">if_error</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_requirement</span><span class="plain-syntax"> *</span><span class="identifier-syntax">req</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP33" class="function-link"><span class="function-syntax">JSON::decode_printing_errors</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rtext</span><span class="plain-syntax">, </span><span class="identifier-syntax">known_JSON_reqs</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">req</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">de</span><span class="plain-syntax"> = </span><a href="../foundation-module/2-dct.html#SP5" class="function-link"><span class="function-syntax">Dictionaries::create</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">known_JSON_reqs</span><span class="plain-syntax">, </span><span class="identifier-syntax">rname</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">de</span><span class="plain-syntax">) </span><span class="identifier-syntax">de</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">value</span><span class="plain-syntax"> = </span><span class="identifier-syntax">req</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><a href="../foundation-module/4-jsn.html#SP31" class="function-link"><span class="function-syntax">JSON::encode_req</span></a><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../foundation-module/4-jsn.html#SP32" class="function-link"><span class="function-syntax">JSON::encode_req</span></a><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../foundation-module/4-pm.html#SP10" class="function-link"><span class="function-syntax">Regexp::match</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">, </span><span class="identifier-syntax">JSON</span><span class="plain-syntax">, </span><span class="identifier-syntax">L</span><span class="string-syntax">" *(%c+?) against *(%c+)"</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">rtext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">material</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mr</span><span class="plain-syntax">.</span><span class="element-syntax">exp</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"JSON verification test on:\n%S-- to match --\n%S\n----\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">material</span><span class="plain-syntax">, </span><span class="identifier-syntax">rtext</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_requirement</span><span class="plain-syntax"> *</span><span class="identifier-syntax">req</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP27" class="function-link"><span class="function-syntax">JSON::decode_req</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rtext</span><span class="plain-syntax">, </span><span class="identifier-syntax">known_JSON_reqs</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">req</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">JSON_type</span><span class="plain-syntax"> == </span><span class="constant-syntax">ERROR_JSONTYPE</span><span class="plain-syntax">))</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"JSON requirement error: %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">if_error</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_value</span><span class="plain-syntax"> *</span><span class="identifier-syntax">value</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP9" class="function-link"><span class="function-syntax">JSON::decode</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">material</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_requirement</span><span class="plain-syntax"> *</span><span class="identifier-syntax">req</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP33" class="function-link"><span class="function-syntax">JSON::decode_printing_errors</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">rtext</span><span class="plain-syntax">, </span><span class="identifier-syntax">known_JSON_reqs</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">req</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_value</span><span class="plain-syntax"> *</span><span class="identifier-syntax">value</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP10" class="function-link"><span class="function-syntax">JSON::decode</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">material</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">value</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">value</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">JSON_type</span><span class="plain-syntax"> == </span><span class="constant-syntax">ERROR_JSONTYPE</span><span class="plain-syntax">))</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"JSON error: %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">if_error</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">linked_list</span><span class="plain-syntax"> *</span><span class="identifier-syntax">errs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NEW_LINKED_LIST</span><span class="plain-syntax">(</span><span class="reserved-syntax">text_stream</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP25" class="function-link"><span class="function-syntax">JSON::verify</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">value</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">, </span><span class="identifier-syntax">errs</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP26" class="function-link"><span class="function-syntax">JSON::verify</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">value</span><span class="plain-syntax">, </span><span class="identifier-syntax">req</span><span class="plain-syntax">, </span><span class="identifier-syntax">errs</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"Verifies"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
@ -531,11 +527,11 @@ function togglePopup(material_id) {
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"JSON test on:\n%S----\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">JSON</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_value</span><span class="plain-syntax"> *</span><span class="identifier-syntax">value</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP9" class="function-link"><span class="function-syntax">JSON::decode</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">JSON</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">JSON_value</span><span class="plain-syntax"> *</span><span class="identifier-syntax">value</span><span class="plain-syntax"> = </span><a href="../foundation-module/4-jsn.html#SP10" class="function-link"><span class="function-syntax">JSON::decode</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">JSON</span><span class="plain-syntax">, </span><span class="identifier-syntax">tfp</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">value</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">value</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">JSON_type</span><span class="plain-syntax"> == </span><span class="constant-syntax">ERROR_JSONTYPE</span><span class="plain-syntax">))</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"JSON error: %S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">if_error</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span>
<span class="plain-syntax"> </span><a href="../foundation-module/4-jsn.html#SP16" class="function-link"><span class="function-syntax">JSON::encode</span></a><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><a href="../foundation-module/4-jsn.html#SP17" class="function-link"><span class="function-syntax">JSON::encode</span></a><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="identifier-syntax">value</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><a href="../foundation-module/4-pm.html#SP9" class="function-link"><span class="function-syntax">Regexp::dispose_of</span></a><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">mr</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="constant-syntax">STDOUT</span><span class="plain-syntax">, </span><span class="string-syntax">"\n--------\n"</span><span class="plain-syntax">);</span>

Binary file not shown.

View file

@ -92,7 +92,7 @@ actually look for: they will be available to some patterns and not others.
<span class="plain-syntax"> </span><span class="constant-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">colour_scheme</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure colour_scheme is accessed in 5/ee, 1/ts, 5/hf, 6/cs and here.</li></ul>
<ul class="endnotetexts"><li>The structure colour_scheme is accessed in 4/jsn, 5/ee, 1/ts, 5/hf, 6/cs and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b></p>
<pre class="displayed-code all-displayed-code code-font">

View file

@ -299,7 +299,7 @@ function togglePopup(material_id) {
<span class="plain-syntax"> </span><span class="constant-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">weave_verbatim_node</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure weave_document_node is accessed in 3/tc, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_head_node is accessed in 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_body_node is private to this section.</li><li>The structure weave_tail_node is accessed in 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_chapter_header_node is accessed in 5/ptf, 5/tf, 5/df and here.</li><li>The structure weave_chapter_footer_node is accessed in 5/ptf, 5/tf, 5/df and here.</li><li>The structure weave_section_header_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_section_footer_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_section_purpose_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_subheading_node is accessed in 1/pc, 2/lc, 2/tp, 2/pn, 3/ta, 3/tw, 3/tt, 4/as, 4/cl, 4/is, 5/ptf, 5/tf, 5/hf, 5/df, 6/cs and here.</li><li>The structure weave_bar_node is private to this section.</li><li>The structure weave_pagebreak_node is private to this section.</li><li>The structure weave_linebreak_node is private to this section.</li><li>The structure weave_paragraph_heading_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_endnote_node is private to this section.</li><li>The structure weave_figure_node is accessed in 1/fm, 1/pp, 1/wp, 8/ws, 4/cl, 5/tf, 5/hf, 5/df, 6/rw and here.</li><li>The structure weave_extract_node is accessed in 5/hf and here.</li><li>The structure weave_audio_node is accessed in 8/ws, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_video_node is accessed in 1/fm, 1/pp, 1/wp, 8/ws, 4/cl, 5/tf, 5/hf, 5/df, 6/rw and here.</li><li>The structure weave_download_node is accessed in 5/hf, 5/df and here.</li><li>The structure weave_material_node is accessed in 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_embed_node is accessed in 1/fm, 1/pp, 1/wp, 8/ws, 4/cl, 5/ptf, 5/tf, 5/hf, 5/df, 6/rw and here.</li><li>The structure weave_pmac_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_vskip_node is accessed in 5/tf, 5/df and here.</li><li>The structure weave_chapter_node is accessed in 5/ptf, 5/tf, 5/df and here.</li><li>The structure weave_section_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_code_line_node is private to this section.</li><li>The structure weave_function_usage_node is accessed in 1/wp, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_commentary_node is accessed in 1/pc, 2/lc, 2/tp, 2/pn, 3/ta, 3/tw, 3/tt, 4/as, 4/cl, 4/is, 5/ptf, 5/tf, 5/hf, 5/df, 6/cs and here.</li><li>The structure weave_carousel_slide_node is accessed in 2/tgs, 5/hf, 5/df and here.</li><li>The structure weave_toc_node is accessed in 5/tf, 5/df and here.</li><li>The structure weave_toc_line_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_chapter_title_page_node is private to this section.</li><li>The structure weave_defn_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_inline_node is private to this section.</li><li>The structure weave_locale_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_source_code_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_url_node is accessed in 2/trs, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_footnote_cue_node is accessed in 2/tp, 3/tw, 3/twot, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_begin_footnote_text_node is accessed in 2/tp, 3/tw, 3/twot, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_display_line_node is accessed in 1/pc, 2/lc, 2/tp, 2/pn, 3/ta, 3/tw, 3/tt, 4/as, 4/cl, 4/is, 5/ptf, 5/tf, 5/hf, 5/df, 6/cs and here.</li><li>The structure weave_function_defn_node is accessed in 1/wp, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_item_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_grammar_index_node is private to this section.</li><li>The structure weave_maths_node is accessed in 2/trs, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_verbatim_node is accessed in 2/trs, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li></ul>
<ul class="endnotetexts"><li>The structure weave_document_node is accessed in 3/tc, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_head_node is accessed in 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_body_node is private to this section.</li><li>The structure weave_tail_node is accessed in 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_chapter_header_node is accessed in 5/ptf, 5/tf, 5/df and here.</li><li>The structure weave_chapter_footer_node is accessed in 5/ptf, 5/tf, 5/df and here.</li><li>The structure weave_section_header_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_section_footer_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_section_purpose_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_subheading_node is accessed in 1/pc, 2/lc, 2/tp, 2/pn, 3/ta, 3/tw, 3/tt, 4/as, 4/cl, 4/is, 5/ptf, 5/tf, 5/hf, 5/df, 6/cs and here.</li><li>The structure weave_bar_node is private to this section.</li><li>The structure weave_pagebreak_node is private to this section.</li><li>The structure weave_linebreak_node is private to this section.</li><li>The structure weave_paragraph_heading_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_endnote_node is private to this section.</li><li>The structure weave_figure_node is accessed in 1/fm, 1/pp, 1/wp, 8/ws, 4/cl, 5/tf, 5/hf, 5/df, 6/rw and here.</li><li>The structure weave_extract_node is accessed in 5/hf and here.</li><li>The structure weave_audio_node is accessed in 8/ws, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_video_node is accessed in 1/fm, 1/pp, 1/wp, 8/ws, 4/cl, 5/tf, 5/hf, 5/df, 6/rw and here.</li><li>The structure weave_download_node is accessed in 5/hf, 5/df and here.</li><li>The structure weave_material_node is accessed in 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_embed_node is accessed in 1/fm, 1/pp, 1/wp, 8/ws, 4/cl, 5/ptf, 5/tf, 5/hf, 5/df, 6/rw and here.</li><li>The structure weave_pmac_node is accessed in 4/jsn, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_vskip_node is accessed in 5/tf, 5/df and here.</li><li>The structure weave_chapter_node is accessed in 5/ptf, 5/tf, 5/df and here.</li><li>The structure weave_section_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_code_line_node is private to this section.</li><li>The structure weave_function_usage_node is accessed in 1/wp, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_commentary_node is accessed in 1/pc, 2/lc, 2/tp, 2/pn, 3/ta, 3/tw, 3/tt, 4/as, 4/cl, 4/is, 5/ptf, 5/tf, 5/hf, 5/df, 6/cs and here.</li><li>The structure weave_carousel_slide_node is accessed in 2/tgs, 5/hf, 5/df and here.</li><li>The structure weave_toc_node is accessed in 5/tf, 5/df and here.</li><li>The structure weave_toc_line_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_chapter_title_page_node is private to this section.</li><li>The structure weave_defn_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_inline_node is private to this section.</li><li>The structure weave_locale_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_source_code_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_url_node is accessed in 2/trs, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_footnote_cue_node is accessed in 2/tp, 3/tw, 3/twot, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_begin_footnote_text_node is accessed in 2/tp, 3/tw, 3/twot, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_display_line_node is accessed in 1/pc, 2/lc, 2/tp, 2/pn, 3/ta, 3/tw, 3/tt, 4/as, 4/cl, 4/is, 5/ptf, 5/tf, 5/hf, 5/df, 6/cs and here.</li><li>The structure weave_function_defn_node is accessed in 1/wp, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_item_node is accessed in 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_grammar_index_node is private to this section.</li><li>The structure weave_maths_node is accessed in 2/trs, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li><li>The structure weave_verbatim_node is accessed in 2/trs, 3/twot, 5/fm, 5/ptf, 5/tf, 5/hf, 5/df and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b></p>
<pre class="displayed-code all-displayed-code code-font">

View file

@ -109,7 +109,7 @@ directory holding a multi-section web.
<span class="plain-syntax"> </span><span class="constant-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">colony_member</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure colony_member is accessed in 2/trs, 4/prp, 1/cnf, 1/ts, 3/tc, 5/wt, 6/cs, 6/rw and here.</li></ul>
<ul class="endnotetexts"><li>The structure colony_member is accessed in 2/trs, 4/prp, 4/jsn, 1/cnf, 1/ts, 3/tc, 5/wt, 6/cs, 6/rw and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>And the following reads a colony file <span class="extract"><span class="extract-syntax">F</span></span> and produces a suitable <span class="extract"><span class="extract-syntax">colony</span></span>
object from it. This, for example, is the colony file for the Inweb repository
at GitHub:

View file

@ -261,7 +261,7 @@ memory is cheap. It's easier to keep a duplicate list.
<span class="plain-syntax"> </span><span class="constant-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">defined_constant</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure defined_constant is accessed in 2/trs, 4/prp, 1/apacs, 5/wt, 6/rw, 6/cln and here.</li></ul>
<ul class="endnotetexts"><li>The structure defined_constant is accessed in 2/trs, 4/prp, 4/jsn, 1/apacs, 5/wt, 6/rw, 6/cln and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>This is called for any <span class="extract"><span class="extract-syntax">@d</span></span> or <span class="extract"><span class="extract-syntax">@e</span></span> constant name, then:
</p>

View file

@ -105,7 +105,7 @@ assume that the version complies with any format).
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="../foundation-module/4-sm.html#SP19" class="function-link"><span class="function-syntax">Str::eq</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">datum</span><span class="plain-syntax">, </span><span class="identifier-syntax">I</span><span class="string-syntax">"Version Number"</span><span class="plain-syntax">)) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">version</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure writeme_asset is accessed in 2/trs, 4/prp, 5/wt, 6/cs, 6/cln and here.</li></ul>
<ul class="endnotetexts"><li>The structure writeme_asset is accessed in 2/trs, 4/prp, 4/jsn, 5/wt, 6/cs, 6/cln and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>That just leaves the business of inspecting assets to obtain their metadata.
</p>

View file

@ -26,6 +26,7 @@ here we are.
@e HTML_tag_CLASS
@e JSON_pair_requirement_CLASS
@e JSON_requirement_CLASS
@e JSON_single_requirement_CLASS
@e JSON_value_CLASS
@e linked_list_CLASS
@e linked_list_item_CLASS
@ -70,6 +71,7 @@ DECLARE_CLASS(heterogeneous_tree)
DECLARE_CLASS(HTML_file_state)
DECLARE_CLASS(JSON_pair_requirement)
DECLARE_CLASS(JSON_requirement)
DECLARE_CLASS(JSON_single_requirement)
DECLARE_CLASS(JSON_value)
DECLARE_CLASS(linked_list)
DECLARE_CLASS(method_set)

View file

@ -54,7 +54,7 @@ void JSON::write_type(OUTPUT_STREAM, int t) {
case OBJECT_JSONTYPE: WRITE("object"); break;
case NULL_JSONTYPE: WRITE("null"); break;
case ERROR_JSONTYPE: WRITE("<error>"); break;
default: WRITE("<invalid>"); break;
default: WRITE("<invalid %d>", t); break;
}
}
@ -190,6 +190,24 @@ JSON_value *JSON::error(text_stream *msg) {
return value;
}
@ This is a very limited form of comparison, since it cannot test equality
of arrays or objects.
=
int JSON::eq(JSON_value *val1, JSON_value *val2) {
if ((val1 == NULL) && (val2)) return FALSE;
if ((val1) && (val2 == NULL)) return FALSE;
if (val1 == NULL) return TRUE;
if (val1->JSON_type != val2->JSON_type) return FALSE;
switch (val1->JSON_type) {
case NUMBER_JSONTYPE: if (val1->if_integer == val2->if_integer) return TRUE; break;
case STRING_JSONTYPE: if (Str::eq(val1->if_string, val2->if_string)) return TRUE; break;
case BOOLEAN_JSONTYPE: if (val1->if_boolean == val2->if_boolean) return TRUE; break;
case NULL_JSONTYPE: return TRUE;
}
return FALSE;
}
@h Decoding JSON.
We do no actual file-handling in this section, but the following decoder can
be pointed to the contents of UTF-8 text file as needed.
@ -200,8 +218,34 @@ any malformed JSON anywhere inside it, this pointer will be to a value of type
message is made use of.
=
JSON_value *JSON::decode(text_stream *T) {
return JSON::decode_range(T, 0, Str::len(T));
JSON_value *JSON::decode(text_stream *T, text_file_position *tfp) {
return JSON::decode_range(T, 0, Str::len(T), tfp);
}
JSON_value *JSON::decode_error(text_stream *err, text_file_position *tfp) {
TEMPORARY_TEXT(msg)
if (tfp) WRITE_TO(msg, "%f: ", tfp->text_file_filename);
WRITE_TO(msg, "%S", err);
JSON_value *value = JSON::error(msg);
DISCARD_TEXT(msg)
return value;
}
JSON_value *JSON::decode_error_q(text_stream *err, text_file_position *tfp,
text_stream *T, int from, int to) {
TEMPORARY_TEXT(msg)
WRITE_TO(msg, "%S", err);
if ((T) && (from < to)) {
WRITE_TO(msg, ": '");
for (int i=from; ((i<to) && (i-from < 40)); i++) {
if (Str::get_at(T, i) == '\n') WRITE_TO(msg, " ");
else WRITE_TO(msg, "%c", Str::get_at(T, i));
}
WRITE_TO(msg, "'");
}
JSON_value *value = JSON::decode_error(msg, tfp);
DISCARD_TEXT(msg)
return value;
}
@ This decodes the text in the character position range |[from, to)| as a
@ -213,31 +257,31 @@ number (note that |+| and |.| are not allowed to open a number according to
the JSON standard), and the special cases |true|, |false| and |null|.
=
JSON_value *JSON::decode_range(text_stream *T, int from, int to) {
JSON_value *JSON::decode_range(text_stream *T, int from, int to, text_file_position *tfp) {
int first_nws = -1, last_nws = -1, first_c = 0, last_c = 0;
@<Find the first and last non-whitespace character@>;
switch (first_c) {
case '[':
if (last_c != ']') return JSON::error(I"mismatched '[' ... ']'");
if (last_c != ']') return JSON::decode_error(I"mismatched '[' ... ']'", tfp);
JSON_value *array = JSON::new_array();
return JSON::decode_array(array, T, first_nws+1, last_nws);
return JSON::decode_array(array, T, first_nws+1, last_nws, tfp);
case '{':
if (last_c != '}') return JSON::error(I"mismatched '{' ... '}'");
if (last_c != '}') return JSON::decode_error(I"mismatched '{' ... '}'", tfp);
JSON_value *obj = JSON::new_object();
return JSON::decode_object(obj, T, first_nws+1, last_nws);
return JSON::decode_object(obj, T, first_nws+1, last_nws, tfp);
case '"':
if (last_c != '"') return JSON::error(I"mismatched quotation marks");
return JSON::decode_string(T, first_nws+1, last_nws);
if (last_c != '"') return JSON::decode_error(I"mismatched quotation marks", tfp);
return JSON::decode_string(T, first_nws+1, last_nws, tfp);
}
if ((Characters::isdigit(first_c)) || (first_c == '-'))
return JSON::decode_number(T, first_nws, last_nws+1);
return JSON::decode_number(T, first_nws, last_nws+1, tfp);
if ((Str::includes_at(T, first_nws, I"true")) && (last_nws - first_nws == 3))
return JSON::new_boolean(TRUE);
if ((Str::includes_at(T, first_nws, I"false")) && (last_nws - first_nws == 4))
return JSON::new_boolean(FALSE);
if ((Str::includes_at(T, first_nws, I"null")) && (last_nws - first_nws == 3))
return JSON::new_null();
return JSON::error(I"unknown JSON value");
return JSON::decode_error(I"unknown JSON value", tfp);
}
@<Find the first and last non-whitespace character@> =
@ -249,7 +293,7 @@ JSON_value *JSON::decode_range(text_stream *T, int from, int to) {
if (Characters::is_whitespace(Str::get_at(T, i)) == FALSE) {
last_nws = i; break;
}
if (first_nws < 0) return JSON::error(I"whitespace where JSON value expected");
if (first_nws < 0) return JSON::decode_error(I"whitespace where JSON value expected", tfp);
first_c = Str::get_at(T, first_nws);
last_c = Str::get_at(T, last_nws);
@ -259,7 +303,8 @@ needs to be a comma-separated list. We follow ECMA strictly in disallowing a fin
comma before the |]|, unlike some JSON-like parsers.
=
JSON_value *JSON::decode_array(JSON_value *array, text_stream *T, int from, int to) {
JSON_value *JSON::decode_array(JSON_value *array, text_stream *T, int from, int to,
text_file_position *tfp) {
int content = FALSE;
for (int i=from; i<to; i++)
if (Characters::is_whitespace(Str::get_at(T, i)) == FALSE)
@ -278,22 +323,24 @@ JSON_value *JSON::decode_array(JSON_value *array, text_stream *T, int from, int
}
}
if (first_comma >= 0) {
array = JSON::decode_array_entry(array, T, from, first_comma);
array = JSON::decode_array_entry(array, T, from, first_comma, tfp);
from = first_comma + 1;
goto NextEntry;
}
return JSON::decode_array_entry(array, T, from, to);
return JSON::decode_array_entry(array, T, from, to, tfp);
}
JSON_value *JSON::decode_array_entry(JSON_value *array, text_stream *T, int from, int to) {
JSON_value *value = JSON::decode_range(T, from, to);
JSON_value *JSON::decode_array_entry(JSON_value *array, text_stream *T, int from, int to,
text_file_position *tfp) {
JSON_value *value = JSON::decode_range(T, from, to, tfp);
return JSON::add_to_array(array, value);
}
@ And similarly for objects.
=
JSON_value *JSON::decode_object(JSON_value *obj, text_stream *T, int from, int to) {
JSON_value *JSON::decode_object(JSON_value *obj, text_stream *T, int from, int to,
text_file_position *tfp) {
int content = FALSE;
for (int i=from; i<to; i++)
if (Characters::is_whitespace(Str::get_at(T, i)) == FALSE)
@ -312,11 +359,11 @@ JSON_value *JSON::decode_object(JSON_value *obj, text_stream *T, int from, int t
}
}
if (first_comma >= 0) {
obj = JSON::decode_object_entry(obj, T, from, first_comma);
obj = JSON::decode_object_entry(obj, T, from, first_comma, tfp);
from = first_comma + 1;
goto NextEntry;
}
return JSON::decode_object_entry(obj, T, from, to);
return JSON::decode_object_entry(obj, T, from, to, tfp);
}
@ Note that we allow key names to include all kinds of unconscionable garbage,
@ -327,10 +374,14 @@ in the same object. ECMA says this is a "semantic consideration that may be defi
by JSON processors". We are hereby defining it.
=
JSON_value *JSON::decode_object_entry(JSON_value *obj, text_stream *T, int from, int to) {
JSON_value *JSON::decode_object_entry(JSON_value *obj, text_stream *T, int from, int to,
text_file_position *tfp) {
while (Characters::is_whitespace(Str::get_at(T, from))) from++;
int saved_from = from, saved_to = to;
if (from >= to)
return JSON::decode_error(I"object body ends with comma", tfp);
if (Str::get_at(T, from) != '"')
return JSON::error(I"key does not begin with quotation mark");
return JSON::decode_error_q(I"key does not begin with quotation mark", tfp, T, saved_from, saved_to);
from++;
int ended = FALSE;
TEMPORARY_TEXT(key)
@ -343,13 +394,13 @@ JSON_value *JSON::decode_object_entry(JSON_value *obj, text_stream *T, int from,
PUT_TO(key, c);
}
}
if (ended == FALSE) return JSON::error(I"key does not end with quotation mark");
if (ended == FALSE) return JSON::decode_error_q(I"key does not end with quotation mark", tfp, T, saved_from, saved_to);
while (Characters::is_whitespace(Str::get_at(T, from))) from++;
if ((from >= to) || (Str::get_at(T, from) != ':'))
return JSON::error(I"key is not followed by ':'");
return JSON::decode_error_q(I"key is not followed by ':'", tfp, T, saved_from, saved_to);
from++;
if (JSON::look_up_object(obj, key)) return JSON::error(I"duplicate key");
JSON_value *value = JSON::decode_range(T, from, to);
if (JSON::look_up_object(obj, key)) return JSON::decode_error_q(I"duplicate key", tfp, T, saved_from, saved_to);
JSON_value *value = JSON::decode_range(T, from, to, tfp);
obj = JSON::add_to_object(obj, key, value);
DISCARD_TEXT(key)
return obj;
@ -361,10 +412,10 @@ what floating-point numbers can be represented, but it's common to consider
them as being |double|, so we'll follow suit.
=
JSON_value *JSON::decode_number(text_stream *T, int from, int to) {
JSON_value *JSON::decode_number(text_stream *T, int from, int to, text_file_position *tfp) {
while (Characters::is_whitespace(Str::get_at(T, from))) from++;
while ((to > from) && (Characters::is_whitespace(Str::get_at(T, to-1)))) to--;
if (to <= from) return JSON::error(I"whitespace where number expected");
if (to <= from) return JSON::decode_error(I"whitespace where number expected", tfp);
TEMPORARY_TEXT(integer)
int at = from;
if ((Str::get_at(T, at) == '-') && (to > at+1)) { PUT_TO(integer, '-'); at++; }
@ -376,7 +427,7 @@ JSON_value *JSON::decode_number(text_stream *T, int from, int to) {
(Str::get_at(T, i) == '.') || (Str::get_at(T, i) == '+'))
double_me = TRUE;
else
return JSON::error(I"number is not a decimal integer");
return JSON::decode_error(I"number is not a decimal integer", tfp);
JSON_value *value = NULL;
if (double_me) {
char double_buffer[32];
@ -384,7 +435,7 @@ JSON_value *JSON::decode_number(text_stream *T, int from, int to) {
for (int i=from; (i<to) && (i-from<31); i++)
double_buffer[i-from] = (char) Str::get_at(T, i);
double d = atof(double_buffer);
if (isnan(d)) return JSON::error(I"number is not allowed to be NaN");
if (isnan(d)) return JSON::decode_error(I"number is not allowed to be NaN", tfp);
value = JSON::new_double(d);
} else {
int N = Str::atoi(integer, 0);
@ -398,14 +449,14 @@ JSON_value *JSON::decode_number(text_stream *T, int from, int to) {
to allow the escaping of forward slash, but the standard requires it.
=
JSON_value *JSON::decode_string(text_stream *T, int from, int to) {
JSON_value *JSON::decode_string(text_stream *T, int from, int to, text_file_position *tfp) {
TEMPORARY_TEXT(string)
for (int i=from; i<to; i++) {
wchar_t c = Str::get_at(T, i);
if (c == '\\') {
i++;
c = Str::get_at(T, i);
if ((c >= 0) && (c < 32)) return JSON::error(I"unescaped control character");
if ((c >= 0) && (c < 32)) return JSON::decode_error(I"unescaped control character", tfp);
switch (c) {
case 'b': c = 8; break;
case 't': c = 9; break;
@ -415,7 +466,7 @@ JSON_value *JSON::decode_string(text_stream *T, int from, int to) {
case '\\': break;
case '/': break;
case 'u': @<Decode a hexadecimal Unicode escape@>; break;
default: return JSON::error(I"bad '\\' escape in string");
default: return JSON::decode_error(I"bad '\\' escape in string", tfp);
}
PUT_TO(string, c);
} else {
@ -432,7 +483,7 @@ in the Basic Multilingual Plane, but we don't handle the curious UTF-16 surrogat
rule for code points between |0x10000| and |0x10fff|.
@<Decode a hexadecimal Unicode escape@> =
if (i+4 >= to) return JSON::error(I"incomplete '\\u' escape");
if (i+4 >= to) return JSON::decode_error(I"incomplete '\\u' escape", tfp);
int hex = 0;
for (int j=0; j<4; j++) {
int v = 0;
@ -440,7 +491,7 @@ rule for code points between |0x10000| and |0x10fff|.
if ((digit >= '0') && (digit <= '9')) v = (int) (digit-'0');
else if ((digit >= 'a') && (digit <= 'f')) v = 10 + ((int) (digit-'a'));
else if ((digit >= 'A') && (digit <= 'F')) v = 10 + ((int) (digit-'A'));
else return JSON::error(I"garbled '\\u' escape");
else return JSON::decode_error(I"garbled '\\u' escape", tfp);
hex = hex * 16 + v;
}
c = (wchar_t) hex;
@ -538,7 +589,28 @@ an object marked as optional or mandatory.
=
typedef struct JSON_requirement {
struct linked_list *alternatives; /* of |JSON_single_requirement| */
CLASS_DEFINITION
} JSON_requirement;
JSON_requirement *JSON::single_choice(JSON_single_requirement *sing) {
JSON_requirement *req = CREATE(JSON_requirement);
req->alternatives = NEW_LINKED_LIST(JSON_single_requirement);
ADD_TO_LINKED_LIST(sing, JSON_single_requirement, req->alternatives);
return req;
}
JSON_requirement *JSON::add_alternative(JSON_requirement *so_far,
JSON_single_requirement *sing) {
if (so_far == NULL) return JSON::single_choice(sing);
ADD_TO_LINKED_LIST(sing, JSON_single_requirement, so_far->alternatives);
return so_far;
}
typedef struct JSON_single_requirement {
int JSON_type;
struct JSON_requirement *this_requirement;
struct JSON_value *this_value;
struct JSON_requirement *all_if_list;
struct linked_list *if_list; /* of |JSON_requirement| */
struct dictionary *dictionary_if_object; /* to |JSON_pair_requirement| */
@ -546,7 +618,7 @@ typedef struct JSON_requirement {
struct text_stream *if_error;
int encoding_number;
CLASS_DEFINITION
} JSON_requirement;
} JSON_single_requirement;
typedef struct JSON_pair_requirement {
struct JSON_requirement *req;
@ -554,12 +626,14 @@ typedef struct JSON_pair_requirement {
CLASS_DEFINITION
} JSON_pair_requirement;
@ The following constructor is used for everything...
@ The following constructors are used for everything...
=
JSON_requirement *JSON::require(int t) {
JSON_requirement *req = CREATE(JSON_requirement);
JSON_single_requirement *JSON::require(int t) {
JSON_single_requirement *req = CREATE(JSON_single_requirement);
req->JSON_type = t;
req->this_requirement = NULL;
req->this_value = NULL;
req->all_if_list = NULL;
req->if_list = NULL;
if (t == ARRAY_JSONTYPE) req->if_list = NEW_LINKED_LIST(JSON_requirement);
@ -574,11 +648,23 @@ JSON_requirement *JSON::require(int t) {
return req;
}
JSON_single_requirement *JSON::require_known(JSON_requirement *req) {
JSON_single_requirement *sing = JSON::require(-1);
sing->this_requirement = req;
return sing;
}
JSON_single_requirement *JSON::require_value(JSON_value *value) {
JSON_single_requirement *sing = JSON::require(-1);
sing->this_value = value;
return sing;
}
@ ...except for "array of any number of entries each matching this":
=
JSON_requirement *JSON::require_array_of(JSON_requirement *E_req) {
JSON_requirement *req = JSON::require(ARRAY_JSONTYPE);
JSON_single_requirement *JSON::require_array_of(JSON_requirement *E_req) {
JSON_single_requirement *req = JSON::require(ARRAY_JSONTYPE);
req->all_if_list = E_req;
return req;
}
@ -588,7 +674,7 @@ its own requirement, then instead call |JSON::require(ARRAY_JSONTYPE)| and
then make a number of calls to the following in sequence:
=
void JSON::require_entry(JSON_requirement *req_array, JSON_requirement *req_entry) {
void JSON::require_entry(JSON_single_requirement *req_array, JSON_requirement *req_entry) {
if (req_array == NULL) internal_error("no array");
if (req_array->JSON_type != ARRAY_JSONTYPE) internal_error("not an array requirement");
if (req_entry == NULL) internal_error("no new entry");
@ -599,15 +685,15 @@ void JSON::require_entry(JSON_requirement *req_array, JSON_requirement *req_entr
and then either require or allow key-value pairs with:
=
void JSON::require_pair(JSON_requirement *req_obj, text_stream *key, JSON_requirement *req) {
void JSON::require_pair(JSON_single_requirement *req_obj, text_stream *key, JSON_requirement *req) {
JSON::require_pair_inner(req_obj, key, req, FALSE);
}
void JSON::allow_pair(JSON_requirement *req_obj, text_stream *key, JSON_requirement *req) {
void JSON::allow_pair(JSON_single_requirement *req_obj, text_stream *key, JSON_requirement *req) {
JSON::require_pair_inner(req_obj, key, req, TRUE);
}
void JSON::require_pair_inner(JSON_requirement *req_obj, text_stream *key,
void JSON::require_pair_inner(JSON_single_requirement *req_obj, text_stream *key,
JSON_requirement *req, int opt) {
if (req_obj == NULL) internal_error("no object");
if (req_obj->JSON_type != OBJECT_JSONTYPE) internal_error("not an object requirement");
@ -625,7 +711,7 @@ void JSON::require_pair_inner(JSON_requirement *req_obj, text_stream *key,
is not permitted:
=
JSON_pair_requirement *JSON::look_up_pair(JSON_requirement *req_obj, text_stream *key) {
JSON_pair_requirement *JSON::look_up_pair(JSON_single_requirement *req_obj, text_stream *key) {
if (req_obj == NULL) internal_error("no object");
if (req_obj->JSON_type != OBJECT_JSONTYPE) internal_error("not an object");
dict_entry *de = Dictionaries::find(req_obj->dictionary_if_object, key);
@ -636,8 +722,8 @@ JSON_pair_requirement *JSON::look_up_pair(JSON_requirement *req_obj, text_stream
@ This is used when parsing textual requirements, to indicate a syntax error:
=
JSON_requirement *JSON::error_req(text_stream *msg) {
JSON_requirement *req = JSON::require(ERROR_JSONTYPE);
JSON_single_requirement *JSON::error_req(text_stream *msg) {
JSON_single_requirement *req = JSON::require(ERROR_JSONTYPE);
req->if_error = Str::duplicate(msg);
return req;
}
@ -648,7 +734,7 @@ appended to the linked list |errs|.
The stack here is used to give better error messages by locating where the
problem was: e.g. |"object.coordinates[1]"| is the result of the stack
holding |"object" > ".cooordinates" > "[1]"|. See //
holding |"object" > ".cooordinates" > "[1]"|.
=
int JSON::verify(JSON_value *val, JSON_requirement *req, linked_list *errs) {
@ -686,6 +772,34 @@ int JSON::verify_r(JSON_value *val, JSON_requirement *req, linked_list *errs,
lifo_stack *location) {
if (val == NULL) internal_error("no value");
if (req == NULL) internal_error("no req");
JSON_single_requirement *sing;
LOOP_OVER_LINKED_LIST(sing, JSON_single_requirement, req->alternatives) {
int rv = JSON::verify_sr(val, sing, NULL, location);
if (rv) return TRUE;
}
LOOP_OVER_LINKED_LIST(sing, JSON_single_requirement, req->alternatives) {
JSON::verify_sr(val, sing, errs, location);
break;
}
return FALSE;
}
int JSON::verify_sr(JSON_value *val, JSON_single_requirement *req, linked_list *errs,
lifo_stack *location) {
if (req->this_requirement)
return JSON::verify_r(val, req->this_requirement, errs, location);
if (req->this_value) {
if (JSON::eq(val, req->this_value) == FALSE) {
TEMPORARY_TEXT(msg)
WRITE_TO(msg, "value ");
JSON::encode(msg, val);
WRITE_TO(msg, " not one of those allowed");
JSON::verify_error(errs, msg, location);
DISCARD_TEXT(msg)
return FALSE;
}
return TRUE;
}
if (val->JSON_type == ERROR_JSONTYPE) {
JSON::verify_error(errs, I"erroneous JSON value from parsing bad text", location);
return FALSE;
@ -818,14 +932,52 @@ JSON_requirement *JSON::decode_req_range(text_stream *T, int from, int to,
dictionary *known_names) {
int first_nws = -1, last_nws = -1, first_c = 0, last_c = 0;
@<Find the first and last non-whitespace character in requirement@>;
if (first_c == '(') {
if (last_c != ')') return JSON::single_choice(JSON::error_req(I"mismatched '(' ... ')'"));
from = first_nws + 1;
to = last_nws;
JSON_requirement *req = NULL;
NextEntry: ;
int first_pipe = -1, bl = 0;
for (int i=from, quoted = FALSE; i<to; i++) {
wchar_t c = Str::get_at(T, i);
switch (c) {
case '"': quoted = (quoted)?FALSE:TRUE; break;
case '\\': if (quoted) i++; break;
case '|': if ((first_pipe < 0) && (bl == 0)) first_pipe = i; break;
case '[': case '{': case '(': if (quoted == FALSE) bl++; break;
case ']': case '}': case ')': if (quoted == FALSE) bl--; break;
}
}
if (first_pipe >= 0) {
req = JSON::decode_req_alternative(req, T, from, first_pipe, known_names);
from = first_pipe + 1;
goto NextEntry;
}
return JSON::decode_req_alternative(req, T, from, to, known_names);
}
return JSON::single_choice(JSON::decode_sreq_range(T, from, to, known_names));
}
JSON_requirement *JSON::decode_req_alternative(JSON_requirement *req, text_stream *T,
int from, int to, dictionary *known_names) {
JSON_single_requirement *sing = JSON::decode_sreq_range(T, from, to, known_names);
return JSON::add_alternative(req, sing);
}
JSON_single_requirement *JSON::decode_sreq_range(text_stream *T, int from, int to,
dictionary *known_names) {
int first_nws = -1, last_nws = -1, first_c = 0, last_c = 0;
@<Find the first and last non-whitespace character in requirement@>;
if (first_nws < 0) return JSON::error_req(I"whitespace where requirement expected");
switch (first_c) {
case '[':
if (last_c != ']') return JSON::error_req(I"mismatched '[' ... ']'");
JSON_requirement *array = JSON::require(ARRAY_JSONTYPE);
JSON_single_requirement *array = JSON::require(ARRAY_JSONTYPE);
return JSON::decode_req_array(array, T, first_nws+1, last_nws, known_names);
case '{':
if (last_c != '}') return JSON::error_req(I"mismatched '{' ... '}'");
JSON_requirement *obj = JSON::require(OBJECT_JSONTYPE);
JSON_single_requirement *obj = JSON::require(OBJECT_JSONTYPE);
return JSON::decode_req_object(obj, T, first_nws+1, last_nws, known_names);
case '<':
if (last_c != '>') return JSON::error_req(I"mismatched '<' ... '>'");
@ -841,7 +993,31 @@ JSON_requirement *JSON::decode_req_range(text_stream *T, int from, int to,
return JSON::error_req(I"'<' ... '>' not allowed");
}
DISCARD_TEXT(name)
return known;
if (known) return JSON::require_known(known);
return NULL;
}
int require_value = FALSE;
if ((first_c == '"') || (first_c == '-') || (Characters::isdigit(first_c)))
require_value = TRUE;
if ((Str::includes_at(T, first_nws, I"true")) && (last_nws - first_nws == 3))
require_value = TRUE;
if ((Str::includes_at(T, first_nws, I"false")) && (last_nws - first_nws == 4))
require_value = TRUE;
if ((Str::includes_at(T, first_nws, I"null")) && (last_nws - first_nws == 3))
require_value = TRUE;
if (require_value) {
JSON_value *value = JSON::decode_range(T, from, to, NULL);
if (value->JSON_type == ERROR_JSONTYPE) {
TEMPORARY_TEXT(err)
WRITE_TO(err, "JSON value error: %S", value->if_error);
JSON_single_requirement *sing = JSON::error_req(err);
DISCARD_TEXT(err)
return sing;
}
return JSON::require_value(value);
}
if ((Str::includes_at(T, first_nws, I"number")) && (last_nws - first_nws == 5))
@ -855,7 +1031,11 @@ JSON_requirement *JSON::decode_req_range(text_stream *T, int from, int to,
if ((Str::includes_at(T, first_nws, I"null")) && (last_nws - first_nws == 3))
return JSON::require(NULL_JSONTYPE);
return JSON::error_req(I"unknown JSON value");
text_stream *msg = Str::new();
WRITE_TO(msg, "unknown JSON type '");
for (int i=first_nws; i<last_nws; i++) PUT_TO(msg, Str::get_at(T, i));
WRITE_TO(msg, "'");
return JSON::error_req(msg);
}
@<Find the first and last non-whitespace character in requirement@> =
@ -867,14 +1047,13 @@ JSON_requirement *JSON::decode_req_range(text_stream *T, int from, int to,
if (Characters::is_whitespace(Str::get_at(T, i)) == FALSE) {
last_nws = i; break;
}
if (first_nws < 0) return JSON::error_req(I"whitespace where requirement expected");
first_c = Str::get_at(T, first_nws);
last_c = Str::get_at(T, last_nws);
@ Array requirements:
=
JSON_requirement *JSON::decode_req_array(JSON_requirement *array, text_stream *T,
JSON_single_requirement *JSON::decode_req_array(JSON_single_requirement *array, text_stream *T,
int from, int to, dictionary *known_names) {
int content = FALSE;
for (int i=from; i<to; i++)
@ -894,8 +1073,8 @@ JSON_requirement *JSON::decode_req_array(JSON_requirement *array, text_stream *T
case '"': quoted = (quoted)?FALSE:TRUE; break;
case '\\': if (quoted) i++; break;
case ',': if ((first_comma < 0) && (bl == 0)) first_comma = i; break;
case '[': case '{': if (quoted == FALSE) bl++; break;
case ']': case '}': if (quoted == FALSE) bl--; break;
case '[': case '{': case '(': if (quoted == FALSE) bl++; break;
case ']': case '}': case ')': if (quoted == FALSE) bl--; break;
}
}
if (first_comma >= 0) {
@ -906,7 +1085,7 @@ JSON_requirement *JSON::decode_req_array(JSON_requirement *array, text_stream *T
return JSON::decode_req_array_entry(array, T, from, to, known_names);
}
JSON_requirement *JSON::decode_req_array_entry(JSON_requirement *array, text_stream *T,
JSON_single_requirement *JSON::decode_req_array_entry(JSON_single_requirement *array, text_stream *T,
int from, int to, dictionary *known_names) {
JSON_requirement *req = JSON::decode_req_range(T, from, to, known_names);
JSON::require_entry(array, req);
@ -916,7 +1095,7 @@ JSON_requirement *JSON::decode_req_array_entry(JSON_requirement *array, text_str
@ And similarly for objects.
=
JSON_requirement *JSON::decode_req_object(JSON_requirement *obj, text_stream *T,
JSON_single_requirement *JSON::decode_req_object(JSON_single_requirement *obj, text_stream *T,
int from, int to, dictionary *known_names) {
int content = FALSE;
for (int i=from; i<to; i++)
@ -931,8 +1110,8 @@ JSON_requirement *JSON::decode_req_object(JSON_requirement *obj, text_stream *T,
case '"': quoted = (quoted)?FALSE:TRUE; break;
case '\\': if (quoted) i++; break;
case ',': if ((first_comma < 0) && (bl == 0)) first_comma = i; break;
case '[': case '{': if (quoted == FALSE) bl++; break;
case ']': case '}': if (quoted == FALSE) bl--; break;
case '[': case '{': case '(': if (quoted == FALSE) bl++; break;
case ']': case '}': case ')': if (quoted == FALSE) bl--; break;
}
}
if (first_comma >= 0) {
@ -943,7 +1122,7 @@ JSON_requirement *JSON::decode_req_object(JSON_requirement *obj, text_stream *T,
return JSON::decode_req_object_entry(obj, T, from, to, known_names);
}
JSON_requirement *JSON::decode_req_object_entry(JSON_requirement *obj, text_stream *T,
JSON_single_requirement *JSON::decode_req_object_entry(JSON_single_requirement *obj, text_stream *T,
int from, int to, dictionary *known_names) {
int optional = FALSE;
while (Characters::is_whitespace(Str::get_at(T, from))) from++;
@ -981,8 +1160,8 @@ This is now simple, with one caveat. It's possible to set up requirement trees
so that they are not well-founded. For example:
= (text as InC)
JSON_requirement *set = JSON::require(ARRAY_JSONTYPE);
set->all_if_list = set;
JSON_single_requirement *set = JSON::require(ARRAY_JSONTYPE);
set->all_if_list = JSON::single_choice(set);
=
This is not useless: it matches, say, |[]|, |[ [] ]| and |[ [], [ [] ] ]|
@ -998,10 +1177,30 @@ void JSON::encode_req(OUTPUT_STREAM, JSON_requirement *req) {
void JSON::encode_req_r(OUTPUT_STREAM, JSON_requirement *req, int uniq) {
if (req == NULL) internal_error("no JSON value supplied");
int L = LinkedLists::len(req->alternatives);
if (L > 1) WRITE("( ");
int c = 0;
JSON_single_requirement *sing;
LOOP_OVER_LINKED_LIST(sing, JSON_single_requirement, req->alternatives) {
if (c++ > 0) WRITE(" | ");
JSON::encode_sreq_r(OUT, sing, uniq);
}
if (L > 1) WRITE(" )");
}
void JSON::encode_sreq_r(OUTPUT_STREAM, JSON_single_requirement *req, int uniq) {
if (req->encoding_number == uniq) {
WRITE("<req %d>", req->allocation_id);
} else {
req->encoding_number = uniq;
if (req->this_requirement) {
JSON::encode_req_r(OUT, req->this_requirement, uniq);
return;
}
if (req->this_value) {
JSON::encode(OUT, req->this_value);
return;
}
switch (req->JSON_type) {
case ARRAY_JSONTYPE: {
WRITE("[");
@ -1045,3 +1244,82 @@ void JSON::encode_req_r(OUTPUT_STREAM, JSON_requirement *req, int uniq) {
}
}
}
@h Reading requirements files.
=
typedef struct JSON_rrf_state {
struct text_stream *name;
struct text_stream *defn;
struct dictionary *dict;
struct text_file_position at;
} JSON_rrf_state;
dictionary *JSON::read_requirements_file(dictionary *known, filename *F) {
if (known == NULL) known = Dictionaries::new(32, FALSE);
JSON_rrf_state state;
state.name = Str::new();
state.defn = Str::new();
state.dict = known;
TextFiles::read(F, FALSE, "unable to read file of JSON requirements", TRUE,
&JSON::read_requirements_file_helper, NULL, (void *) &state);
JSON::process_req_defn(&state);
return known;
}
void JSON::read_requirements_file_helper(text_stream *text, text_file_position *tfp,
void *v_state) {
JSON_rrf_state *state = (JSON_rrf_state *) v_state;
match_results mr = Regexp::create_mr();
if (Regexp::match(&mr, text, L" *<(%C+)> *::= *(%c*)")) {
JSON::process_req_defn(state);
WRITE_TO(state->name, "%S", mr.exp[0]);
WRITE_TO(state->defn, "%S", mr.exp[1]);
state->at = *tfp;
} else if (Regexp::match(&mr, text, L" *!%c*")) {
/* do nothing: this line is a comment */
} else if (Regexp::match(&mr, text, L" *")) {
/* do nothing: this line is blank */
} else if (Str::len(state->name) > 0) {
WRITE_TO(state->defn, "%S\n", text);
} else {
Errors::in_text_file_S(I"spurious text before first requirement", tfp);
}
}
void JSON::process_req_defn(JSON_rrf_state *state) {
if (Str::len(state->name) > 0) {
JSON_requirement *req = JSON::decode_printing_errors(state->defn, state->dict, &(state->at));
if (req) {
dict_entry *de = Dictionaries::create(state->dict, state->name);
if (de) de->value = req;
}
}
Str::clear(state->name);
Str::clear(state->defn);
}
JSON_requirement *JSON::decode_printing_errors(text_stream *defn, dictionary *dict,
text_file_position *tfp) {
JSON_requirement *req = JSON::decode_req(defn, dict);
if (req == NULL) internal_error("decode_req returned NULL");
int errors_found = FALSE;
JSON_single_requirement *sing;
LOOP_OVER_LINKED_LIST(sing, JSON_single_requirement, req->alternatives) {
if (sing->JSON_type == ERROR_JSONTYPE) {
TEMPORARY_TEXT(err)
WRITE_TO(err, "JSON requirement error: %S", sing->if_error);
Errors::in_text_file_S(err, tfp);
errors_found = TRUE;
DISCARD_TEXT(err)
}
}
if (errors_found == FALSE) return req;
return NULL;
}
JSON_requirement *JSON::look_up_requirements(dictionary *known, text_stream *name) {
dict_entry *de = Dictionaries::find(known, name);
if (de == NULL) return NULL;
return de->value;
}

View file

@ -437,10 +437,8 @@ void Unit::test_JSON_helper(text_stream *text, text_file_position *tfp, void *st
text_stream *rname = mr.exp[0];
text_stream *rtext = mr.exp[1];
WRITE_TO(STDOUT, "JSON requirement <%S> set to:\n%S----\n", rname, rtext);
JSON_requirement *req = JSON::decode_req(rtext, known_JSON_reqs);
if ((req) && (req->JSON_type == ERROR_JSONTYPE))
WRITE_TO(STDOUT, "JSON requirement error: %S", req->if_error);
else {
JSON_requirement *req = JSON::decode_printing_errors(rtext, known_JSON_reqs, tfp);
if (req) {
dict_entry *de = Dictionaries::create(known_JSON_reqs, rname);
if (de) de->value = req;
JSON::encode_req(STDOUT, req);
@ -450,11 +448,9 @@ void Unit::test_JSON_helper(text_stream *text, text_file_position *tfp, void *st
text_stream *material = mr.exp[1];
WRITE_TO(STDOUT, "JSON verification test on:\n%S-- to match --\n%S\n----\n",
material, rtext);
JSON_requirement *req = JSON::decode_req(rtext, known_JSON_reqs);
if ((req) && (req->JSON_type == ERROR_JSONTYPE))
WRITE_TO(STDOUT, "JSON requirement error: %S", req->if_error);
else {
JSON_value *value = JSON::decode(material);
JSON_requirement *req = JSON::decode_printing_errors(rtext, known_JSON_reqs, tfp);
if (req) {
JSON_value *value = JSON::decode(material, tfp);
if ((value) && (value->JSON_type == ERROR_JSONTYPE))
WRITE_TO(STDOUT, "JSON error: %S", value->if_error);
else {
@ -474,7 +470,7 @@ void Unit::test_JSON_helper(text_stream *text, text_file_position *tfp, void *st
}
} else {
WRITE_TO(STDOUT, "JSON test on:\n%S----\n", JSON);
JSON_value *value = JSON::decode(JSON);
JSON_value *value = JSON::decode(JSON, tfp);
if ((value) && (value->JSON_type == ERROR_JSONTYPE))
WRITE_TO(STDOUT, "JSON error: %S", value->if_error);
else

View file

@ -137,6 +137,44 @@ number
----
number
--------
JSON requirement <optionalint> set to:
( number | null )
----
( number | null )
--------
JSON requirement <enum> set to:
( "alpha" | "beta" | 3 | 5 | false | true | null )
----
( "alpha" | "beta" | 3 | 5 | false | true | null )
--------
JSON verification test on:
"beta"
-- to match --
<enum>
----
Verifies
--------
JSON verification test on:
"gamma"
-- to match --
<enum>
----
value "gamma" not one of those allowed
--------
JSON verification test on:
5
-- to match --
<enum>
----
Verifies
--------
JSON verification test on:
null
-- to match --
<enum>
----
Verifies
--------
JSON requirement <record> set to:
{ "coordinates": [ double, double, string ], ?"jurisdiction": string, "journal": [ { "date": number, "entry": string }* ] }
----

View file

@ -59,6 +59,18 @@ null
----
<int> = number
----
<optionalint> = ( number | null )
----
<enum> = ( "alpha" | "beta" | 3 | 5 | false | true | null )
----
<enum> against "beta"
----
<enum> against "gamma"
----
<enum> against 5
----
<enum> against null
----
<record> = { "coordinates": [ double, double, string ], ?"jurisdiction": string, "journal": [ { "date": number, "entry": string }* ] }
----
<int> against 217