diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-01 21:39:01 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-01 21:46:45 -0500 |
| commit | 1b8aab1ebfc36888d58d5347f7723e4bd1c5031c (patch) | |
| tree | 18f2fef309a13d84a6fb84c2ee2d15f629ca199a /spec/literal.md | |
| parent | 462ef9f8136c4d87e3dd320a68ba8b63a5238aac (diff) | |
Allow and ignore underscores in numbers
Diffstat (limited to 'spec/literal.md')
| -rw-r--r-- | spec/literal.md | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/spec/literal.md b/spec/literal.md index edf91b83..ab644601 100644 --- a/spec/literal.md +++ b/spec/literal.md @@ -6,7 +6,7 @@ A *literal* is a single [token](token.md) that indicates a fixed character, numb 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](types.md), 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](token.md), 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](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form) 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](token.md), 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](https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form) 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 )? ) |
