aboutsummaryrefslogtreecommitdiff
path: root/docs/spec
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-14 16:56:01 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-09-14 16:56:01 -0400
commit1450c56754c1b2a1b42fc78547f384b83aa8dc13 (patch)
treefe26d167a65e34525dc2aa598d2bd4df1945b136 /docs/spec
parentc6cc1584c1a9aa5c30c39f272e1300a7be76323d (diff)
Don't allow ∞ with an exponent in numeric literals
Diffstat (limited to 'docs/spec')
-rw-r--r--docs/spec/literal.html6
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/spec/literal.html b/docs/spec/literal.html
index 1a5fea6a..39ac864a 100644
--- a/docs/spec/literal.html
+++ b/docs/spec/literal.html
@@ -9,12 +9,12 @@
<p>Two types of literal deal with text. As the source code is considered to be a sequence of unicode code points (&quot;characters&quot;), and these code points are also used for BQN's character <a href="types.html">data type</a>, the representation of a text literal is very similar to its value. In a text literal, the newline character is always represented using the ASCII line feed character, code point 10. A <em>character literal</em> is enclosed with single quotes <code><span class='String'>'</span></code> and its value is identical to the single character between them. A <em>string literal</em> is enclosed in double quotes <code><span class='String'>&quot;</span></code>, and any double quotes between them must come in pairs, as a lone double quote marks the end of the literal. The value of a string literal is a rank-1 array whose elements are the characters in between the enclosing quotes, after replacing each pair of double quotes with only one such quote. The <em>null literal</em> is the token <code><span class='String'>@</span></code> and represents the null character, code point 0.</p>
<p>The format of a <em>numeric literal</em> is more complicated. From the <a href="token.html">tokenization rules</a>, a numeric literal consists of a numeric character (one of <code><span class='Number'>¯∞π.0123456789</span></code>) followed by any number of numeric or alphabetic characters. Some numeric literals are <em>valid</em> and indicate a number, while others are invalid and cause an error. The grammar for valid numbers is given below in a <a href="https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form">BNF</a> variant. Only four alphabetic characters are allowed: &quot;i&quot;, which separates the real and imaginary components of a complex number, &quot;e&quot;, which functions as in scientific notation, and the uppercase versions of these letters.</p>
<pre><span class='Value'>number</span> <span class='Function'>=</span> <span class='Value'>component</span> <span class='Paren'>(</span> <span class='Paren'>(</span> <span class='String'>&quot;i&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;I&quot;</span> <span class='Paren'>)</span> <span class='Value'>component</span> <span class='Paren'>)</span><span class='Value'>?</span>
-<span class='Value'>component</span> <span class='Function'>=</span> <span class='Value'>mantissa</span> <span class='Paren'>(</span> <span class='Paren'>(</span> <span class='String'>&quot;e&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;E&quot;</span> <span class='Paren'>)</span> <span class='Value'>exponent</span> <span class='Paren'>)</span><span class='Value'>?</span>
+<span class='Value'>component</span> <span class='Function'>=</span> <span class='String'>&quot;¯&quot;</span><span class='Value'>?</span> <span class='Paren'>(</span> <span class='String'>&quot;∞&quot;</span> <span class='Function'>|</span> <span class='Value'>mantissa</span> <span class='Paren'>(</span> <span class='Paren'>(</span> <span class='String'>&quot;e&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;E&quot;</span> <span class='Paren'>)</span> <span class='Value'>exponent</span> <span class='Paren'>)</span><span class='Value'>?</span> <span class='Paren'>)</span>
<span class='Value'>exponent</span> <span class='Function'>=</span> <span class='String'>&quot;¯&quot;</span><span class='Value'>?</span> <span class='Value'>digit</span><span class='Function'>+</span>
-<span class='Value'>mantissa</span> <span class='Function'>=</span> <span class='String'>&quot;¯&quot;</span><span class='Value'>?</span> <span class='Paren'>(</span> <span class='String'>&quot;∞&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;π&quot;</span> <span class='Function'>|</span> <span class='Value'>digit</span><span class='Function'>+</span> <span class='Paren'>(</span> <span class='String'>&quot;.&quot;</span> <span class='Value'>digit</span><span class='Function'>+</span> <span class='Paren'>)</span><span class='Value'>?</span> <span class='Paren'>)</span>
+<span class='Value'>mantissa</span> <span class='Function'>=</span> <span class='String'>&quot;π&quot;</span> <span class='Function'>|</span> <span class='Value'>digit</span><span class='Function'>+</span> <span class='Paren'>(</span> <span class='String'>&quot;.&quot;</span> <span class='Value'>digit</span><span class='Function'>+</span> <span class='Paren'>)</span><span class='Value'>?</span>
<span class='Value'>digit</span> <span class='Function'>=</span> <span class='String'>&quot;0&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;1&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;2&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;3&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;4&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;5&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;6&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;7&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;8&quot;</span> <span class='Function'>|</span> <span class='String'>&quot;9&quot;</span>
</pre>
-<p>The digits or arabic numerals correspond to the numbers from 0 to 9 in the conventional way (also, each corresponds to its code point value minus 48). A sequence of digits gives a natural number by evaluating it in base 10: the number is 0 for an empty sequence, and otherwise the last digit's numerical value plus ten times the number obtained from the remaining digits. The symbol <code><span class='Number'>∞</span></code> indicates infinity and <code><span class='Number'>π</span></code> indicates the ratio <a href="https://en.wikipedia.org/wiki/Pi_(mathematics)">pi</a> of a circle's circumference to its diameter (or, for modern mathematicians, the smallest positive real number at which the function <code><span class='Brace'>{</span><span class='Function'>⋆</span><span class='Number'>0j1</span><span class='Function'>×</span><span class='Value'>𝕩</span><span class='Brace'>}</span></code> attains a real part of 0). The <a href="https://aplwiki.com/wiki/High_minus">high minus</a> symbol <code><span class='Number'>¯</span></code> indicates that the number containing it is to be negated.</p>
+<p>The digits or arabic numerals correspond to the numbers from 0 to 9 in the conventional way (also, each corresponds to its code point value minus 48). A sequence of digits gives a natural number by evaluating it in base 10: the number is 0 for an empty sequence, and otherwise the last digit's numerical value plus ten times the number obtained from the remaining digits. The symbol <code><span class='Number'>∞</span></code> indicates infinity and <code><span class='Number'>π</span></code> indicates the ratio <a href="https://en.wikipedia.org/wiki/Pi_(mathematics)">pi</a> of a circle's circumference to its diameter (or, for modern mathematicians, the smallest positive real number at which the function <code><span class='Brace'>{</span><span class='Function'>⋆</span><span class='Number'>0i1</span><span class='Function'>×</span><span class='Value'>𝕩</span><span class='Brace'>}</span></code> attains a real part of 0). The <a href="https://aplwiki.com/wiki/High_minus">high minus</a> symbol <code><span class='Number'>¯</span></code> indicates that the number containing it is to be negated.</p>
<p>When an exponent is provided (with <code><span class='Value'>e</span></code> or <code><span class='Function'>E</span></code>), the corresponding mantissa is multiplied by ten to that power, giving the value <code><span class='Value'>mantissa</span><span class='Function'>×</span><span class='Number'>10</span><span class='Function'>⋆</span><span class='Value'>exponent</span></code>. If a second component is present (using <code><span class='Value'>i</span></code> or <code><span class='Function'>I</span></code>), that component's value is multiplied by the <a href="https://en.wikipedia.org/wiki/Imaginary_unit">imaginary unit</a> <em>i</em> and added to the first component; otherwise the value is the first component's value without modification. If complex numbers are not supported, then <code><span class='Value'>i</span></code> should not be allowed in numeric literals, even when followed by 0.</p>
<p>The above specification describes exactly a complex number with extended real components. To obtain a BQN number, each component is rounded to its nearest representative by the rules of the number system used: for IEEE 754, smallest distance, with ties rounding to the option with even mantissa.</p>