mw-parser/docs/cloverage/mw_parser/errors.clj.html

213 lines
14 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../coverage.css"/> <title> mw_parser/errors.clj </title>
</head>
<body>
<span class="covered" title="1 out of 1 forms covered">
001&nbsp;&nbsp;(ns&nbsp;^{:doc&nbsp;&quot;Display&nbsp;parse&nbsp;errors&nbsp;in&nbsp;a&nbsp;format&nbsp;which&nbsp;makes&nbsp;it&nbsp;easy&nbsp;for&nbsp;the&nbsp;user
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
002&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;see&nbsp;where&nbsp;the&nbsp;error&nbsp;occurred.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
003&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:author&nbsp;&quot;Simon&nbsp;Brooke&quot;}
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
004&nbsp;&nbsp;&nbsp;&nbsp;mw-parser.errors)
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
005&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
006&nbsp;&nbsp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
007&nbsp;&nbsp;;;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
008&nbsp;&nbsp;;;&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software;&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and&#x2F;or
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
009&nbsp;&nbsp;;;&nbsp;modify&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
010&nbsp;&nbsp;;;&nbsp;as&nbsp;published&nbsp;by&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation;&nbsp;either&nbsp;version&nbsp;2
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
011&nbsp;&nbsp;;;&nbsp;of&nbsp;the&nbsp;License,&nbsp;or&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version.
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
012&nbsp;&nbsp;;;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
013&nbsp;&nbsp;;;&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
014&nbsp;&nbsp;;;&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
015&nbsp;&nbsp;;;&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
016&nbsp;&nbsp;;;&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
017&nbsp;&nbsp;;;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
018&nbsp;&nbsp;;;&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
019&nbsp;&nbsp;;;&nbsp;along&nbsp;with&nbsp;this&nbsp;program;&nbsp;if&nbsp;not,&nbsp;write&nbsp;to&nbsp;the&nbsp;Free&nbsp;Software
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
020&nbsp;&nbsp;;;&nbsp;Foundation,&nbsp;Inc.,&nbsp;51&nbsp;Franklin&nbsp;Street,&nbsp;Fifth&nbsp;Floor,&nbsp;Boston,&nbsp;MA&nbsp;&nbsp;02110-1301,
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
021&nbsp;&nbsp;;;&nbsp;USA.
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
022&nbsp;&nbsp;;;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
023&nbsp;&nbsp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
024&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
025&nbsp;&nbsp;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
026&nbsp;&nbsp;;;&nbsp;error&nbsp;thrown&nbsp;when&nbsp;an&nbsp;attempt&nbsp;is&nbsp;made&nbsp;to&nbsp;set&nbsp;a&nbsp;reserved&nbsp;property
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
027&nbsp;&nbsp;(def&nbsp;reserved-properties-error
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
028&nbsp;&nbsp;&nbsp;&nbsp;&quot;The&nbsp;properties&nbsp;&#x27;x&#x27;&nbsp;and&nbsp;&#x27;y&#x27;&nbsp;of&nbsp;a&nbsp;cell&nbsp;are&nbsp;reserved&nbsp;and&nbsp;should&nbsp;not&nbsp;be&nbsp;set&nbsp;in&nbsp;rule&nbsp;actions&quot;)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
029&nbsp;&nbsp;;;&nbsp;error&nbsp;thrown&nbsp;when&nbsp;a&nbsp;rule&nbsp;cannot&nbsp;be&nbsp;parsed.&nbsp;Slots&nbsp;are&nbsp;for
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
030&nbsp;&nbsp;;;&nbsp;(1)&nbsp;rule&nbsp;text
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
031&nbsp;&nbsp;;;&nbsp;(2)&nbsp;cursor&nbsp;showing&nbsp;where&nbsp;in&nbsp;the&nbsp;rule&nbsp;text&nbsp;the&nbsp;error&nbsp;occurred
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
032&nbsp;&nbsp;;;&nbsp;(3)&nbsp;the&nbsp;reason&nbsp;for&nbsp;the&nbsp;error
</span><br/>
<span class="covered" title="2 out of 2 forms covered">
033&nbsp;&nbsp;(def&nbsp;bad-parse-error&nbsp;&quot;I&nbsp;did&nbsp;not&nbsp;understand:\n&nbsp;&nbsp;&#x27;%s&#x27;\n&nbsp;&nbsp;%s\n&nbsp;&nbsp;%s&quot;)
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
034&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
035&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
036&nbsp;&nbsp;(defn-&nbsp;explain-parse-error-reason
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
037&nbsp;&nbsp;&nbsp;&nbsp;&quot;Attempt&nbsp;to&nbsp;explain&nbsp;the&nbsp;reason&nbsp;for&nbsp;the&nbsp;parse&nbsp;error.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
038&nbsp;&nbsp;&nbsp;&nbsp;[reason]
</span><br/>
<span class="covered" title="17 out of 17 forms covered">
039&nbsp;&nbsp;&nbsp;&nbsp;(str&nbsp;&quot;Expecting&nbsp;one&nbsp;of&nbsp;(&quot;&nbsp;(apply&nbsp;str&nbsp;(map&nbsp;#(str&nbsp;(:expecting&nbsp;%)&nbsp;&quot;&nbsp;&quot;)&nbsp;reason))&nbsp;&quot;)&quot;))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
040&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
041&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
042&nbsp;&nbsp;(defn-&nbsp;parser-error-to-map
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
043&nbsp;&nbsp;&nbsp;&nbsp;[parser-error]
</span><br/>
<span class="covered" title="16 out of 16 forms covered">
044&nbsp;&nbsp;&nbsp;&nbsp;(let&nbsp;[m&nbsp;(reduce&nbsp;(fn&nbsp;[map&nbsp;item](merge&nbsp;map&nbsp;{(first&nbsp;item)(second&nbsp;item)}))&nbsp;{}&nbsp;parser-error)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
045&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reason&nbsp;(map
</span><br/>
<span class="covered" title="15 out of 15 forms covered">
046&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#(reduce&nbsp;(fn&nbsp;[map&nbsp;item]&nbsp;(merge&nbsp;{(first&nbsp;item)&nbsp;(second&nbsp;item)}&nbsp;map))&nbsp;{}&nbsp;%)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
047&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(:reason&nbsp;m))]
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
048&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(merge&nbsp;m&nbsp;{:reason&nbsp;reason})))
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
049&nbsp;&nbsp;
</span><br/>
<span class="blank" title="0 out of 0 forms covered">
050&nbsp;&nbsp;
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
051&nbsp;&nbsp;(defn&nbsp;throw-parse-exception
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
052&nbsp;&nbsp;&nbsp;&nbsp;&quot;Construct&nbsp;a&nbsp;helpful&nbsp;error&nbsp;message&nbsp;from&nbsp;this&nbsp;`parser-error`,&nbsp;and&nbsp;throw&nbsp;an&nbsp;exception&nbsp;with&nbsp;that&nbsp;message.&quot;
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
053&nbsp;&nbsp;&nbsp;&nbsp;[parser-error]
</span><br/>
<span class="partial" title="5 out of 16 forms covered">
054&nbsp;&nbsp;&nbsp;&nbsp;(assert&nbsp;(coll?&nbsp;parser-error)&nbsp;&quot;Expected&nbsp;a&nbsp;paser&nbsp;error&nbsp;structure?&quot;)
</span><br/>
<span class="covered" title="1 out of 1 forms covered">
055&nbsp;&nbsp;&nbsp;&nbsp;(let
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
056&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
057&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;the&nbsp;error&nbsp;structure&nbsp;is&nbsp;a&nbsp;list,&nbsp;such&nbsp;that&nbsp;each&nbsp;element&nbsp;is&nbsp;a&nbsp;list&nbsp;of&nbsp;two&nbsp;items,&nbsp;and
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
058&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;the&nbsp;first&nbsp;element&nbsp;in&nbsp;each&nbsp;sublist&nbsp;is&nbsp;a&nbsp;keyword.&nbsp;Easier&nbsp;to&nbsp;work&nbsp;with&nbsp;it&nbsp;as&nbsp;a&nbsp;map
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
059&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error-map&nbsp;(parser-error-to-map&nbsp;parser-error)
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
060&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text&nbsp;(:text&nbsp;error-map)
</span><br/>
<span class="covered" title="5 out of 5 forms covered">
061&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reason&nbsp;(explain-parse-error-reason&nbsp;(:reason&nbsp;error-map))
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
062&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;rules&nbsp;have&nbsp;only&nbsp;one&nbsp;line,&nbsp;by&nbsp;definition;&nbsp;we&#x27;re&nbsp;interested&nbsp;in&nbsp;the&nbsp;column
</span><br/>
<span class="partial" title="7 out of 8 forms covered">
063&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;column&nbsp;(if&nbsp;(:column&nbsp;error-map)(:column&nbsp;error-map)&nbsp;0)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
064&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;;&nbsp;create&nbsp;a&nbsp;cursor&nbsp;to&nbsp;point&nbsp;to&nbsp;that&nbsp;column
</span><br/>
<span class="covered" title="12 out of 12 forms covered">
065&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor&nbsp;(apply&nbsp;str&nbsp;(reverse&nbsp;(conj&nbsp;(repeat&nbsp;column&nbsp;&quot;&nbsp;&quot;)&nbsp;&quot;^&quot;)))
</span><br/>
<span class="covered" title="6 out of 6 forms covered">
066&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message&nbsp;(format&nbsp;bad-parse-error&nbsp;text&nbsp;cursor&nbsp;reason)
</span><br/>
<span class="not-tracked" title="0 out of 0 forms covered">
067&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]
</span><br/>
<span class="covered" title="3 out of 3 forms covered">
068&nbsp;&nbsp;&nbsp;&nbsp;(throw&nbsp;(Exception.&nbsp;message))))
</span><br/>
</body>
</html>