This document aims to describe the accepted syntax for parsing rsn
. Currently, it is more of a TODO list than actual documentation.
An rsn
payload contains a single Value
, which can be one of these types:
- Integer:
123
;-123_456
;0x0123_aBc
;0o123_777
;0b1010_1111
- Float:
1.
;-2_000.123_456
;1e-2
- Boolean:
true
;false
- Character:
'a'
;'\''
- Byte:
b'a'
;b'\''
- String:
"hello, world"
;r#"raw "strings""#
- Byte String:
b"hello, world"
;br#"raw "strings""#
- Map:
{key: "value"}
;{a: 1, b: true,}
- List:
[1, 2, 3]
;["a", "b",]
- Tuple:
(1, false)
;(2, true,)
- Identified:
Name
;Name { a: 1 }
;Name(1)
Just like in Rust, integers can be represented in four different
representations: decimal (base 10), binary (base 2), octal (base 8), and
hexadecimal (base 16). Integer parsing ignores underscores (_
) to allow large
literals to be grouped however the user prefers.
If an integer has no explicit sign, it will be parsed as a usize
. If the value
overflows, it will be promoted to the "large integer size". If the integer128
feature is enabled, the "large integer size" is a u128
. If the feature is not
enabled, the "large integer size" is a u64
.
If either a +
or -
sign is present, the integer will be parsed as an isize
with the appropriate sign applied. If the value overflows, it will be promoted
to the "large integer size". If the integer128
feature is enabled, the "large
integer size" is a i128
. If the feature is not enabled, the "large integer
size" is a i64
.
Integer values always begin with a digit (0-9
) or a sign (+
/-
).
- If a sign (
+
or-
) is encountered, the literal is parsed as a signed number. - At least one digit (
0-9
) must be present.- If the first digit is a
0
and it is followed by anx
or 'X', parse the remainder of this literal as a hexadecimal number. - If the first digit is a
0
and it is followed by ab
or 'B', parse the remainder of this literal as a binary number. - If the first digit is a
0
and it is followed by ano
or 'O', parse the remainder of this literal as an octal number.
- If the first digit is a
- Continue reading digits (
0-9
) or underscores (_
) until a non-matching character is encountered. - If the first non-matching character is either a
.
,e
orE
, switch to parsing this numerical value as a float.
Hexadecimal values are parsed after encountering 0x
while parsing an
integer. After this prefix, parsing is done by reading hexadecimal
digits (0-9
, a-f
, A-F
) or underscores (_
) until a non-matching character
is encountered.
Octal values are parsed after encountering 0o
while parsing an
integer. After this prefix, parsing is done by reading octal digits
(0-7
) or underscores (_
) until a non-matching character is encountered.
Binary values are parsed after encountering 0b
while parsing an
integer. After this prefix, parsing is done by reading binary digits
(0
or 1
) or underscores (_
) until a non-matching character is encountered.
- Tokenizer support
-
inf
/NaN
support
-
- Parser support
- Deserializer Support
- Documentation
- Grammar Spec
- Tokenizer support
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
- Support same whitespace rules on raw line ending escaping.
- Error-by-default on multiple line ending removal with raw line ending escaping, just like rustc, but allow a parsing option that prevents the errors.
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
-
b64
prefixed base64-encoded byte strings
-
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
- Parser support
- Deserializer Support
- Documentation
- Tokenizer support
- Parser support
- Deserializer Support
- Documentation