Alternatives for configuration format #3

Open
opened 5 years ago by Rirush · 1 comments
Rirush commented 5 years ago
Owner

no_std serde JSON parser is broken, and it would've been better to implement my own configuration format or use another with better parser.

no_std serde JSON parser is broken, and it would've been better to implement my own configuration format or use another with better parser.
Rirush added the
Improvement
label 5 years ago
Rirush added the
Essential
label 5 years ago
Poster
Owner

Since there aren't any no_std serde libraries for parsing configuration formats, I guess it's better to write our own. And to gain some experience, we'll make our own configuration file format.

// Integer type
integer = 1;
// Floating point type
float = 1.0;
// Boolean type
bool = true;
// String type, should support escape sequences
string = "text";
// Tuple type
tuple = ("text", 1);
// Array type, all fields should be of one type. Type of array is decided by first element
array = [1, 2, 3];
// Map (dictionary) type
map = !["a": 1, "b": 2];
// Object type
object = {
    // Objects can have fields of any type
    array = [4, 5, 6];
    // Empty objects are allowed too
    nested_object = {};
};
// Null type, deserializes into None in Rust. 
// If a value should be serialized into Option<T> and is absent, then it is treated as null.
null = _;
// Value copy
copy = #object.array;
// Reference
ref = &object.nested_object;

Serializer and deserializer will be implemented inside CoonCTRB library.

Since there aren't any `no_std` serde libraries for parsing configuration formats, I guess it's better to write our own. And to gain some experience, we'll make our own configuration file format. ```none // Integer type integer = 1; // Floating point type float = 1.0; // Boolean type bool = true; // String type, should support escape sequences string = "text"; // Tuple type tuple = ("text", 1); // Array type, all fields should be of one type. Type of array is decided by first element array = [1, 2, 3]; // Map (dictionary) type map = !["a": 1, "b": 2]; // Object type object = { // Objects can have fields of any type array = [4, 5, 6]; // Empty objects are allowed too nested_object = {}; }; // Null type, deserializes into None in Rust. // If a value should be serialized into Option<T> and is absent, then it is treated as null. null = _; // Value copy copy = #object.array; // Reference ref = &object.nested_object; ``` Serializer and deserializer will be implemented inside [CoonCTRB](https://git.foxdogcoon.me/CoonOS/CoonCTRB) library.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.