From 1b8aab1ebfc36888d58d5347f7723e4bd1c5031c Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 1 Dec 2020 21:39:01 -0500 Subject: Allow and ignore underscores in numbers --- docs/spec/literal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/spec') diff --git a/docs/spec/literal.html b/docs/spec/literal.html index 2b6b5559..47696b37 100644 --- a/docs/spec/literal.html +++ b/docs/spec/literal.html @@ -7,7 +7,7 @@

Specification: BQN literal notation

A literal is a single token that indicates a fixed character, number, or array. While literals indicate values of a data type, primitives indicate values of an operation type: function, 1-modifier, or 2-modifier.

Two types of literal deal with text. As the source code is considered to be a sequence of unicode code points ("characters"), and these code points are also used for BQN's character data type, 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 character literal is enclosed with single quotes ' and its value is identical to the single character between them. A string literal is enclosed in double quotes ", 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 null literal is the token @ and represents the null character, code point 0.

-

The format of a numeric literal is more complicated. From the tokenization rules, a numeric literal consists of a numeric character (one of ¯∞π.0123456789) followed by any number of numeric or alphabetic characters. Some numeric literals are valid and indicate a number, while others are invalid and cause an error. The grammar for valid numbers is given below in a BNF variant. Only four alphabetic characters are allowed: "i", which separates the real and imaginary components of a complex number, "e", which functions as in scientific notation, and the uppercase versions of these letters.

+

The format of a numeric literal is more complicated. From the tokenization rules, a numeric literal consists of a numeric character (one of ¯∞π.0123456789) followed by any number of numeric or alphabetic characters. Some numeric literals are valid and indicate a number, while others are invalid and cause an error. The grammar for valid numbers is given below in a BNF variant. Only four alphabetic characters are allowed: "i", which separates the real and imaginary components of a complex number, "e", which functions as in scientific notation, and the uppercase versions of these letters. Not included in this grammar are underscores—they can be placed anywhere in a number, including after the last non-underscore character, and are ignored entirely.

number    = component ( ( "i" | "I" ) component )?
 component = "¯"? ( "∞" | mantissa ( ( "e" | "E" ) exponent )? )
 exponent  = "¯"? digit+
-- 
cgit v1.2.3