This crate is very early in development and is not ready for consumption.
A UTF-8 based text format that looks very similar to valid Rust code.
The syntax differs from valid Rust code for:
- Map literals. Rust has no syntax for map literals.
- Enum Variants being used without the type name --
Red
vsColor::Red
- This is technically valid Rust syntax if
use Color::*
is present.
- This is technically valid Rust syntax if
- Infinity and Not-A-Number floats are represented as
+Inf
/-Inf
/+NaN
/-NaN
.
The rules for parsing literals should match Rust's rules as closely as possible.
This crate supports no_std
targets that support the alloc
crate.
-
Integers (
42
,0xFF
,0o77
,ob101
) -
Floats (
42.
,3.14
, `) -
Bool (
true
,false
) -
Character (
'a'
,'\''
) -
Byte (
b'a'
,b'\''
) -
String (
"hello, world"
) -
Raw Strings (
r#"They said, "Hello World!""#
) -
Byte Strings (
b"hello, world"
) -
Struct
- Ident or Raw Ident (
r#foo
) - Map or Tuple
- Ident or Raw Ident (
-
Map
- List of
<Value>: <Value>
pairs, delimited by comma - Trailing comma is optional
- List of
-
Tuple (empty tuple = Unit)
- List of
<Value>
s, delimited by comma - Trailing comma is optional
- List of
-
Array
- List of
<Value>
s, delimited by comma - Trailing comma is optional
- List of
-
Comments
//
and/* */
-
Potential Extensions via #[] syntax
- Semi-strict comma-delimited list
#[foo(...), bar = ...,]
- All braces/brackets/parens must be paired correctly?
Ron is a great format. There were a few design decisions that led to this very-similar-yet-not-the-same format being invented:
ron
differentiates between Tuples and Lists, whilersn
treats all sequences the same.ron
uses a different syntax for structures and maps.rsn
uses the same syntax for both concepts.ron
has special support forOption<T>
.rsn
treatsOption<T>
like any other enum.ron
's parsing rules are close but not the same as Rust, whilersn
attempts to match implementations:- Rust allows unicode identifiers
- Rust allows additional whitespace characters
- Rust allows
_
in float literals - Rust allows for raw line endings to be escaped in string literals.
- Rust supports multi-line comments
/* ... */
- Rust supports byte strings and byte literals, while Ron elected to use
base64
encoded strings for byte values.