diff --git a/zkat/suffixes/draft-marchan-kdl2.html b/zkat/suffixes/draft-marchan-kdl2.html
index 3258927..8cf7f75 100644
--- a/zkat/suffixes/draft-marchan-kdl2.html
+++ b/zkat/suffixes/draft-marchan-kdl2.html
@@ -1566,20 +1566,28 @@ about how to interpret a value.¶
annotation as a "suffix", instead of prepending it between ( and ). This
makes it possible to, for example, write 10px, 10.5%, 512GiB, etc., which
are equivalent to (px)10, (%)5, and (GiB)512, respectively.¶
-An implementation that finds BOTH a parenthesized and a suffix
-(Section 3.8) on the same (Section 3.14) MUST yield a syntax error.¶
-Suffixes MUST BE plain (Section 3.10)s. No other (Section 3.9) is
-acceptable.¶
-There are two kinds of (Section 3.8.1) available:
-(Section 3.8.1.1)s and (Section 3.8.1.2).¶
+Most suffixes can be appended directly to the number (a
+(Section 3.8.1.1)), as shown in the previous paragraph. To avoid
+parsing ambiguity, there are some restrictions on this; an
+(Section 3.8.1.2) avoids all these restrictions by using an
+additional # to explicitly indicate it. For example, 10.0u8 is invalid, but
+10.0#u8 is valid and equivalent to (u8)10.0. See
+(Section 3.8.1.1) for the full list of restrictions.¶
+An implementation that finds BOTH a parenthesized and a suffix
+(Section 3.8) on the same (Section 3.14) MUST yield a syntax error.¶
+Suffixes MUST BE plain (Section 3.10)s. No other (Section 3.9) is
+acceptable.¶
+There are two kinds of (Section 3.8.1) available:
+(Section 3.8.1.1)s and (Section 3.8.1.2).¶
When a (Section 3.7) is a decimal (Section 3.14) WITHOUT exponential syntax (1e+5
-etc) (and ONLY a decimal), it's possible to attach the type annotation as a
-suffix directly to the number, without any additional syntax.¶
+etc) (and ONLY a decimal: that is, numbers which do NOT have a 0b/0o/0x
+prefix), it's possible to attach the type annotation as a suffix directly to the
+number, without any additional syntax.¶
They also come with some additional rules (like only being available for
decimals), in order to prevent potential ambiguity or footguns with the syntax.
This is generally acceptable, as type annotations in particular tend to be
@@ -1587,27 +1595,26 @@ application-defined and limited in scope, rather than arbitrary user data. In
designing this feature, it was determined that the value for various real-world
DSLs outweighed the complexity of the following rules.¶
As such, to remove ambiguity, the suffix (Section 3.10) MUST NOT start
-with any of the following patterns, all of which MUST yield syntax errors
-(if they can be distinguished from other syntaxes at all):¶
+with any of the following patterns, all of which MUST yield syntax errors (if
+they can be distinguished from other syntaxes at all):¶
-
., ,, or _¶
-
-
[a-zA-Z][0-9_] (to disambiguate all non-decimals, with breathing room)¶
-
- -
-
[eE][+-]?[0-9] (to disambiguate exponentials)¶
-
- -
-
[xX][a-fA-F] (to disambiguate hexadecimals)¶
+ [eE][+-]?[0-9] (to disambiguate exponentials)¶
-All other (Section 3.10)s can be safely appended to decimal numbers, so
-long as the decimal does not include an exponential component.¶
-If the desired suffix would violate any of the above rules, either regular
-parenthetical (Section 3.8)s, or (Section 3.8.1.2)s
-may be used.¶
+For example, 10,000 is illegal. 10e0n is illegal, but 10e0 is a legal
+decimal number using exponential syntax, not equivalent to (e0)10.
+Additionally, note that since bare suffixes are only legal on decimals, 0u8
+is legal, but 0xs is not, since hexadecimals are determined by their
+prefixes. Similarly, 1xs is legal, and equivalent to (xs)1.¶
+All other (Section 3.10)s can be safely appended to decimal numbers, so
+long as the decimal does not include an exponential component.¶
+If the desired suffix would violate any of the above rules, either regular
+parenthetical (Section 3.8)s or (Section 3.8.1.2)s
+may be used.¶
@@ -1615,14 +1622,14 @@ may be used.
¶
-
Any (Section 3.14) may have a # attached to it, followed by any valid
+
Any (Section 3.14) may have a # appended to it, followed by any valid
(Section 3.10). This is an explicit (Section 3.8.1) syntax
without any of the relatively complex requirements of
(Section 3.8.1.1), which can be a useful escape hatch. For
-example: 10.0#u8 is invalid syntax without the # prefix.¶
+example:
0#b1 is invalid syntax without the
# prefix.
¶
Note again that, unlike (Section 3.8.1.1)s, Explicit Suffixes
may be used with ALL (Section 3.14) formats (hexadecimal, decimal, octal, and
-binary). For example, 0x1234#u16 is valid.¶
+binary). For example,
0x1234#u32 is valid.
¶
@@ -2849,8 +2856,9 @@ node-children := '{' nodes final-node? '}'
node-terminator := single-line-comment | newline | ';' | eof
prop := string node-space* '=' node-space* value
-value := type? node-space* (string | number | keyword)
+value := normal-value | suffixed-decimal
type := '(' node-space* string node-space* ')'
+normal-value := type? node-space* (string | number | keyword)
// Strings
string := identifier-string | quoted-string | raw-string ¶
@@ -2911,24 +2919,25 @@ multi-line-raw-string-body :=
// Numbers
number := keyword-number | hex | octal | binary | decimal
-decimal := sign? integer ('.' integer)? (
- // NOTE: This grammar does not explicitly guard against having both
- // parenthesized and type suffixes.
- bare-type-suffix |
- explicit-type-suffix |
- (exponent explicit-type-suffix?)
- )?
+decimal := significand exponent?
+suffixed-decimal := significand (
+ bare-type-suffix
+ | (exponent? explicit-type-suffix)
+)
+significand := sign? significand-initial integer? ('.' integer)?
exponent := ('e' | 'E') sign? integer
integer := digit (digit | '_')*
+significand-initial = digit
+ - '0b'
+ - '0o'
+ - '0x'
digit := [0-9]
sign := '+' | '-'
bare-type-suffix := bare-type-suffix-initial identifier-char*
bare-type-suffix-initial := identifier-char
- '.' - ',' - '_'
- - ([a-zA-Z] [0-9_])
- (('e' | 'E') sign? digit)
- - (('x' | 'X') [a-fA-F])
explicit-type-suffix := '#' identifier-string
hex := sign? '0x' hex-digit (hex-digit | '_')*
diff --git a/zkat/suffixes/draft-marchan-kdl2.txt b/zkat/suffixes/draft-marchan-kdl2.txt
index a0866e6..8d441fc 100644
--- a/zkat/suffixes/draft-marchan-kdl2.txt
+++ b/zkat/suffixes/draft-marchan-kdl2.txt
@@ -312,6 +312,14 @@ Table of Contents
512GiB, etc., which are equivalent to (px)10, (%)5, and (GiB)512,
respectively.
+ Most suffixes can be appended directly to the number (a
+ (Section 3.8.1.1)), as shown in the previous paragraph. To avoid
+ parsing ambiguity, there are some restrictions on this; an
+ (Section 3.8.1.2) avoids all these restrictions by using an
+ additional # to explicitly indicate it. For example, 10.0u8 is
+ invalid, but 10.0#u8 is valid and equivalent to (u8)10.0. See
+ (Section 3.8.1.1) for the full list of restrictions.
+
An implementation that finds BOTH a parenthesized and a suffix
(Section 3.8) on the same (Section 3.14) MUST yield a syntax error.
@@ -324,9 +332,9 @@ Table of Contents
3.8.1.1. Bare Suffix Type Annotation
When a (Section 3.7) is a decimal (Section 3.14) WITHOUT exponential
- syntax (1e+5 etc) (and ONLY a decimal), it's possible to attach the
- type annotation as a suffix directly to the number, without any
- additional syntax.
+ syntax (1e+5 etc) (and ONLY a decimal: that is, numbers which do NOT
+ have a 0b/0o/0x prefix), it's possible to attach the type annotation
+ as a suffix directly to the number, without any additional syntax.
They also come with some additional rules (like only being available
for decimals), in order to prevent potential ambiguity or footguns
@@ -343,31 +351,33 @@ Table of Contents
* ., ,, or _
- * [a-zA-Z][0-9_] (to disambiguate all non-decimals, with breathing
- room)
-
* [eE][+-]?[0-9] (to disambiguate exponentials)
- * [xX][a-fA-F] (to disambiguate hexadecimals)
+ For example, 10,000 is illegal. 10e0n is illegal, but 10e0 is a legal
+ _decimal number using exponential syntax_, *not* equivalent to
+ (e0)10. Additionally, note that since bare suffixes are only legal
+ on _decimals_, 0u8 is legal, but 0xs is _not_, since hexadecimals are
+ determined by their prefixes. Similarly, 1xs _is_ legal, and
+ equivalent to (xs)1.
All other (Section 3.10)s can be safely appended to decimal numbers,
so long as the decimal does not include an exponential component.
If the desired suffix would violate any of the above rules, either
- regular parenthetical (Section 3.8)s, or (Section 3.8.1.2)s may be
+ regular parenthetical (Section 3.8)s or (Section 3.8.1.2)s may be
used.
3.8.1.2. Explicit Suffix Type Annotation
- Any (Section 3.14) may have a # attached to it, followed by any valid
+ Any (Section 3.14) may have a # appended to it, followed by any valid
(Section 3.10). This is an explicit (Section 3.8.1) syntax without
any of the relatively complex requirements of (Section 3.8.1.1),
- which can be a useful escape hatch. For example: 10.0#u8 is invalid
+ which can be a useful escape hatch. For example: 0#b1 is invalid
syntax without the # prefix.
Note again that, unlike (Section 3.8.1.1)s, Explicit Suffixes may be
used with ALL (Section 3.14) formats (hexadecimal, decimal, octal,
- and binary). For example, 0x1234#u16 is valid.
+ and binary). For example, 0x1234#u32 is valid.
3.8.2. Reserved Type Annotations for Numbers Without Decimals
@@ -1146,8 +1156,9 @@ Table of Contents
node-terminator := single-line-comment | newline | ';' | eof
prop := string node-space* '=' node-space* value
- value := type? node-space* (string | number | keyword)
+ value := normal-value | suffixed-decimal
type := '(' node-space* string node-space* ')'
+ normal-value := type? node-space* (string | number | keyword)
// Strings
string := identifier-string | quoted-string | raw-string ¶
@@ -1208,24 +1219,25 @@ Table of Contents
// Numbers
number := keyword-number | hex | octal | binary | decimal
- decimal := sign? integer ('.' integer)? (
- // NOTE: This grammar does not explicitly guard against having both
- // parenthesized and type suffixes.
- bare-type-suffix |
- explicit-type-suffix |
- (exponent explicit-type-suffix?)
- )?
+ decimal := significand exponent?
+ suffixed-decimal := significand (
+ bare-type-suffix
+ | (exponent? explicit-type-suffix)
+ )
+ significand := sign? significand-initial integer? ('.' integer)?
exponent := ('e' | 'E') sign? integer
integer := digit (digit | '_')*
+ significand-initial = digit
+ - '0b'
+ - '0o'
+ - '0x'
digit := [0-9]
sign := '+' | '-'
bare-type-suffix := bare-type-suffix-initial identifier-char*
bare-type-suffix-initial := identifier-char
- '.' - ',' - '_'
- - ([a-zA-Z] [0-9_])
- (('e' | 'E') sign? digit)
- - (('x' | 'X') [a-fA-F])
explicit-type-suffix := '#' identifier-string
hex := sign? '0x' hex-digit (hex-digit | '_')*