make unicodey equals signs valid property assignment characters

This commit is contained in:
Kat Marchán 2023-12-16 16:09:13 -08:00
parent 50d378f1db
commit 90cd0b1bb9
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
5 changed files with 31 additions and 6 deletions

View File

@ -58,6 +58,10 @@
least-indented line in the body. Multiline strings and raw strings now must least-indented line in the body. Multiline strings and raw strings now must
have a newline immediately following their opening `"`, and a final newline have a newline immediately following their opening `"`, and a final newline
preceding the closing `"`. preceding the closing `"`.
* SMALL EQUALS SIGN (`U+FE66`), FULLWIDTH EQUALS SIGN (`U+FF1D`), and HEAVY
EQUALS SIGN (`U+1F7F0`) are now treated the same as `=` and can be used for
properties (e.g. `お名前=☜(゚ヮ゚☜)`). They are also no longer valid in bare
identifiers.
### KQL ### KQL

View File

@ -158,10 +158,12 @@ node3 #"C:\Users\zkat\raw\string"#
You don't have to quote strings unless they contain whitespace, or if any the You don't have to quote strings unless they contain whitespace, or if any the
following apply: following apply:
* The string contains `[]{}()\/#=";`. * The string contains `[]{}()\/#";`.
* The string contains whitespace. * The string contains whitespace.
* The string is one of `true`, `false`, or `null`. * The string is one of `true`, `false`, or `null`.
* The strings starts with a digit, or `+`/`-` and a digit. * The strings starts with a digit, or `+`/`-` and a digit.
* The string contains an equals sign (including unicode equals signs `﹦`,
``, and `🟰`).
In essence, if it can get confused for other KDL syntax, it needs quotes. In essence, if it can get confused for other KDL syntax, it needs quotes.
@ -294,8 +296,8 @@ smile 😁
// Identifiers are very flexible. The following is a legal bare identifier: // Identifiers are very flexible. The following is a legal bare identifier:
<@foo123~!$%^&*.:'|?+> <@foo123~!$%^&*.:'|?+>
// And you can also use unicode! // And you can also use unicode, even for the equals sign!
ノード お名前=☜(゚ヮ゚☜) ノード お名前☜(゚ヮ゚☜)
// kdl specifically allows properties and values to be // kdl specifically allows properties and values to be
// interspersed with each other, much like CLI commands. // interspersed with each other, much like CLI commands.

20
SPEC.md
View File

@ -137,7 +137,8 @@ negative number.
The following characters cannot be used anywhere in a [Bare Identifier](#identifier): The following characters cannot be used anywhere in a [Bare Identifier](#identifier):
* Any of `(){}[]/\="#;` * Any of `(){}[]/\"#;`
* Any [Equals Sign](#equals-sign)
* Any [Whitespace](#whitespace) or [Newline](#newline). * Any [Whitespace](#whitespace) or [Newline](#newline).
* Any [disallowed literal code points](#disallowed-literal-code-points) in KDL * Any [disallowed literal code points](#disallowed-literal-code-points) in KDL
documents. documents.
@ -163,7 +164,8 @@ my-node 1 2 \ // comments are ok after \
### Property ### Property
A Property is a key/value pair attached to a [Node](#node). A Property is A Property is a key/value pair attached to a [Node](#node). A Property is
composed of an [Identifier](#identifier), followed immediately by a `=`, and then a [Value](#value). composed of an [Identifier](#identifier), followed immediately by an [equals
sign](#equals-sign), and then a [Value](#value).
Properties should be interpreted left-to-right, with rightmost properties with Properties should be interpreted left-to-right, with rightmost properties with
identical names overriding earlier properties. That is: identical names overriding earlier properties. That is:
@ -181,6 +183,17 @@ still be spec-compliant.
Properties _MAY_ be prefixed with `/-` to "comment out" the entire token and Properties _MAY_ be prefixed with `/-` to "comment out" the entire token and
make it act as plain whitespace, even if it spreads across multiple lines. make it act as plain whitespace, even if it spreads across multiple lines.
#### Equals Sign
Any of the following characters may be used as equals signs in properties:
| Name | Character | Code Point |
|----|-----|----|
| EQUALS SIGN | `=` | `U+003D` |
| SMALL EQUALS SIGN | `﹦` | `U+FE66` |
| FULLWIDTH EQUALS SIGN | `` | `U+FF1D` |
| HEAVY EQUALS SIGN | `🟰` | `U+1F7F0` |
### Argument ### Argument
An Argument is a bare [Value](#value) attached to a [Node](#node), with no An Argument is a bare [Value](#value) attached to a [Node](#node), with no
@ -600,9 +613,10 @@ numberish-ident := sign ((identifier-char - digit) identifier-char*)?
identifier-char := unicode - line-space - [\\/(){};\[\]="#] - disallowed-literal-code-points identifier-char := unicode - line-space - [\\/(){};\[\]="#] - disallowed-literal-code-points
keyword := '#' (boolean | 'null') keyword := '#' (boolean | 'null')
prop := identifier optional-node-space '=' optional-node-space value prop := identifier optional-node-space equals-sign optional-node-space value
value := type? optional-node-space (identifier | string | number | keyword) value := type? optional-node-space (identifier | string | number | keyword)
type := '(' optional-node-space identifier optional-node-space ')' type := '(' optional-node-space identifier optional-node-space ')'
equals-sign := See Table (Equals Sign)
string := raw-string | escaped-string string := raw-string | escaped-string
escaped-string := '"' (single-line-string-body | newline multi-line-string-body newline ws*) '"' escaped-string := '"' (single-line-string-body | newline multi-line-string-body newline ws*) '"'

View File

@ -0,0 +1 @@
node p1=val1 p2=val2 p3=val3

View File

@ -0,0 +1,4 @@
node \
p1﹦val1 \ // U+FE66
p2val2 \ // U+FF1D
p3🟰val3 // U+1F7F0